Need memory efficient way to store tons of strings (was: HAT-Trie implementation in java)

The trie seems like a very good idea for your constraints. A “thinking outside the box” alternative: If you can afford some probability of answering “present” for a string that is absent EDIT: if you can afford false positives, use a Bloom filter as suggested by WizardOfOdds in the comments. For k=1, a Bloom filter … Read more

How do you know where to perform rotations in an AVL tree?

The pseudocode that you’ve posted will correctly balance a tree. That said, it is too inefficient to be practical – notice that you’re recursively exploring the entire tree trying to do rebalancing operations, which will make all insertions and deletions take O(n) time, eating away all the efficiency gains of having a balanced tree. The … Read more

Linked list vs. dynamic array for implementing a stack

There are many tradeoffs involved here and I don’t think that there’s a “correct” answer to this question. If you implement the stack using a linked list with a tail pointer, then the worst-case runtime to push, pop, or peek is O(1). However, each element will have some extra overhead associated with it (namely, the … Read more

Time Complexity for Java ArrayList

The best resource is straight from the official API: The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared … Read more

NumPy “record array” or “structured array” or “recarray”

The answer in a nutshell is you should generally use structured arrays rather than recarrays because structured arrays are faster and the only advantage of recarrays is to allow you to write arr.x instead of arr[‘x’], which can be a convenient shortcut, but also error prone if your column names conflict with numpy methods/attributes. See … Read more

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