Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the second traversal and the big o Write a program that implements a binary search tree using a node-pointer implementation. Assume all entries

I need the second traversal and the big o image text in transcribed
image text in transcribed
Write a program that implements a binary search tree using a node-pointer implementation. Assume all entries in the tree will be unique. struct node t int data; node left; noderight; Requirements: 1) Implement the following functions: a) void insert (int data) I/ creates a new node and inserts it in the correct location in the tree b) void print_preorder (node root): 1I prints the data in a tree using a preorder traversal c) void print _postorder (node root) I/ prints the data in a tree using a postorder traversal d) void print inorder (node root) // prints the data in a tree using an inorder traversal e) int search (int data) // searches the tree for data. Returns 0 if data is not found, otherwise, returns the number of nodes visited MUST RUN IN 2) Insert the following sequence into the tree: Sequence A: 1,5,4,6,7,2,3 Sequence B: (Cut and paste sequence this into your source code and create a hard-initialized array) 150,125,175,166,163,123,108,116,117,184,165,137,141,111,138,122,109,194,143,183.178,173,139 126,170,190,140,188,120,195,113,104,193,181,185,198,103,182,136,115,191,144,145,155,153,151 112,129,199,135,146,157,176,159,196,121,105,131,154,107,110,158,187,134,132,179,133,102,172 106,177,171,156,168,161,149,124,189,167,174,147,148,197,160,130,164,152,142,162,118,186,169, 127,114.192,180,101,119,128,100 3) 4) Search the Sequence B tree for 196, 137, 102, 190, and print the return value Traverse the tree with each of the three traversal functions above, and generate a sequence of 5) , with a graphics program, showing the path of traversal and the DRAW the tree for w.yu sequence of processing for each of the three given traversals. That is, indicate on the path where the processing of each node occurs. Turn in 1) Paper source code listings 2) Paper output listings demonstrating all program functionality. Use the insertion sequence provided Perform all three traversals and include the output from each one A diagram for each of the three traversals 3) Write a program that implements a binary search tree using a node-pointer implementation. Assume all entries in the tree will be unique. struct node t int data; node left; noderight; Requirements: 1) Implement the following functions: a) void insert (int data) I/ creates a new node and inserts it in the correct location in the tree b) void print_preorder (node root): 1I prints the data in a tree using a preorder traversal c) void print _postorder (node root) I/ prints the data in a tree using a postorder traversal d) void print inorder (node root) // prints the data in a tree using an inorder traversal e) int search (int data) // searches the tree for data. Returns 0 if data is not found, otherwise, returns the number of nodes visited MUST RUN IN 2) Insert the following sequence into the tree: Sequence A: 1,5,4,6,7,2,3 Sequence B: (Cut and paste sequence this into your source code and create a hard-initialized array) 150,125,175,166,163,123,108,116,117,184,165,137,141,111,138,122,109,194,143,183.178,173,139 126,170,190,140,188,120,195,113,104,193,181,185,198,103,182,136,115,191,144,145,155,153,151 112,129,199,135,146,157,176,159,196,121,105,131,154,107,110,158,187,134,132,179,133,102,172 106,177,171,156,168,161,149,124,189,167,174,147,148,197,160,130,164,152,142,162,118,186,169, 127,114.192,180,101,119,128,100 3) 4) Search the Sequence B tree for 196, 137, 102, 190, and print the return value Traverse the tree with each of the three traversal functions above, and generate a sequence of 5) , with a graphics program, showing the path of traversal and the DRAW the tree for w.yu sequence of processing for each of the three given traversals. That is, indicate on the path where the processing of each node occurs. Turn in 1) Paper source code listings 2) Paper output listings demonstrating all program functionality. Use the insertion sequence provided Perform all three traversals and include the output from each one A diagram for each of the three traversals 3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What is behavioral persuasion in advertising designed to do?

Answered: 1 week ago