C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 12.19E
Program Plan Intro

Program plan:

  1. item, root, d variableare used for input. There is structure Treenode havingdata, leftptr, rightptr member variables which represents the tree node.
  2. void insertnode(node **ptr, int value) function inserts the node in the tree and create a tree.
  3. void inorder(node *ptr) function display the tree values in sorting order.
  4. int depth(node *ptr) determine the height of depth of tree and return max depth between left or right nodes path.

Program description:

The main purpose of the program is to create binary search tree, display the tree values and measure and display the depth of the tree.

Blurred answer
Students have asked these similar questions
(Python)- Implement functions successor and predecessor. These functions will take two arguments: the root of a tree and an integer. The successor function returns the smallest item in the tree that is greater than the given item. The predecessorfunction returns the largest item in the tree that is smaller than the given item. Both functions will return -1 if not found. Note that the predecessor or successor may exist even if the given item is not present in the tree.  Use this template:  # Node definition provided, please don't modify it.class TreeNode:def __init__(self, val=None):self.val = valself.left = Noneself.right = None# TODO: Please implement the following functions that return an integer# Return the largest value in the tree that is smaller than given value. Return -1 if not found.def predecessor(root, value):pass# Return the smallest value in the tree that is bigger than given value. Return -1 if not found.def successor(root, value):passif __name__ == "__main__":# TODO:…
Use function def showList(self) Precondition: None. Postcondition: Outputs the keys of the elements of the order list. If the list is empty, outputs “Empty list”   note: Use python and the concept of doubly Linked List
(Java) How can I implement a binary search tree in a program to store data, and use the delete method to trim the tree? The program should have a 'populate' button that obtains a string from the user, creates a sorted binary search tree of characters, and prints the tree using the DisplayTree class. It should also print the characters on one line in sorted order by traversing the tree in inorder fashion. The program should also have a 'Trim Tree' button that obtains a second line of input to delete characters from the tree, trimming the tree accordingly. It should ignore characters that are not in the tree, and only delete one character for each occurrence in the second line of input. When all characters from the second line have been deleted from the tree, the program should print the remaining characters in the tree using the DisplayTree class. The output should be labeled appropriately, and no spaces or commas should be used between tree elements in the inorder traversal.Here is the…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education