COMP 2013-Sec. 1 Fall 2018 Homework 2 Your second homework will focus on binary tree which includes the following tasks 1. a. Using C/C++, define the tree node structure (e.g. value is an integer, left and right are a node type pointer) and build a binary search tree by giving 10 random numbers; b. Define three functions: inOrder), preOrder), and postOrder) to output the node values of the tree in three different orders. Finally, design a recursive function freeTreeNodes0 to free all memory of the binary tree. c. Based on 1a & 1b, define a function which search if a given number is in the tree. 2. a. While building a binary search tree (BST), if the numbers come in the following sequence: 8, 7, 9, 20, 11, 10, 12, 13, 5, 1; what will be the tree like after constructed? How many comparisons are made totally? b. Given the following binary tree, write the InOrder, PreOrder, PostOder traversals. c. Given a binary tree with 8 nodes, if its InOrder and Postorder traversal results are: 12345678 InOrder PostOrder: 32147685 Reconstruct the tree according to the results; is this tree a binary search tree? The following specifications will be expected for each programming project in this class: 1. An empty project file must be created at the beginning, and then you will create/add new source files and header files. 2. Add comments at the beginning of the program, and add description for each function, loop, etc. Turn in both the hardcopy and softcopy of your source code, including all.cpp and .h file Your name, your ID number and lab number should be written on the upper right-hand corner of the top sheet of the hardcopy. Note that you are required to submit your homework to assignment 1 (b1, b2) in Taskstream. Date Due: Wednesday, November 12th, 2018

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now