Input order: Student ID: Islam, Md. Rashedul Tree input order: 5,4,1,9,2,3,8,6,7 Part A:Build a Binary Search Tree with the given input order. You must show step by step process of inserting the inputs including both recursive calls and tree diagrams for each step. [ refer to the InsertItem function of Lecture10 slides to get an idea of doing this.] N.B: Unique Input orders for each student to build the tree are given on a separate file. Write down the input order on your answer script before answering the question. You must use the assigned input order. Do not change the order. InserItem function: void Insert(TreeNode *&tree, ItemType item) {

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Input order:

Student ID: Islam, Md. Rashedul

Tree input order: 5,4,1,9,2,3,8,6,7

Part A:Build a Binary Search Tree with the given input order. You must show step by step
process of inserting the inputs including both recursive calls and tree diagrams for
each step. [ refer to the InsertItem function of Lecture10 slides to get an idea of
doing this.]
N.B: Unique Input orders for each student to build the tree are given on a separate
file. Write down the input order on your answer script before answering the question.
You must use the assigned input order. Do not change the order.

InserItem function:

void Insert(TreeNode *&tree, ItemType item)

{

  if (tree == NULL)//Base case:Insertion place found.

  {

    tree = new TreeNode;

    tree->right = NULL;

    tree->left = NULL;

    tree->info = item;

  }

  else if (item < tree->info)

    Insert(tree->left, item);//General case 1:Insert in left subtree.

  else

    Insert(tree->right, item);//General case 2:Insert in right subtree.

}

 

void TreeType::InsertItem(ItemType item)

{

  Insert(root, item):

}

Part B:Write down the inorder, preorder, and post-order traversal of the tree you made in Part A.
Part C:Delete the Left Node of level 1 from the tree you have built in Question 1. Show
step-by-step procedure of deleting and draw the final status of the tree after deletion
is completed.
Now, you have a new tree that is different from the previous tree. Delete the Right
Node of level 1 from this derived tree. Show step-by-step procedure of deleting and
draw the final status of the tree after deletion is completed.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY