Question

Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this a max heap, draw the tree and check if this is a max heap. b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

4.

BINARY SEARCH TREE

phpIMlpRZ.png


Pre-Order: Root - Left - Right
45 12 5 34 18 40 50

Post-Order: Left - Right - Root
5 18 40 34 12 50 45

Removed 45: Find it and replace it with the highest value in the left sub tree

phpZpRMCB.png

ADDED 42: Find the place of the 42 using BST rules and insert.

004


--------------------------------------
Hit the thumbs up if you are fine with the answer. Happy Learning!

Add a comment
Know the answer?
Add Answer to:
Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. In Lab 4, you developed a program to build a Max Heap, and then Heap...

    1. In Lab 4, you developed a program to build a Max Heap, and then Heap Sort. Update the program by adding two additional functions: (a) AddData(A, N, V) where V is the new value added. (b) Delete a data Delete by giving the index of the data position Make sure to display the array after calling each of the function. 2. Write a program to implement Binary Search Algorithm, which will return the index of the data searched (V)....

  • Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6...

    Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6 7 8 9 A C E G B P D X F H Give the pre-order traversal. Give the post-order traversal. Give the in-order traversal. Determine the height of the tree. Using these values: 8 6 4 3 5 9 2 1 6 Build a binary search tree. Build an AVL Tree. Build a 2-3 Tree. Build a min-heap. Build a max-heap. Apply a...

  • I need question 9-10 answered. Thank you Question 1 iShow the resulting binary search tree if...

    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...

  • 1. Consider the following unordered list: 20, 35, 25, 10, 40, 50, 45. Perform heap sort...

    1. Consider the following unordered list: 20, 35, 25, 10, 40, 50, 45. Perform heap sort to sort this list in nondecreasing (ascending) order. a. Perform the bottom-up method to arrange these values into a max heap. Show the heapify operations on each relevant subtree. (10 points) b. Show the tree representation and the array representation of these numbers after every dequeue operation. Remember that dequeue does not delete a number. Dequeue will instead remove that number from the heap...

  • 1. Short Questions Given the following data: 30 20 s0 40 10 60 28 Which method...

    1. Short Questions Given the following data: 30 20 s0 40 10 60 28 Which method will perform better: Binary Search or Binary Search Tree? a) Give explanation as well S pts) b) Draw a binary search tree using the following data (5 pts) (No need to show the steps) 24 60 17 40 S0 20 22 21 c) Give the In-onder, pre-order and post-order search ordering from the tree constructed in part (b) (5 pts) d) Give definition of...

  • Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should...

    Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should have short description of the implemented class and for files with main method the problem it is solving. Make sure your files have appropriate names. Programs should write output to the Console. b) BST: Implement Binary Search Tree ADT with insert(int key), delete(int key), Node find(int key), and in-order traverse() where it prints the value of the key. Your operations should use recursion. The...

  • 17) Which of the following is a valid binary search tree? 23 12 40 19 30...

    17) Which of the following is a valid binary search tree? 23 12 40 19 30 61 13 21 41 50 23 43 10 18 34 51 15 21 40 50 23 43 10 18 51 15 27 40 50 What is the worst-case runtime of searching for a value in a binary search tree? (a) constant O(1) (b) logarithmic O(logn) (c) linear O(n) 18) Pag

  • Given the following set of data: 17, 12, 1, 4, 6, 9, 7, 2 Provide a...

    Given the following set of data: 17, 12, 1, 4, 6, 9, 7, 2 Provide a heap that stores the data as a tree. Show how the heap sort algorithm works by providing the heap content/structure with each new number considered. Display the contents with a heap diagram tree.

  • (b) Given the following tree (graph) as shown in Figure 2: Diberi pepohon (graf) seperti yang...

    (b) Given the following tree (graph) as shown in Figure 2: Diberi pepohon (graf) seperti yang ditunjukkan dalam Rajah 2: Figure 2 Rajah 2 (i) Find the pre-order traversal of the tree. Cari penyusuran pepohon "pre-order". (8/100) (ii) Find the post-order traversal of the tree. Cari penyusuran pepohon "port-order". (8/100) (iii Using the ordering c, d, e, f, g, h, i, j, k, I, m, a, b, c and the depth-first search algorithm, find a spanning tree for the graph...

  • Consider the following values: 20, 10, 45, 23, 46, 75, 15. What value will be at...

    Consider the following values: 20, 10, 45, 23, 46, 75, 15. What value will be at the root of the tree created by inserting these values in the order given to build a min heap? a. 10 b. 23 c. 20 d. 75 Consider the following tree with root value 20, 20 has a left child of 10 and a right child value 30; 10 has a left child of 5 and a right child of 15; 30 has a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT