Question

In: Computer Science

Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a...

Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a data structure containing 15 data items, a fanout of three, and at most three data items per node. Also give the search algorithm (use a give-up scheme).

Solutions

Expert Solution

B-Tree showing split:

This algorithm splits a node only when it is necessary. We first recursively call insert for appropriate child of node (in case of non-leaf node) or insert it into node (for leaf node). If the node is full, we split it, storing new child entry in newEntry and new parent key in val. These values are then inserted into the parent, which recursively splits itself in case it is also full.

Example:

Consider if we insert number 1 to 15 in a tree it become.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Then we insert 16, the node is full. Hence it is split into two nodes making 8,9,10,11 as parent.

1 2 3 4 5 6 7
8 9 10 11
11 13 14 15 16

B-Tree showing Free-at-empty:

The first type allows B-tree nodes to become arbitrarily small (i.e., contain as few as one entry). When a node becomes empty, the space is freed and the delete is propagated upwards. We call this type of B-tree a free-at-empty B-tree. Free-at-empty B-trees.

Example:

5 is a leaf node and if we delete 5 follow the below B-Tree. 8,9,10,11 are the Parent node.

1 2 3 4 6 7
8 9 10 11
11 13 14 15 16

Algorithms:

Procedure binary_search
   A ← sorted array
   n ← size of array
   x ← value to be searched

   Set lowerBound = 1
   Set upperBound = n 

   while x not found
      if upperBound < lowerBound 
         EXIT: x does not exists.
   
      set midPoint = lowerBound + ( upperBound - lowerBound ) / 2
      
      if A[midPoint] < x
         set lowerBound = midPoint + 1
         
      if A[midPoint] > x
         set upperBound = midPoint - 1 

      if A[midPoint] = x 
         EXIT: x found at location midPoint
   end while
   
end procedure

Related Solutions

Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a...
Consider a B-tree allowing splits and free-on-empty. Please show an example of these operations on a data structure containing 15 data items, a fanout of three, and at most three data items per node. Also give the search algorithm (use a give-up scheme).
1. Starting with an empty tree, show each step in the construction of an AVL tree...
1. Starting with an empty tree, show each step in the construction of an AVL tree using the following input in the order given. For full credit, you must show the tree after each new input is added. 16, 7, 14, 18, 6, 17, 2, 5, 13, 22, 4 (6 pts.) 2. Show how the AVL tree in previous changes with the following operations. For full credit, you must show the tree after each iteration. Remove: 17 Remove: 18 Remove:...
(10 pts) Construct a (2,3) B tree starting from an empty tree, inserting the following values:...
(10 pts) Construct a (2,3) B tree starting from an empty tree, inserting the following values: 30, 50, 32, 10, 25, 35, 40, 50, 70, 80. Show your work. (10 pts) Using the result of the (2,3) B tree in question 8 above, insert the following into the tree: 45, 22, 6, 99
Insert the following values into an initially empty B+ tree with parameter d=3    17, 11, 50,...
Insert the following values into an initially empty B+ tree with parameter d=3    17, 11, 50, 22, 5, 35, 42, 60, 15, 30, 25, 27, 37, 40, 20.
Insert the following values into an initially empty B+ tree with parameter d=2 17, 11, 50,...
Insert the following values into an initially empty B+ tree with parameter d=2 17, 11, 50, 22, 5, 35, 42, 60, 15, 30, 25, 27, 37, 40, 20.
Consider two languages A and B where A is a context free language and B is...
Consider two languages A and B where A is a context free language and B is a regular language. Show that the set difference, A-B, must also be context free. Also show that B-A may not be context free
Closure under Context-Free Languages Show that the following operations are closed under context-free languages: union concatentation...
Closure under Context-Free Languages Show that the following operations are closed under context-free languages: union concatentation Kleene star
In C++ with lots of comments please Complete a binary search tree of 20 numbers Show...
In C++ with lots of comments please Complete a binary search tree of 20 numbers Show in the output the steps while it's performing the search with 20 numbers in a text file called list.txt The numbers will be imported to the program Simple program that should let you have the option to search for numbers, remove numbers, print numbers, and insert numbers in the binary tree If the number isn't there then give an error
Consider the function f(x) = cos (bx2), where b = 0.0628cm−2. PLEASE SHOW ALL WORK AND...
Consider the function f(x) = cos (bx2), where b = 0.0628cm−2. PLEASE SHOW ALL WORK AND EXPLAIN THOROUGHLY! Equation Q12.8: [λx]2=-4π2f(x)d2f/dx2 (a) Argue that this function has crests at x = 0, 10 cm, 14.1cm, 17.3 cm, 20 cm, 22.4 cm, and so on. (b) Draw a graph of this function and show that it is like a wave whose wavelength decreases as x increases. (c) Estimate this function’s local wavelength at x = 20cm by averaging the distances to...
Consider the following splay tree: Show the paths from root to node 12, 10, 9, 5,...
Consider the following splay tree: Show the paths from root to node 12, 10, 9, 5, and 1 after search node 3. (Sample answer: for the above splay tree, the path from root to node 9 can be expressed as 10, 4, 6, 8, 9.) The path from root to node 12:Question Blank.The path from root to node 10:Question Blank.The path from root to node 9:Question Blank.The path from root to node 5:Question Blank.The path from root to node 1:Question...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT