Question: please provide all the code correctly. Please do mention what is the code for. All the tests files, makefile and mention each and every other
please provide all the code correctly. Please do mention what is the code for. All the tests files, makefile and mention each and every other file do not miss anything. do mention if the code was written in visual studio or something else and in what language. it must be in c or java
In this program you will be writing a program to build a tree and print it using different traversals. The program will be invoked as
Pfile
where file is an optional argument.
If the file argument is not given, the program reads data from the keyboard as a device
If the argument is given, the program reads data file file.
Programs improperly implementing file name or executable will not be graded.
is for style. interactive input. performance.
Example invocations:
P read from the keyboard until simulated EOF
P somefile same as above except redirecting from somefile instead of keyboard, this tests keyboard input
P somefile read from somefile
Assume you do not know the size of the input file
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 must abort with an appropriate message
The program will read the data left to right and put them into a tree. The tree for this project is a modified binary search tree. In particular, the nodes for your tree will have children. The left child, right child and middle child. When storing new strings on the tree, you will put them in the tree as you would on a normal binary search tree using left and right children. However, if there is an identical match, you will hang a new child off of the middle child. Note that as you could have more than a single duplicate for example, a string repeated times if this happens you would have a linked list of children using the middle child pointers.
The binary search tree should be with respect to the first letter of the string and only the first letter, so searching the tree for a string would be off the first letter. Strings that differ but have the same first letter would be counted as identical and be stored in the middle pointers.
Tree is never balanced nor restructured other than growing new nodes.
The program will subsequently output files corresponding to traversals, named file.preorder, file.inorder and file.postorder. Note that file is the base name of the input file if given, and it is output if not given.
Traversals
preorder
inorder
postoder
Printing in traversal
Indent the node by x depth of the node, then print the node's first letter, a : then the word in that node. So for example, if printing the string "dog" at depth you would space over spaces from the left and then print d:dog
Example will be elaborated in class
File xxx contains
george adam ala ada john haus geode
invocation: P xxx
Output files: xxxinorder xxxpreorder xxxpostorder
Invocation: P xxx or P followed by typing the data followed by EOF
Output files: ouput.inorder output.preorder output.postorder
Standards related requirements:
Have the following functionsmethods minimum the types and arguments are up to you, the names are required as given Note that these can be in separate files or all the same source file, but it must be different from whatever source file has your main function or equivalent. I would suggest putting them in a tree.cpp or something similar, along with a tree.h header file. They could also all be in the same class or separate classes.
buildTree
printInorder
printPreorder
printPostorder
Define the node type in node.h which could be included in your tree.cpp
Keep the main function in a separate file regardless of language This main function or class would call the tree functions from the other source file or class.
Traversals taken from the textbook:
Preorder:
process root
process children left, middle, right
Inorder:
process left child
process root taking you down the middle pointer
proccess right child
Postorder:
process children left, middle, right
process root
More suggestions
Using topdown decomposition you have tasks in main:
Process command arguments, set up file to work regardless of source, check if file readable, set the basename for the output file, etc.
Build the tree
Traverse the tree three different ways generating outputs
The main function should handle the functionalities. # should be handled inside of main, functions for # and # should be in another separate source as indicated. Any node types should be defined in a separate header file.
For development purposes, do either or first. should follow first with one traversal only.
Processing either keyboard or file input can be done one of these two ways:
If keyboard input, read the input into temporary file, after which the rest of the program always processes file input
If keyboard input, se
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
