Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 2PC
Program Plan Intro

Tree Size

Program Plan:

  • Define a class BTreeNode to create nodes for binary search tree items.
    • Include all the required header files.
    • Initialize a value to the node, and set the left child of node to leftp and right child of node to rightp .
  • Define a class to create a Binary Search Tree.
    • Create a function int size that returns no. of items present in the tree.
  • Create a function bool search to search a particular item in tree.
    • Create function void insert to insert nodes into the tree.
  • Create a function void inorder to sort items in inorder traversal.
  • Declare the main function.
    • Prompt the user to enter 5 numbers to be inserted into tree.
  • Sort the items present in the tree in inorder traversal and return the number of items present in the tree.

Blurred answer
Students have asked these similar questions
Programming questions:typedef struct node {      int data;      struct node  *left, *right;}BT;The node structure of the binary tree (BT) is shown above. There is a binary tree T, please complete the function: int degreeone(BT *T) to compute how many degree 1 node in the BT. The T is the root pointer, and the function shoule return the total number of degree 1 node.
typedef struct node{int data;struct node *left,*right;}BST;The node structure of BST is shown above. Please design an efficient algorithm to return the maximum keyword value in BST. Completion function: int findmax (BST *T)
You have a large data set of an area with income and number of people having that income. You want to create an efficient search system using Binary Search Tree (BST) to search an income and related count. Input to be read from in.txt file, Consider a file (you have to create in.txt file and copy the sample data shown below) with total number of people (N) in the first line and next N lines will contain the income and corresponding count separated by space. Output: display the result in console. Do not spend too much time to produce exact output format as we will check the output manually. Tasks: [you have to write a set of functions and test them. Some of them are fairly small] 1. Create a binary search tree based on the income as the key. However, you should also store the corresponding count within the BST node. 2. Print the data in the tree in the inorder traversal to see the keys are in sorted order. Print them like comma separated tuple (income, count). (income, count)..... 3.…
Knowledge Booster
Background pattern image
Computer Science
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
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