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

Databases versus plain text

1) Concurrency. Do you have multiple people accessing the same dataset? Then it’s going to get pretty involved to broker all of the different readers and writers in a scalable fashion if you roll your own system. 2) Formatting and relationships: Is your data something that doesn’t fit neatly into a table structure? Long nucleotide … 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

What’s faster: inserting into a priority queue, or sorting retrospectively?

Testing is the best way to answer this question for your specific computer architecture, compiler, and implementation. Beyond that, there are generalizations. First off, priority queues are not necessarily O(n log n). If you have integer data, there are priority queues which work in O(1) time. Beucher and Meyer’s 1992 publication “The morphological approach to … Read more

Java: what’s the big-O time of declaring an array of size n?

It’s O(n). Consider this simple program: public class ArrayTest { public static void main(String[] args) { int[] var = new int[5]; } } The bytecode generated is: Compiled from “ArrayTest.java” public class ArrayTest extends java.lang.Object{ public ArrayTest(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object.”<init>”:()V 4: return public static void main(java.lang.String[]); Code: 0: iconst_5 1: … Read more

What is the complexity of the log function?

This really depends on the domain of what values you want to compute a logarithm of. For IEEE doubles, many processors can take logarithms in a single assembly instruction; x86 has the FYL2X and FYL2XP1 instructions, for example. Although typically instructions like these will only take the logarithm in some fixed base, they can be … Read more

What is the best way to get the minimum or maximum value from an Array of numbers?

The theoretical answers from everyone else are all neat, but let’s be pragmatic. ActionScript provides the tools you need so that you don’t even have to write a loop in this case! First, note that Math.min() and Math.max() can take any number of arguments. Also, it’s important to understand the apply() method available to Function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)