MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 12.23E
Program Plan Intro
Program plan:
- Item, root variablesare used for input. There is structure Treenode havingdata, leftptr, rightptrmember variables which represents the tree node. Structure qitem having treenode, nextPtrvariables which represents the queue and stores the Treenodetype value.
- voidinsertnode(node **ptr, int value) function inserts the node in the tree and create a tree.
- voidinorder(node *ptr) function displays the tree values in sorting order.
- voidpreorder (node *ptr) function displays the tree values in pre order fashion.
- voidpostorder(node *ptr) function displays the tree values in post order.
- voidlevelorder(node *ptr) function display the tree values in sorting order.
- voidenque(queue **front, queue **taiil, node *tnode) function stores the Treenodetype data in a queue.
- node*deque(queue **front, queue **tail) function delete the Treenode type from the queue and return the Treenode type value.
Program description:
The main purpose of the program is to create binary search tree and display the tree value using levelorder
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
Language : C
Course : Data Structure and Algorithms
Write a java/c++ code or an algorithm to solve the following problem. After that dry run and show output of algorithm using an example binary tree. .
Write a recursive function to write the parent of the all the nodes while traversing. Like if you traverse the root node write the current node a, parent null. Then if you go to left sub tree, your code will show, current node : b , parent a and so on.
Chapter 12 Solutions
MYPROGRAMMINGLAB WITH PEARSON ETEXT
Ch. 12 - Prob. 12.6ECh. 12 - (Merging Ordered Lists) Write a program that...Ch. 12 - Prob. 12.8ECh. 12 - (Creating a Linked List, Then Reversing Its...Ch. 12 - Prob. 12.10ECh. 12 - Prob. 12.11ECh. 12 - Prob. 12.12ECh. 12 - Prob. 12.13ECh. 12 - Prob. 12.14ECh. 12 - (Supermarket Simulation) Write a program that...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- [8] Instructions: Kindly provide the complete and correct solutions. I won't like it if it is incomplete and incorrect.arrow_forwardDon't rejectarrow_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
- (1 of 2 parts) Suppose you have a binary search tree with the following in-order traversal: ACEFHIJKMSW Then suppose we deleted a node with two children from that tree. The post- order traversal of the resulting tree is: AEHFCKW SMJ what is the level order traversal of the original treearrow_forward1. 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_forwardlütfen yanlızca c kodu kullanın ve verilen direktifleri uygulayın.arrow_forward
- 1). Write a program to construct a binary tree to support the following operations. Assume no duplicate elements while constructing the tree. i. Given a key, perform a search in the binary search tree. If the key is found then display "key found" else insert the key in the binary search tree. ii. Display the tree using inorder, preorder and post order traversal methodsarrow_forward*Please using JAVA only* Objective Program 3: Binary Search Tree Program The primary objective of this program is to learn to implement binary search trees and to combine their functionalities with linked lists. Program Description In a multiplayer game, players' avatars are placed in a large game scene, and each avatar has its information in the game. Write a program to manage players' information in a multiplayer game using a Binary Search (BS) tree for a multiplayer game. A node in the BS tree represents each player. Each player should have an ID number, avatar name, and stamina level. The players will be arranged in the BS tree based on their ID numbers. If there is only one player in the game scene, it is represented by one node (root) in the tree. Once another player enters the game scene, a new node will be created and inserted in the BS tree based on the player ID number. Players during the gameplay will receive hits that reduce their stamina. If the players lose…arrow_forwardCO LL * Question Completion Status: QUESTION 3 Write a recursive function, OnlyChild(..), that returns the number of nodes in a binary tree that has only one child. Consider binaryTreeNode structure is defined as the following. struct binaryTreeNode int info; binaryTreeNode *llink: binaryTreeNode *rlink; The function is declared as the following. You must write the function as a recursive function. You will not get any credits if a non-recursive solution is used. int OnlyChild(binaryTreeNode *p); For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). Paragraph Arial 10pt B. ^三へ三 三山 三Ex? X2 = E E E 9 Click Save and Submit to save and submit. Click Save All Answers to save all ansuwers. Is E English (United States) Focus || 15 stv MacBook Air D00 O00 F4 F5 F8 64arrow_forward
- Help on the following question A co-worker emails you and said she developed a recursive version for doing search in a binary search tree. Here’s the code for the function: public boolean searchRecursive(Node current, int searchValue) { if (current == null) return false; if (current.data == searchValue) return true; else if (current.data > searchValue) return searchRecursive(current.right, searchValue); else return searchRecursive(current.left, searchValue); } She’s not sure if there is an error or not because the code does compile. You analyze the code and respond to her as follows: Draw a picture of what a binary search tree would look like after inserting values of 10, 15, 18, 13, 5, 1, and 8 in that order Next, if you believe there is no error with the code, then show her how the code executes when searching for different values using the tree you made in step 1) Or, if you believe there is…arrow_forwardQ-13. Recursive binary tree code. Write a recursive C++ function called insert which takes two arguments: a pointer to the root of a binary scarch tree whose nodes are as defincd above, and an integer key. The function inscrts a new key into the tree and returns a pointer to the node. The tree should only store unique keys. When a duplicate key is encountered, the function increments the appropriate node count variable and returns a pointer to the node.arrow_forwardAlgorithm Design 1. In-order traversal a binary tree in two ways. 1) Use recursive method 2) Use iterative methodarrow_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