Question: Write a C program to output 3 files named file .preorder, f ile.inorder and file .postorder. Note that file is the name of the input
Write a C program to output 3 files named file.preorder, file.inorder and file.postorder. Note that file is the name of the input file if given, and it is 'out' if the input is from the keyboard. The program will create 3 binary search trees (inorder, preorder, and postorder). With an optional 'file' argument, assume you do not know the size of the input file and assume the input data is all strings separated with standard WS separators (space, tab, new line). If the input file is not readable for whatever reason, or command line arguments are not correct, the program will abort with an appropriate message The program will read the data left to right and put them into a tree, which is a binary search tree (BST) with respect to the first character of the string (that is strings of the same first character are considered the same data). Letter cases are the same. The Tree is never balanced nor restructured other than growing new nodes and A node should contain all data that falls into the node except that literally the same strings will show up only once (set).
Have the following functions minimum in addition to the main function (the types and arguments are just suggested, the names are required) node_t *buildTree(FILE *); void traverseInorder(node_t*, const char[]); // parameters: tree root, and output basefilename void traversePreorder(node_t*, const char[]); void traversePostorder(node_t*, const char[]);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
