Question

In: Computer Science

What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree?...

What happens if you call VEB-TREE-INSERT with an element that is already in the vEB tree? What happens if you call VEB-TREE-DELETE with an element that is not in the vEB tree? Explain why the procedures exhibit the behavior that they do. Show how to modify vEB trees and their operations so that we can check in constant time whether an element is present.

Solutions

Expert Solution

Let us consider that x is an element which is already in the vEB tree. If the insert operation is called on the vEB tree then it will cause an overflow. In order to resolve the issue we need to modify the code adding an else case.

Now let us assume that we want to delete an element not present in the vEB tree. If there is only one element in the tree then it will be deleted. But the else-if condition will not be executed as the tree size is not equal to 2. So, the max element will be deleted. In order to resolve this issue we need to use an auxiliary array A[] and update it with the condition:

A[x] = 0 if x is not in the tree.

Now for insertion we will check if A[x] = 0.

If it is true then we will set A[x] = 1 and perform the insert operation. If A[x] <> 0 then return.

Now for deletion we will check if A[x] = 1.

If it is true then we will set A[x] = 0 and perform the delete operation. If A[x] <> 1 then return.

Hope this helps.


Related Solutions

Beginning with an empty binary search tree, what binary search tree is formed when you insert...
Beginning with an empty binary search tree, what binary search tree is formed when you insert the following values in the given order – consider there alphabetical position for comparison. a. W, T, N, J, E, B, A b. W, T, N, A, B, E, J c. A, B, W, J, N, T, E d. B, T, E, A, N, W, J Alphabetical positions: A-1, B-2, E-5, J-10, N-14,T-20,W-23
Through careful genetic engineering, you have produced what you call the Super Tree – a tree...
Through careful genetic engineering, you have produced what you call the Super Tree – a tree that can absorb extraordinary amounts of carbon dioxide (CO2), thereby helping to slow the process of global warming. Past research has shown that a regular tree absorbs 48 pounds of (CO2) per year but you find that in a random sample of 36 of your own trees, the average amount of CO2 absorbed is 54.3 pounds with a standard deviation of 18. Using an...
1.What happens if you attempt to call a method using a referencevariable that is set...
1.What happens if you attempt to call a method using a reference variable that is set to null?2.Consider the following class declaration:public class Square{   private double side;   public Square (double s){    side = s;}public double getArea(){   return side * side;}public double getSide(){   return side;}}a. Write a toString method for this class. The method should return a string containing the side and area of the square.b. Write a equals method for this class. The method should accept a Square object as...
In Java please What happens if you call factorial( with a negative value of n? With...
In Java please What happens if you call factorial( with a negative value of n? With a large value of say 35? Write a recursive function that takes an integer n as its argument and returns ln(n!)
Insert VTQWDNGOCMKPI into a 2-3 tree (A B-Tree with Min set to 1) in the given...
Insert VTQWDNGOCMKPI into a 2-3 tree (A B-Tree with Min set to 1) in the given order and show the result at each step. Then, delete WKN in the given order and show result at each step
Write a loop that subtracts 1 from each element in lowerScores. If the element was already...
Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the element. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}. please bold the solution import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int SCORES_SIZE = 4; int[] lowerScores = new int[SCORES_SIZE]; int i; for (i = 0; i < lowerScores.length; ++i) {...
AVL tree; Insert and Range Minimum operation in Java code.
AVL tree; Insert and Range Minimum operation in Java code.
Write a non recursive method to insert into an AVL tree in Java
Write a non recursive method to insert into an AVL tree in Java
this is my linkedlist and to insert a new element in it , however i want...
this is my linkedlist and to insert a new element in it , however i want it to be user entered linkedlist #include <bits/stdc++.h> using namespace std;    // A linked list Node struct Node {     int data;     struct Node* next; };    // Size of linked list int size = 0;    // function to create and return a Node Node* getNode(int data) {     // allocating space     Node* newNode = new Node();        // inserting the required data     newNode->data...
goal of this function will be to add an element to an already existing array in...
goal of this function will be to add an element to an already existing array in C/C++. bool add(structure dir[], int& size, const char nm[], const char ph[]){ //code here } add = function name structure = structure with two fields { char name[20]; char phone[13]; } int& size = # of entries in dir nm = name that's going to be added ph = phone that's going to be added. return true if entry was successfully added, false if...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT