Write an algorithm that will check if a tree is a binary search tree. If a tree is not a binary search tree, then it will repair it to make it one. (a) Write pseudo-code for both functions. (b) What is the running time for your algorithm?
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Write an algorithm that will check if a tree is a binary search tree. If a...
I need question 9-10 answered. Thank you Question 1 iShow the resulting binary search tree if we are to insert following elements into the tree in given order, [34, 12, 23, 27,31,9,11,45, 20, 37. i) Show the resulting balanced binary search tree if we are to insert following sorted elements into the tree, [9,12,21, 23, 29, 31, 34, 45, 48, 52, 55] iii What is the pre-order traversal of the balanced binary search tree? v) What is the post-order traversal...
Describe an algorithm that checks if a given binary tree T is a binary search tree. Analyze your algorithm by giving its asymptotic runtime. Show your work.
CAN SOMEONE HELP! The following problem is to design an algorithm which check if a binary tree is a binary search tree. The following code was given. There exists a bug in this code for the variable last printed. (20 points) 6. Find the bug and provide a way to fix this bug: public static Integer last printed-null: public static boolean checkBST (TreeNode n) if (nnull) return true // check/ recurse left if (checkBST (n.left)) return false; /I check current...
pseudo code only no coding in necessary (a) Design a variant "binary" search algorithm which splits the set not into 2 sets of equal sizes (½ and ½), but into 2 sets of sizes one quarter (14) and three quarters (3/4) (b) Give the recurrence relations of your algorithm. (c) How does this algorithm compare with the original binary search in both the best case complexity and the worst case complexity?
1. What is the worst case time complexity of insertion into a binary search tree with n elements? You should use the most accurate asymptotic notation for your answer. 2. A binary search tree is given in the following. Draw the resulting binary search tree (to the right of the given tree) after deleting the node with key value 8. 10 3. You have a sorted array B with n elements, where n is very large. Array C is obtained...
## Codes must be in Python ## In a binary search tree What is worst case time complexity of the binary_search function? Provide an example binary search tree that exhibits worst case running time of binary_search function Write a function that prints elements in binary search tree in order
1.Fix any tree T on 10 vertices. Draw the recursion tree of the algorithm Find-size-node when run on the input T with a being the root of T. Can you use this to give a bound on the running time of T? 2. Consider the following problem. Check-BST • Input: A binary tree T • Output: 1 if T is a binary search tree, and 0 otherwise. Give an efficient algorithm for this problem. 3.Give a recursive algorithm for the...
Design a divide-and-conquer algorithm for computing the number of levels in a binary tree. In particular, the algorithm should return 0 and 1 for the empty and single-node trees respectively. Please provide the pseudocode for your algorithm. What is the running time of your algorithm in the worst case using O() notation? Design a divide-and-conquer algorithm for computing the number of levels in a COMPLETE binary tree. In particular, the algorithm should return 0 and 1 for the empty and...
Recall that in a binary search tree, at every node, all elements to the left of the node have a smaller key, and all elements to the right of a node have a larger key. Write a program called that takes two parameters: a pointer to a binary search tree node, and an int parameter called min which will print all the elements bigger than the specified value, min. Your program should allow the user to enter data (integer) from...
In C++ Given a pointer to the root of a binary search tree (has left, right, and parent pointers as well as a data section ) write a function (or functions) which will return an STL list (you should not define this class, it’s already included) with all of the values from the tree in sorted order. Your code should run in theta(N) time. for the second part,.given a pointer to the first node of a linked list, you are...