C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 12.16E
Program Plan Intro
Program plan:
- item variable is used for input. There is structure Treenode having data, leftptr, rightptr member variables which represents the tree node.
- void insertnode(node **ptr, char *value) function inserts the node in the tree.
- void preorder(node *ptr) function displays the contents of the tree in a preorder fashion.
- void inorder(node *ptr) function displays the contents of the tree in an in-order fashion.
- void postorder(node *ptr) function display the contents of the tree in a post-order fashion.
Program description:
The main purpose of the program is to create a tree from the input entered by user. This violates the binary tree insertion rule and allows the user to enter the duplicate values as well. Then the created tree contents are displayed in preorder, inorder and postorder fashion.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
1001 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.
( Solve it by using Scanner )
Using Binary search tree write a Java program to Insert and print the element in (in-Order traversal ), then search the elements (a and z) in the tree.
6. Symbolize the following statement in P (be sure to include your translation key).
'Every forest is full of trees.'
Chapter 12 Solutions
C How to Program (8th Edition)
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
- (Questions 13-16) A researcher is interested in how variables, such as GRE (Graduate Record Exam scores), GPA (grade point average) and prestige of the undergraduate institution (RANK), affect admission into graduate school. The response variable, admit/don't admit, is a binary variable. Based on the generated classifications tree, answer questions 13-16. 0 0.20 49% O 51% Ⓒ29% 23% 0 0.32 100% yes rank>-3-no -20% 0.29 23% 0 0.20 3% 0 10.43 51% gpa -2 0 0.47 17% gpa-3.5- Question 13: What's the average admission rate of the students whose rank is less than 3 and gpa is less than 3.4? 1 0.75 2% 1 0.69 4% 0.81 8%arrow_forwardC using pythonarrow_forward#python codecoud you provide comments and little explanation it would really help me to understandthankyouarrow_forward
- (ABET 2) Construct a regular expression corresponding to the following set: {binary strings such that every odd position is a 1}. You may assume that the even positions can be a 0 or 1.arrow_forwardB2. b. Given the following infix expression: ((X-Y)/((Z+P) *Q)) 1- Draw the parse tree for this expression 2-Write the equivalent postfix expressionarrow_forward2. Write the following recursive expression tree functions a. Prefix b. Infix c. Postfix d. Evaluate (Evaluate the expression tree-return the value)arrow_forward
- 3 // C++ Code. This is all the info that was provided... I don't understand Given the attached Merkle Tree from http://en.wikipedia.org/wiki/Merkle_tree Let L1=Then out spake brave Horatius, The Captain of the Gate: L2="To every man upon this earth Death cometh soon or late. L3=And how can man die better Than facing fearful odds, and L4=For the ashes of his fathers, And the temples of his Gods." Create all hashes 0-0, 0-1, 1-0, 1-1, 0, 1 with top Show all you need to do to confirm L1 is 0-1, 0, top L2 is 0-0, 1, top L3 is 1-1, 0, top and L4 is 1-0, 0, toparrow_forwardD. Write a program named as ProblemD_.cpp that constructs a BST from a given preorder traversal of that tree. For example, if the given traversal is (10, 5, 1, 7, 40, 50), then the output should be following tree. 10 40 1 7 50 Hints: • Write a recursive function to do the followings: a) Get the first 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 bigger than the root. c) Recursively call a function to do the same for left subarray (1.. i) and right subarray (i+1.size-1). i) Get the first element of left half and make it left child of the root created in step a. ii) Get the first element of right half and make it right child of the root created in step a. d) return root.arrow_forward- Do not add any imports, the ones that you need will be given to you.- Do not use recursion.- Do not use break/continue.- Do not use try-except statements, you should be able to anticipateor prevent any errors from happening at all!arrow_forward
- apartmentList is a pointer to the first node in a linked list of nodes. Use this for Parts a, b, and c. Part a. Create an inner class that will hold the following information: the apartment number of the apartment (an int), the number of bedrooms in the apartment (also an int), the current rent of the apartment (a double). Don't forget to include a field for the link! Just create the class itself and the instance variables; you don't need to put any methods into the class.arrow_forward2, Towers of Hanoi Problem. (10 points) The Towers of Hanoi is a famous problem for studying recursion in computer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. Answer the following questions. (1) Determine a state representation for this problem. (4points) (2) What is the size of the state space? (3 points) (3) Supposing K=3, N=4, what is the start state by using your proposed state representation method and what is the goal state? (3 points)arrow_forwardCalculation "a" was used for loop to calculate the sum of squares of values in this list: 1, 7, 8, 6, 11 (The answer was 271) (Question 1) Create recursive function to do the same calculation "a" in the above. (The function input will be the list. Each recursion, you are going to send a sub-list with one less item from the list) (Hint:There are many ways to do sorting. Create a function to perform bubble sorting as descried in this tutorial: (https://www.geeksforgeeks.org/bubble-sort/) . The algorithm should stop when there are no swaps in the last iteration.)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