Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
Chapter 19, Problem 10PC
Program Plan Intro

Prefix Representation of Binary Trees

Program Plan:

“IntBinaryTree.h”:

  • Include all the required header files.
  • Define the class “TreeNode”.
    • Assign a value to the node, and set the left child of node to leftp and right child of node to rightp.
    • Create function void insert to insert items into nodes of tree.
    • Create a function void destroySubtree that calls the binary tree function and deletes the nodes which are present in the tree.
    • Function to overload the stream insertion and print tree elements void treePrint is called.
    • Functions to display the tree in inorder , pre order and post order void displayInOrder , void displayPreOrder(TreeNode *) and void displayPostOrder are called.
    • Print all the elements of the tree.

“IntBinaryTree.cpp”:

  • Include all the required header files.
  • Create a tree Function void IntBinaryTree::insert that inserts a number into a given sub tree of the main binary search tree by checking for availability of free nodes in the binary search tree.
  • Create a function void IntBinaryTree::destroySubtree calls the binary tree function and deletes the nodes which are present in the tree.
  • Create a function bool IntBinaryTree::search where user enters a number to search, the function search searches the number inside the binary search tree and if present returns true, else false otherwise .
  • Create a tree function void IntBinaryTree::remove that deletes the node in the given tree that has same value as entered by user by searching the left and right subtrees.
  • Display the tree elements in inorder, pre order and post order.
  • Display the items present in tree prefix type.

“main.cpp”:

  • Include all the required header files.
  • Call the Binary tree class to build a tree.
  • Enter elements into the tree.
  • Delete elements and print the elements of the tree in prefix form.

Blurred answer
Students have asked these similar questions
Of the five primary components of an information system (hardware, software, data, people, process), which do you think is the most important to the success of a business organization? Part A - Define each primary component of the information system. Part B - Include your perspective on why your selection is most important. Part C - Provide an example from your personal experience to support your answer.
Management Information Systems
Q2/find the transfer function C/R for the system shown in the figure Re ད
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