Question

Using Java Qaustion 1) A) Draw a B-tree of order 5, which is received sequentially introduction...

Using Java
Qaustion 1)

A) Draw a B-tree of order 5, which is received sequentially
introduction of the following elements: 200,300,8,17,100,2,20,30,89,26,14,15 ,10
B) Show the result of deleting elements 15, 14, 10, 8 from the constructed
trees.

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

Let us start of by defining what is a tree, then we will come down to B-Trees.
Tree is a data structure that is used to simulate a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.

This Diagram clearly illustrates how a tree looks like. The node at the top (the one with value 20) is the root. the nodes on the left are part of the left subtree and those on the right are part of the right subtree. The nodes without any children are leaf nodes.

Now coming on to what is a B-tree:
B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree is a generalization of a binary search tree in that a node can have more than two children.

Now the first question that must come to your mind is, what does the order of a B-tree mean.
I would like to introduce you with two important terms

  1. Order
  2. Degree

Degree represents the minimum number of children a node in the B Tree can have (except for the root. And the Order represents the maximum number of children.

How do we insert and delete in a B-tree?

The answer is pretty straight forward, find a leaf node where you can insert the element in a sorted manner. If the node has a size greater than or equal to the order the split it at the middle. There is a similar procedure with the delete operation. Always remember that you need to insert only in a leaf node.

Deletion should also be done so that only the structure of the leaf is changed. The examples will make it clear.

With all this information in hand, let us now proceed with the question, in a step by step manner.

Insert 200, 300, 8, 17: Since the first four nodes enter without any need of modification we simply insert it in sorted order.

Insert 100: the root node has 5 elements now so we need to split it across the middle element.

Insert 2: 2 gets inserted in the sorted position

Insert 20:

Insert 30: since after insertion of 30 the leftmost node has 5 elements so we need to split it at the middle position. and move 17 at the top node.

Insert 89: Simple sorted inserion

Insert 26: Simple sorted insertion

Insert 14: Simple sorted insertion

Insert 15: Simple sorted insertion

Insert 10: Again the leftmost node has 5 elements after insertion of 10. So we split it at the middle position and then 10 moves on the upward node.

Delete 15: 15 gets removed so to maintain the structure 20 moves to the top node and 17 moves in place of 15.

Delete 14: Again similar to the last operation, 14 gets deleted 17 moves left, 20 moves down and 26 moves up.

Delete 10: Since 10 gets deleted so we merge the two leftmost intervals.

Delete 8: Simple deletion in place.

Just keep in mind that you need to keep all leafs at the same level while you proceed with the deletion and insertion operations.

Happy to help. In case of any doubts feel free to post comments and get your doubts clarified.

Add a comment
Know the answer?
Add Answer to:
Using Java Qaustion 1) A) Draw a B-tree of order 5, which is received sequentially introduction...
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
  • 3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw...

    3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw the trees that result from the following operations: (a) Inserting 142, 400, 205, 127, 100, 320, 160, 141, and 110 into an initially-empty tree (in that order). (b) Deleting 142 from the tree you drew for part (a). 4. (8 points) Draw the unique binary tree that has a preorder traversal of 4, 1, 6, 3, 7, 5, 9, 2, 8 and an inorder...

  • B trees java NAME CSC 236 HW #3 (B-trees & heaps) 1. Given a B-tree of...

    B trees java NAME CSC 236 HW #3 (B-trees & heaps) 1. Given a B-tree of order 5, add the elements 1, 12, 8, 2, 25, 5, 14, 28, 17, 7, 52, 16, 48, 68, 3, 26, 29, 53, 55, 45 into a B-tree in this order. Draw the diagrams to show the B-tree after each element is added. 2. Add the elements 27, 35, 23, 22, 4, 45, 21, 5, 42, 19 into a heap in this order Draw...

  • 1. [10 pts.] AVL Trees: Example Operations (a) [5 pts.] Draw the AVL tree that results...

    1. [10 pts.] AVL Trees: Example Operations (a) [5 pts.] Draw the AVL tree that results from inserting key 45 into the following AVL tree. (b) [5 pts.] Draw the AVL tree that results from deleting key 70 from the following AVL tree. NOTE: When deleting a key from an AVL tree, please follow the textbook approach of finding the node with the key using the function for standard binary search trees. If the key is in the tree and...

  • • P1 (10 pts) Show the result of inserting 2, 9, 5, 8, 6, 4, 3,...

    • P1 (10 pts) Show the result of inserting 2, 9, 5, 8, 6, 4, 3, 1 into an initially empty AVL tree (draw a resulting tree after inserting each number; you need to draw 8 AVL trees). • P2 (5 pts) What is the minimum number of nodes in an AVL tree of height 8? • P3 (5 pts) Show the result of deleting the element with key 9' from the following splay tree. • P4 (5 pts) Show...

  • Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order,...

    Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binary tree into a 2-dimensional array. You may write many recursive methods for this project. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree. Please stop your program if the user enters 0 as the tree selection. Your program must run the following Test Case 1 plus two more test cases to...

  • Draw an AVL tree (initially empty) at each step when inserting the following numbers in order:...

    Draw an AVL tree (initially empty) at each step when inserting the following numbers in order: 1; 2; 5; 4; 6; 3; 10; 9; 7; 8 Now, draw the above AVL tree at each step when deleting the following numbers in order (assuming that the substitution on deleting a node is done by replacing it with the minimum in the right subtree): 4; 5; 6

  • Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binar...

    Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binary tree into a 2-dimensional array. You may write many recursive methods for this project. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree. Please stop your program if the user enters 0 as the tree selection. Your program must run the following Test Case 1 plus two more test cases to...

  • 1. Consider the B+ tree index. Every node can contain m entries, where 2s ms4 The root node is an...

    1. Consider the B+ tree index. Every node can contain m entries, where 2s ms4 The root node is an exception: it allows 1 m s4. B+ tree 18 15 17 A. Show the B+ tree that would result from inserting data entries with key 31, 32, and 41 into the tree. B. Given the output of (A), show the B+ tree that would result from deleting the data entry with key 3 C. Given the output of (B), show...

  • Problems #3 thru #5 refer to the following b-tree. Note that problems #4 and #5 are...

    Problems #3 thru #5 refer to the following b-tree. Note that problems #4 and #5 are continuations of their previous problems. Original for 60 #3-5: 20,40 70 90 62 65 75 80 92 95 97 5 10 15 25 30 45 50 55 #3 Show the b-tree resulting by deleting 90. #4 Continuing from #3, show the b-tree resulting by deleting 25. Only attempt to borrow from an adjacent sibling. If possible, use the sibling that is immediately to its...

  • Build a splay tree inserting keys: 2, 13, 17, 4, 7, 19, 5, 8, 22, 6,...

    Build a splay tree inserting keys: 2, 13, 17, 4, 7, 19, 5, 8, 22, 6, 10. Show each step! a. Show the result of accessing keys 5, 8, 7 in order in the splay tree. Show the tree after each access. b. Show the result of deleting keys 10, 8, 7 in the splay tree. Start with the original tree and show the tree after each deletion.

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