C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 19, Problem 19.23E
Program Plan Intro
Program Plan:
To provide support for Level Order traversal in Binary Tree, a new function to existing class BST has been added.
Void LevelOrderTraversal (node *);
As defined in exercise, this program needs to use queue to store all Nodes of Tree to traverse them according to level.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Language : C
Single Linked Linear List (S.L.L.L.)
1-Write a steps to search for a node contain a given value in a S.L.L.L. its head is
given by pointer variable ( First )
2-Write Recursive function to count number of nodes in a given S.L.L.L.
3-Write a steps to count number of nodes contain odd number in a given
S.L.L.L. its head is given by pointer variable ( First ).
4-Write a steps to test values stored in S.L.L.L. if it is in ascending order or not .
c)
An expression of A + B^3 – C/D is obtained using a rooted tree.
i.
Draw a rooted tree with the height of 2 to represent the postorder traversal.
ii.
Justify whether the rooted tree in 3-c(i) is balanced or not.
iii.
From tree in c(i), get the mathematical expression using the inorder traversal.
d)
Figure 3 represents a network of paths in a park. The number on each edge represents the
length of the path in meters. The cost per meter is RM120. To gain as much profit, the
contractor asked one of his staff to find the minimum network needed using Kruskal's
algorithm.
G
21
16
17
21
F
11
23
E
11
7
15
18
В 11
20
A
Figure 3
i.
Explain why the staff's work which is highlighted in red is incorrect.
ii.
Help the staff to find the correct minimum network using Kruskal's algorithm and
states its length and total cost.
iii.
Is there any possibiliy, more than one distint MST obtained for the Figure 3?. If yes,
justify your answer and show the network.
Chapter 19 Solutions
C++ How to Program (10th Edition)
Ch. 19 - Prob. 19.6ECh. 19 - Prob. 19.7ECh. 19 - Prob. 19.8ECh. 19 - Prob. 19.9ECh. 19 - Prob. 19.10ECh. 19 - Prob. 19.11ECh. 19 - (Infix-to-Post fix conversion) Stacks are used by...Ch. 19 - Prob. 19.13ECh. 19 - Prob. 19.14ECh. 19 - Prob. 19.15E
Ch. 19 - Prob. 19.16ECh. 19 - Prob. 19.17ECh. 19 - (Duplicate Elimination) In this chapter, we saw...Ch. 19 - Prob. 19.19ECh. 19 - Prob. 19.20ECh. 19 - Prob. 19.21ECh. 19 - Prob. 19.22ECh. 19 - Prob. 19.23ECh. 19 - Prob. 19.24ECh. 19 - Prob. 19.25ECh. 19 - Prob. 19.26ECh. 19 - Prob. 19.27ECh. 19 - Prob. 19.28E
Knowledge Booster
Similar questions
- 6Recursion 8, 21, 34, 55, 89 ... ]: The Fibonacci sequence is the series of integers 0, 1, 1, 2, 3, 5, See the pattern? Each element in the series is the sum of the preceding two items. There is a recursive formula for calculating the nh number of the sequence (the 0th number if Fib(0) = 0): N, if N =0 or 1 Fib(N) = %3D Fib(N- 2) +Fib(N -1) if N>1 1. Write a recursive version of the function Fibonacci. 2. Write a non-recursive version of the function Fibonacci. 3. Compare the recursive and iterative versions for efficiency. 4. Can you think of a way to make the recursive version more efficient? If so, discuss your solution in detail.arrow_forwardExercise 1: (Divide and Conquer: Binary tree traversal) Write pseudocode for one of the classic traversal algorithms (preorder, inorder, and postorder) for binary trees. Assuming that your algorithm is recursive, find the number of recursive calls made.arrow_forward***Please type your answer or write in print, because I have had great difficulty with understanding most handwritten assistance done in cursive or mixed print/cursive.arrow_forward
- Don't rejectarrow_forward1001 UnaI (p E. Write a program named as ProblemE_.cpp that constructs a BST from a given postorder traversal of that tree. For example, if the given traversal is {1, 7, 5, 50, 40, 10}, then the output should be the tree shown in Problem 3. Hints: • Write a recursive function to do the followings: a) Get the last element of the array and make it root of the BST. b) Find the index i such that the value in i-1 is the first value smaller than the root. c) Recursively call a function to do the same for left subarray (1 .. i-1) and right subarray (i..size-2). i) Get the last element of right half and make it right child of the root created in step a. ii) Get the last element of left half and make it left child of the root created in step a. d) return root.arrow_forwardA tree can be represented using lists as follows. (root listOfSubTrees ) tree listOfSubTrees tree = root listOfSubTrees = tree Consider the tree defined by: (FD (G (AHI) C) E B) Give the order of letters visited in when using a pre-order traversal implemented recursively as seen in class. (separate each element with a space where the left is the first element visited and the right is the last element visited, example: A B C D E F)arrow_forward
- 1. Do some research about binary search trees. 2. Create a structure in C for the nodes of this tree. Which variables do the structure have? 3. Write a function that builds a balanced binary search tree. The input argument of this function is a sorted array of integers. 4. Write a recursive function that inserts a new element to the tree. The input argument of this function is a pointer to the head node of the tree. 5. What is the time complexity of this insertion function?arrow_forward2. A binary tree is considered "lucky" if it is empty, or if exactly one of its sub-trees is lucky. Write a recursive function named isLucky(struct node *root) which returns 1 if a tree is lucky and 0 if not. You must use the above definition of "lucky," and your code must be recursive. Do not use any for, while or until loops.arrow_forward21. Assume the graph is represented by two linear arrays corresponding to the end vertices of edges. Write and explain the algorithm to find a spanning tree of the graph with an example.arrow_forward
- Write a C++ code for A) Removal of node from Binary Search Tree. Hand written code and screen shot of output is required before and after deletion. B) Display code is required for In-Order and Post Order traversal of binary search tree.arrow_forwardLanguage : Carrow_forwardQ. Write a C++ code for A) Removal of node from Binary Search Tree. Hand written code and screen shot of output is required before and after deletion. B) Display code is required for In-Order and Post Order traversal of binary search tree.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education