ArticleslgStudy

computer science

Y-fast trie

Y-fast trie is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Y-fast trie rather than just read about it. In short: In computer science, a y-fast trie is a data structure for storing integers from a bounded domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n) space, where n is the number of stored values and M is the maximum value in the domain.

Y-fast trie — main illustration
Y-fast trie — illustration

Key takeaways

  • Y-fast trie belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Y-fast trie to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Y-fast trie from memory before moving on to harder problems.

Reference excerpt

In computer science, a y-fast trie is a data structure for storing integers from a bounded domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n) space, where n is the number of stored values and M is the maximum value in the domain. The structure was proposed by Dan Willard in 1983 to decrease the O(n log M) space used by an x-fast trie.

Structure

A y-fast trie consists of two data structures: the top half is an x-fast trie and the lower half consists of a number of balanced binary trees. The keys are divided into groups of O(log M) consecutive elements and for each group a balanced binary search tree is created. To facilitate efficient insertion and deletion, each group contains at least (log M)/4 and at most 2 log M elements. For each balanced binary search tree a representative r is chosen. These representatives are stored in the x-fast trie. A representative r need not be an element of the tree associated with it, but it does need be an integer smaller than the successor of r and the minimum element of the tree associated with that successor and greater than the predecessor of r and the maximum element of the tree associated with that predecessor. Initially, the representative of a tree will be an integer between the minimum and maximum element in its tree. Since the x-fast trie stores O(n / log M) representatives and each representative occurs in O(log M) hash tables, this part of the y-fast trie uses O(n) space. The balanced binary search trees store n elements in total which uses O(n) space. Hence, in total a y-fast trie uses O(n) space.

Operations Like van Emde Boas trees and x-fast tries, y-fast tries support the operations of an ordered associative array. This includes the usual associative array operations, along with two more order operations, Successor and Predecessor:

Find(k): find the value associated with the given key Successor(k): find the key/value pair with the smallest key larger than or equal to the given key Predecessor(k): find the key/value pair with the largest key less than or equal to the given key Insert(k, v): insert the given key/value pair Delete(k): remove the key/value pair with the given key

Find A key k can be stored in either the tree of the smallest representative r greater than k or in the tree of the predecessor of r since the representative of a binary search tree need not be an element stored in its tree. Hence, one first finds the smallest representative r greater than k in the x-fast trie. Using this representative, one retrieves the predecessor of r. These two representatives point to two balanced binary search trees, both of which one searches for k. Finding the smallest representative r greater than k in the x-fast trie takes O(log log M). Using r, finding its predecessor takes constant time. Searching the two balanced binary search trees containing O(log M) elements each takes O(log log M) time. Hence, a key k can be found, and its value retrieved, in O(log log M) time.

Successor and predecessor Similarly to the key k itself, its successor can be stored in either the tree of the smallest representative r greater than k or in the tree of the predecessor of r. Hence, to find the successor of a key k, one first searches the x-fast trie for the smallest representative greater than k. Next, one uses this representative to retrieve its predecessor in the x-fast trie. These two representatives point to two balanced binary search trees, which one searches for the successor of k. Finding the smallest representative r greater than k in the x-fast trie takes O(log log M) time and using r to find its predecessor takes constant time. Searching the two balanced binary search trees containing O(log M) elements each takes O(log log M) time. Hence, the successor of a key k can be found, and its value retrieved, in O(log log M) time. Searching for the predecessor of a key k is highly similar to finding its successor. One searches the x-fast trie for the largest representative r smaller than k and one uses r to retrieve its predecessor in the x-fast trie. Finally, one searches the two balanced binary search trees of these two representatives for the predecessor of k. This takes O(log log M) time.

Insert To insert a new key/value pair (k, v), one first needs to determine in which balanced binary search tree one needs to insert k. To this end, one finds the tree T containing the successor of k. Next, one inserts k into T. To ensure that all balanced binary search trees contain O(log M) elements, one splits T into two balanced binary trees and removes its representative from the x-fast trie if it contains more than 2 log M elements. Each of the two new balanced binary search trees contains at most log M + 1 elements. One picks a representative for each tree and insert these into the x-fast trie. Finding the successor of k takes O(log log M) time. Inserting k into a balanced binary search tree that contains O(log M) elements also takes O(log log M) time. Splitting a binary search tree that contains O(log M) elements can be done in O(log log M) time. Finally, inserting and deleting the three representatives takes O(log M) time. However, since one splits the tree at most once every O(log M) insertions and deletions, this takes constant amortized time. Therefore, inserting a new key/value pair takes O(log log M) amortized time.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Y-fast trie

Start with the simplest possible case. Write down what Y-fast trie claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Y-fast trie before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Y-fast trie ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Y-fast trie

In research
Y-fast trie appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Y-fast trie in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Y-fast trie is common in secondary-school and first-year university syllabi. It links to neighbouring topics Trees (data structures), so understanding it makes those chapters shorter.
In everyday life
Look for Y-fast trie outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Y-fast trie” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Y-fast trie in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Y-fast trie means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Y-fast trie out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Y-fast trie in simple terms?

In computer science, a y-fast trie is a data structure for storing integers from a bounded domain. It supports exact and predecessor or successor queries in time O(log log M), using O(n) space, where n is the number of stored values and M is the maximum value in the domain.

Why does Y-fast trie matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Y-fast trie?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Y-fast trie.

Tags

  • Trees (data structures)

Keep exploring