Question: This is a practice on design, implement and analyzing problems using binary search trees. The main function of your test program (testBST.cpp) should be compatible
This is a practice on design, implement and analyzing problems using binary search trees. The main function of your test program (testBST.cpp) should be compatible with the following main function. By compatible it means the number of parameters of each function should match. The type of parameters is determined by your design and implementation. This makes some constraints in your design, which is likely to occur in the real world.
int main() { // declaration of your variables ... n1 = getInput(); // either generates a random non-negative // integer or reads it from input list1 = genData(n1); //generates a list of n1 random numbers [-n1, n1] cout << "The List1: "; printList(list1); //prints elements of the given list n2 = getInput(); list2 = genData(n2); //generates a list of n2 random numbers [-n2, n2] printList(list2); bst1 = makeBST(list1); cout << "In-order traversal of bst1 is: "; printBT(bst1); remove(list1[n1/2], bst1); // removes list1[n1/2] from corresponding tree (bst1)
cout << "In-order traversal of bst1 after deleting " < Only binary operations +, -, * and / with priority and parentheses are allowed in an infix expression. Also, to keep it simple, use 1-digit numbers in your expressions. Implement your expression trees as explained in the lecture. A. Write a function named infixExprTree() that given an infix expression, generates its corresponding expression tree. B. Write a function named InfixPostfixExpr() that receives an infix expression and transforms it into a postfix expression. Hint- Make the expression tree of the infix expression and then apply the post-order traversal on the tree.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
