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
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.
Exercise 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.
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
- data structurearrow_forwardDon'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_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_forwardPractice recursion on lists Practice multiple base conditions Combine recursion call with and,or not operators Search for an element in a list using recursion Instructions In this lab, we will write a recursive function for searching a list of integers/strings. Write a recursive function to determine if a list contains an element. Name the function recursive_search(aList, value), where aList is a list and value if primitive type is the object we want to search for. Return a boolean, specifically True if and only if value is an element of aList else return False from the function Examples: recursive_search([1,2,3], 2) == True recursive_search([1,2,3], 4) == False recursive_search([ ], 4) == False recursive_search([ [ 1 ], 2 ], 1) == False # -----> (because the list contains [ 1 ] and 2, not 1) Hint: Think about what the base case is? When is it obvious that the element is not in the list? If we are not at the base case, how can you use the information about the first element of the…arrow_forward
- 21. 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_forwardWrite 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_forward10arrow_forward
- Q. 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_forward2). Write a program to implement the following graph representations and display them. i. Adjacency list ii. Adjacency matrixarrow_forward1.) Design a Binary Search Tree ADT by using following functions. Include the function definitions & run the program (Kindly include header files as well). Paste the output as a screenshot and write the code in your answer sheet. insert(int val)find(int x)************************************************************************************ class btNode { public: int info; btNode *lLink; btNode *rLink; btNode(int e, btNode *l = NULL, btNode *r = NULL) { info = e; lLink = l; rLink = r; } btNode() { lLink = NULL; rLink = NULL; } }; class binarySTADT { private: btNode *root; int count = 0; public: binarySTADT() { root = NULL; } void insert(int val); // function to insert a given value in the 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