Pop multiple values from Redis data structure atomically?

Use LRANGE with LTRIM in a pipeline. The pipeline will be run as one atomic transaction. Your worry above about WATCH, EXEC will not be applicable here because you are running the LRANGE and LTRIM as one transaction without the ability for any other transactions from any other clients to come between them. Try it … Read more

Explain the difference between a data *structure* and a data *type* [closed]

A data structure is an abstract description of a way of organizing data to allow certain operations on it to be performed efficiently. For example, a binary tree is a data structure, as is a Fibonacci heap, AVL tree, or skiplist. Theoreticians describe data structures and prove their properties in order to show that certain … 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 prevents Van Emde Boas trees from being more popular in real-world applications?

The asymptotic complexity is sometimes misleading. In the case for Van Emde Boas tree the constant is quite large see here. I quote: However, for small trees the overhead associated with vEB trees is enormous: on the order of 2^(m/2) There are also other cases where an algorithm with better complexity exists but it only … Read more

Difference between a LinkedList and a Binary Search Tree

Linked List: Item(1) -> Item(2) -> Item(3) -> Item(4) -> Item(5) -> Item(6) -> Item(7) Binary tree: Node(1) / Node(2) / \ / Node(3) RootNode(4) \ Node(5) \ / Node(6) \ Node(7) In a linked list, the items are linked together through a single next pointer. In a binary tree, each node can have 0, … Read more

How do you write data structures that are as efficient as possible in GHC? [closed]

That’s a big topic! Most has been explained elsewhere, so I won’t try to write a book chapter right here. Instead: Real World Haskell, ch 25, “Performance” – discusses profiling, simple specialization and unpacking, reading Core, and some optimizations. Johan Tibell is writing a lot on this topic: Computing the size of a data structure … Read more

tech