It is highly recommended to fully understand Proto Van Emde Boas Tree.
Van Emde Boas Tree supports search, successor, predecessor, insert and delete operations in O(lglgN) time which is faster than any of related data structures like priority queue, binary search tree, etc. Van Emde Boas Tree works with O(1) time-complexity for minimum and maximum query. Here N is the size of the universe over which tree is defined and lg is log base 2.
Note: Van Emde Boas Data Structure’s key set must be defined over a range of 0 to n(n is positive integer of the form 2k) and it works when duplicate keys are not allowed.
- VEB is an abbreviation of Van Emde Boas tree.
- VEB() is an abbreviation for VEB containing u number of keys.
Structure of Van Emde Boas Tree:
Van Emde Boas Tree is a recursively defined structure.
- u: Number of keys present in the VEB Tree.
- Minimum: Contains the minimum key present in the VEB Tree.
- Maximum: Contains the maximum key present in the VEB Tree.
- Summary: Points to new VEB() Tree which contains overview of keys present in clusters array.
- Clusters: An array of size each place in the array points to new VEB() Tree.
See the image below to understand the basics of Van Emde Boas Tree, although it does not represent the actual structure of Van Emde Boas Tree:
Basic Understanding of Van Emde Boas Tree:
- Van Emde Boas Tree is recursively defined structure similar to Proto Van Emde Boas Tree.
- In Van Emde Boas Tree, Minimum and Maximum queries works in O(1) time as Van Emde Boas Tree stores Minimum and Maximum keys present in the tree structure.
- Advantages of adding Maximum and Minimum attributes, which help to decrease time complexity:
- If any of Minimum and Maximum value of VEB Tree is empty(NIL or -1 in code) then there is no element present in the Tree.
- If both Minimum and Maximum is equal then only one value is present in the structure.
- If both are present and distinct then two or more elements are present in the Tree.
- We can insert and delete keys by just setting maximum and minimum values as per conditions in constant time( O(1) ) which helps in decreasing recursive call chain: If only one key is present in the VEB then to delete that key we simply set min and max to the nil value. Similarly, if no keys are present then we can insert by just setting min and max to the key we want to insert. These are O(1) operations.
- In successor and predecessor queries, we can take decisions from minimum and maximum values of VEB, which will make our work easier.
In Proto Van Emde Boas Tree the size of universe size is restricted to be of type 22k but in Van Emde Boas Tree, it allows the universe size to be exact power of two. So we need to modify High(x), low(x), generate_index() helper functions used in Proto Van Emde Boas Tree as below.
High(x): It will return floor( x/ceil() ), which is basically the cluster index in which the key x is present.
High(x) = floor(x/ceil())
Low(x): It will return x mod ceil( ) which is its position in the cluster.
Low(x) = x % ceil( )
generate_index(a, b) : It will return position of key from its position in cluster b and its cluster index a.
generate_index(a, b) = a * ceil() + b
- Proto Van Emde Boas Tree | Set 2 | Construction
- Van Emde Boas Tree | Set 4 | Deletion
- Van Emde Boas Tree - Set 3 | Successor and Predecessor
- Proto Van Emde Boas Tree | Set 5 | Queries: Minimum, Maximum
- Proto Van Emde Boas Tree | Set 6 | Query : Successor and Predecessor
- Proto Van Emde Boas Tree | Set 3 | Insertion and isMember Query
- Van Emde Boas Tree | Set 2 | Insertion, Find, Minimum and Maximum Queries
- Proto Van Emde Boas Trees | Set 4 | Deletion
- proto van Emde Boas Trees | Set 1 (Background and Introduction)
- Ukkonen's Suffix Tree Construction - Part 4
- Ukkonen's Suffix Tree Construction - Part 5
- Ukkonen's Suffix Tree Construction - Part 6
- Ukkonen's Suffix Tree Construction - Part 3
- Ukkonen's Suffix Tree Construction - Part 1
- Ukkonen's Suffix Tree Construction - Part 2
- Basics of Augmented Reality
- Digital Image Processing Basics
- kasai’s Algorithm for Construction of LCP array from Suffix Array
- Pattern Recognition | Basics and Design Principles
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
Construction of Van Emde Boas Tree: Construction of Van Emde Boas Tree is very similar to Proto Van Emde Boas Tree. Difference here is that we are allowing the universe size to be any power of two, so that high(), low(), generate_index() will be different.
To construct, empty VEB: The procedure is the same as Proto VEB just two things minimum and maximum will be added in each VEB. To represent that minimum and maximum is null we will represent it as -1.
Note: In the base case, we just need minimum and maximum values because adding a cluster of size 2 will be redundant after the addition of min and max values.
Below is the implementation:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Aakash_Panchal