CPSC 2430-02 Lab #3

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (9 votes)

This lab will assist you in completing p3 and exercises your understanding of Binary Search Tree
traversals, insertion and deletion.
Follow these steps:
1) Call your source code file “lab3.cpp”
2) Create a node to use which contains a data/key field of type int, and two pointers to
children (left and right)
3) Write a function to construct a BST, with smaller values to the left and larger ones to the
right.
4) Write a function to traverse the tree INORDER, recursively. This function should print
the key/data value at each node to the screen.
5) Write a function to traverse the tree PREORDER, recursively. This function should print
the key/data value at each node to the screen.
6) Write a function to traverse the tree POSTORDER, recursively. This function should print
the key/data value at each node to the screen.
7) Write a function to delete ALL the nodes of the tree and return the root pointer to
“null”.
8) In main, test all functions by creating a tree containing between 5 and 10 nodes, then
call each of the traversal/print functions. Call the deletion function before ending the
program.
Submit your program by typing the following command at the prompt in the same directory
where the file is stored:
/home/fac/sreeder/submit/cpsc2430/lab3_runme