Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linux C programming Sixth: Binary Search Tree (20 points) In the sixth part, you have to implement a binary search tree. The tree must satisfy

Linux C programming
image text in transcribed
Sixth: Binary Search Tree (20 points) In the sixth part, you have to implement a binary search tree. The tree must satisfy the binary scarch tree property: the key in each node must be greater than all keys stored in the left sub-tree, and smaller han ll keys in right sub-tree. You have to dynamically allocate space for each node and free the space for the nodes at the end of the progra Input format This program takes a file name as an argument from the command line. The file is either blank or contains successive lines of input. Each line starts with a character, either i, followed by a tab and then an integer. Your program should insert that number in the binary search tree if it is not already there. If it is already present, you will not change the tree. Output format Your program will print all the elements in the tree in ascending order. To print elements in ascending order, you will need to traverse the tree in-order. In an in-order traversal you will visit the left child, then the parent and the right child. You can find more information about in-order traversal at https: //en , wikipedia. org/wiki/Tree-traversal#In-order_ (LNR) The elements have to be printed in a single line separated by tabs. Your program should print error" (and nothing clse) if the input file does not exist. Example Execution: Lets assume we have a file filel.txt with the following contents: 1 3 i 3 i 6 Executing the program in the following fashion should produce the output shown below $./sixth file1.txt 3 4 56

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

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions