Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

link provided for original question, named trees Write a program that implements a binary search tree using a node-pointer implementation. Assume al entries in the

link provided for original question, named trees image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Write a program that implements a binary search tree using a node-pointer implementation. Assume al entries in the tree will be unique struct node ( int data; node left: noderight: 1) Implement the following functions: a) void insert(int data) // creates a new node and inserts it in the correct location in the tree b) void print preorder (node root): // prints the data in a tree using a preorder traversal c) void print _postorder (node root): 11 prints the data in a tree using a postorder traversal d) void print inorder (node root) 1/ prints the data in a tree using an inorder traversal (int data) 1/ searches the tree frE data. Returns 0 if data is not found, otherwise, returns the number of es 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) 50,125,175.166,163,123,108,116,117,184.165,137,141,111,138,122,109,194,143,183,178,173,139, 26,170,190,140,188,120,195,113,104,193,181,185,198,103,182,136,115,191,144, 145,155,153,151, 12.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 27,114,192,180.101,119,128,100 3) Search the Sequence B tree for 196, 137, 102. 190, and print the return value 4) Traverse the tree with each of the three traversal functions above, and generate a sequence of outout for each of the traversals 5) DRAW the tree for seyuertiue A urny with a graphics program, showing the path of traversal and the sequence of processing processing of each node occurs ng for each of the three given traversals That is, indicate on the path where the Turn in 1) Paper source code listings 2) Paper output listings all program functionality Use the insertion sequence provided Perform all three traversals and include the output from each one 3) A diagram for each of the three traversals 4) Your Big O's for each function

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

Students also viewed these Databases questions