Question

PROBLEM 6: Suppose we insert keys below into an initially empty Vanilla binary search tree in...

PROBLEM 6:

Suppose we insert keys below into an initially empty Vanilla binary search tree in the given order:

6, 9, 2, 1, 5, 7, 10, 8, 3, 4

(a) Draw the resulting binary search tree.

(b) List the keys according to:

A pre-order traversal

An in-order traversal

A post-order traversal

(c) Now we perform some deletions using the “deletion by copying” strategy in which promoted keys are always drawn from a node’s right subtree (so that there is only one correct answer).

(i) Simulate the deletion of 2 and draw the resulting tree. State any relevant assumptions.


(ii) Now (on the resulting tree) simulate the deletion of 6 and draw the resulting tree. Again, stating any relevant assumptions.



0 0
Add a comment Improve this question Transcribed image text
Answer #1

i) Binary Search Tree

ii) A pre-order traversal: ROOT - LEFT - RIGHT
6 2 1 5 3 4 9 7 8 10

iii) An in-order traversal: LEFT - ROOT - RIGHT
1 2 3 4 5 6 7 8 9 10

iv) A post-order traversal: LEFT - RIGHT - ROOT
1 4 3 5 2 8 7 10 9 6

--------------------------------------

We are allowed to answer 4 sub parts only. Please post accordingly.

Add a comment
Know the answer?
Add Answer to:
PROBLEM 6: Suppose we insert keys below into an initially empty Vanilla binary search tree in...
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
  • PROBLEM 6: Suppose we insert keys below into an initially empty binary search tree in the...

    PROBLEM 6: Suppose we insert keys below into an initially empty binary search tree in the given order 6, 9, 2, 1, 5, 7, 10, 8, 3,4 (a) Draw the resulting binary search tree. (b) List the keys according to: A pre-order traversal An in-order traversal A post-order traversal (c) Now we perform some deletions using the "deletion by copying" strategy in which promoted keys are always drawn from a node's right subtree (so that there is only one correct...

  • Starting with an empty binary search tree, insert each of the following keys and rotate it...

    Starting with an empty binary search tree, insert each of the following keys and rotate it to the root in the specified order: 6   1   18   7   15 Starting with an empty red-black binary search tree, insert the following keys in order:: 12   5   23   9   19   2   21   18   7 Show the tree immediately after you insert each key, and after each time you deal with one of the book's cases 1, 2, or 3 (that is, if dealing with one case leads to another, show the additional case as a...

  • A Binary Search Tree is a binary tree where nodes are ordered in the following way:...

    A Binary Search Tree is a binary tree where nodes are ordered in the following way: each node contains one key (also known as data) the keys in the left subtree are less than the key in its parent node the keys in the right subtree are greater than the key in its parent node duplicate keys are not allowed Create a Binary Search Tree inserting the following list of numbers in order from left to right. 10,          6,           4,            8,            18,          15,          21 Please type...

  • Suppose you started with an empty binary search tree. We've seen previously that inserting the keys...

    Suppose you started with an empty binary search tree. We've seen previously that inserting the keys 1, 2, 3, 4, 5, 6, 7 (in that order) would lead to a binary search tree whose shape we called degenerate. Propose a second ordering of the same keys that would also lead to a degenerate-shaped binary search tree. If possible, propose a third ordering of the same keys that would also lead to a degenerate-shaped binary search tree. If there are no...

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

  • Tree & Hash Table & Heap Use the following integer keys 73, 58, 91, 42, 60, 130, 64, 87 to perform the followings: a) Binary Search Tree - Draw a binary search tree - Retrieve the integers ke...

    Tree & Hash Table & Heap Use the following integer keys 73, 58, 91, 42, 60, 130, 64, 87 to perform the followings: a) Binary Search Tree - Draw a binary search tree - Retrieve the integers keys in post-order - Retrieve the integers keys in pre-order - Draw a binary search tree after node 58 is deleted b) Create a Hash Table using the methods described below. Show the final array after all integer keys are inserted. Assumes that...

  • (a) On an initially empty red-black tree, perform the following operations in this order: insert(1), insert(3),...

    (a) On an initially empty red-black tree, perform the following operations in this order: insert(1), insert(3), insert(5), insert(6), insert(7), delete(1) Show all the intermediate steps of your work (b) We can get another sorting algorithm by first inserting all the keys into a red-black tree, and then performing an in-order traversal of the tree. What's the time complexity of this algorithm? (As always, use O or Θ notation.)

  • Binary Search Trees (a) 5 pointsl Insert 5, 12, 7, 1, 6, 3, 13, 2, 10,...

    Binary Search Trees (a) 5 pointsl Insert 5, 12, 7, 1, 6, 3, 13, 2, 10, 11 into an empty binary search tree in the given order. Show the resulting BST after every insertion. (b) 5 points) What are the preorder, inorder, and postorder traversals of the BST you have after (a)? (c) 5 points Delete 2, 7, 5, 6, 11 from the BST you have after (a) in the given order Show the resulting BST after every deletion.

  • Use the Binary Search Tree (BST) insertion algorithm to insert 0078 into the BST below. List...

    Use the Binary Search Tree (BST) insertion algorithm to insert 0078 into the BST below. List the nodes of the resulting tree in pre-order traversal order separated by one blank character. For example, the tree below can be described in the above format as: 75 53 24 57 84 77 76 82 92 0075 0053 0084 0024 0057 0077 OON 0076 0082

  • 1. Suppose we start with an empty B-tree and keys arrive in the following order. –...

    1. Suppose we start with an empty B-tree and keys arrive in the following order. – 1, 12, 8, 2, 25, 6, 14, 28, 17, 7, 52, 16, 48, 68, 3, 26, 29, 53, 55, 45 – Build a B-tree of order 5 – Hints • 17: insert/split/promote • 68: insert/split/promote • 3: insert/split/promote • 45:insert/split/promote 2. Suppose we insert the keys {1,2,3, …, n} into an empty B-tree with degree 5, how many nodes does the final B-tree have?

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
ADVERTISEMENT