How is it possible to build a suffix tree in linear time?

Your intuition behind why the algorithm should be Θ(n2) is a good one, but most suffix trees are designed in a way that eliminates the need for this time complexity. Intuitively, it would seem that you need Θ(n2) different nodes to hold all of the different suffixes, because you’d need n + (n – 1) … Read more

What is the time complexity of indexing, inserting and removing from common data structures?

Information on this topic is now available on Wikipedia at: Search data structure +———————-+———-+————+———-+————–+ | | Insert | Delete | Search | Space Usage | +———————-+———-+————+———-+————–+ | Unsorted array | O(1) | O(1) | O(n) | O(n) | | Value-indexed array | O(1) | O(1) | O(1) | O(n) | | Sorted array | O(n) … Read more

Difference between O(logn) and O(nlogn)

Think of it as O(n*log(n)), i.e. “doing log(n) work n times”. For example, searching for an element in a sorted list of length n is O(log(n)). Searching for the element in n different sorted lists, each of length n is O(n*log(n)). Remember that O(n) is defined relative to some real quantity n. This might be … Read more