Question: BackgroundThe binary tree is one of the most common and important data structures in Computer Science. It isdefined recursively in terms of itself and therefore,
BackgroundThe binary tree is one of the most common and important data structures in Computer Science. It isdefined recursively in terms of itself and therefore, many of the algorithms that manipulate binary treesare recursive as well. For this assignment, you will implement several shorter recursive algorithms or theirnonrecursive versions to answer problems that are based on the binary tree.Problem Review the basic template for the binary tree given on Blackboard under Assignments Assignment Binary Trees This will serve as the framework for the following problems.Problem marksThe inorder traversal of a binary tree can be implemented nonrecursively without the help of a stack. Itis called the Morris Traversal and is based on the idea of a threaded binary tree. Take some time toresearch the Morris Traversal and then complete the following three tasks.a marks Demonstrate on paper how the Morris Traversal works on a complete binary tree witha depth of b marks State one key advantage of the Morris Traversal over the standard inorder traversalseen in class.c Implement the Morris Traversal marks and verify its results with the standard inordertraversal marks Make sure that the original binary tree is reinstated after the Morris Traversalis performed.
Problem marksWe know from class that a unique binary tree can be built from an inorder traversal paired with either apre or postorder traversal. A binary search tree, on the other hand, requires only a pre or postordertraversal since the inorder traversal is implicit. Keeping this in mind, complete the following four tasks.a marks Show on paper that if the preorder traversal, stored in an array, is correctly formulated,the unique binary search tree can be built by inserting the items of the preorder traversal oneafter the other into an initially empty binary search tree.b marks Give an example of a preorder traversal that is incorrectly formulated.c marks Using the bigOh notation, state with justification the time complexity to build thebinary search tree in part a from a preorder traversal with n items.d Implement marks and test marks an alternate way to build the binary search tree given apreorder traversal that only requires On time. If the binary search tree cannot be built, outputa message.
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
