Questions tagged [data-structures]

Questions about ways of storing data so that it can be used advantageously by algorithms.

Questions about ways of storing data so that it can be used advantageously by algorithms.

In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Data structures can implement one or more particular abstract data types (ADT), which are the means of specifying the contract of operations and their complexity.

2166 questions
23
votes
1 answer

Is there an equivalent of van Emde Boas trees for ropes?

Someone I know is planning on implementing a text editor in the near future, which prompted me to think about what kind of data structures are fast for a text editor. The most used structures are apparently ropes or gap buffers. Van Emde Boas trees…
Alex ten Brink
  • 9,066
  • 3
  • 35
  • 63
11
votes
3 answers

Why is the inverted index called so and not simply index?

In my notes is represented like this: From wikipedia: In computer science, an inverted index (also referred to as a postings file or inverted file) is a database index storing a mapping from content, such as words or numbers, to its locations in a…
Gerardo Zinno
  • 271
  • 3
  • 13
9
votes
1 answer

Is hedge union always as fast as divide and conquer?

Adams describes a divide-and-conquer algorithm for finding the union of two sets (represented as weight-balanced binary search trees). He then describes a then-new "hedge union" algorithm which he claims improves on the divide-and-conquer one.…
dfeuer
  • 409
  • 2
  • 14
8
votes
1 answer

Best data structure for queries about subsets?

I am interested in finding a data structure that supports the following operations: Insert Set: Insert a set into the data structure. Decide Subset: Determine whether a given set is a subset of any of the inserted sets. The most obvious way to…
Display Name
  • 385
  • 1
  • 7
7
votes
1 answer

Data structure for testing all subsets of a query for membership

Is there a data structure that efficiently supports the following operations? Add set Query whether any subset of a set has been added. This could be implemented with linear overhead by testing every added set during every query. Can it be…
7
votes
2 answers

The most appropriate way to implement a heap is with an array rather than a linked list, why is this?

The most appropriate way to implement a heap is with an array rather than a linked list, why is this? I don't completely comprehend why this is? is it because it is easier to traverse?
cmehmen
  • 169
  • 1
  • 1
  • 4
6
votes
1 answer

Data structures for annotations in large-scale text editor

I need to create a specialized text editor capable of handling text up to billions of characters long, with no line breaks. I've read of multiple data structures to manage the text itself, including ropes, zippers, piece tables, gap buffers, and…
Andy Thomas
  • 187
  • 8
6
votes
2 answers

print the nodes of an immutable single-linked list in reverse order

Assume you have a single-linked list of length n. The list is immutable. A node node has a method next and node.next() returns a reference to the successor of node. node.print() prints the value of node node or does some other stuff, such etails…
miracle173
  • 542
  • 2
  • 16
5
votes
1 answer

Do we need both path compression and union by rank together in disjoint set data structure?

I was studying disjoint set data structure. I studied path compression and union by rank. Initially all the elements are single in their own set and by performing unions we can combine different sets. Now since we are performing union by rank the…
Navjot Singh
  • 1,215
  • 1
  • 9
  • 26
5
votes
1 answer

What's the highest 'order' data structure

Not sure exactly how to define this but here's the basis of the question (very loosely) All lists can be contained in tree's all trees can be contained in a graph all graphs can be contained in a multi graph, and all multigraphs can be contained…
daven11
  • 159
  • 4
4
votes
1 answer

when to use preorder, postorder and inorder binary search tree traversal strategies

What are some examples of when to use preorder/postorder practically? When does it make more sense than in-order?
Amna Rajpoot
  • 55
  • 1
  • 5
4
votes
3 answers

Datastructure for insertion and scored extraction

I have a simple program (assume a shop) that is actually just returning the $m$ most active customers from a total list of $n$ users (so $m \leq n$). I only use this program on one machine with one process, so assume no distribution of data to be…
5-to-9
  • 143
  • 3
4
votes
1 answer

Heap comparison based sorting question

I need some help with this question from my problem set. I do not want a solution but some $\textbf{hints}$ on how to proceed. Given $n$ records in a file that are so numerous, that just storing the $n$ keys alone would require more RAM than is…
user119264
  • 339
  • 1
  • 9
4
votes
1 answer

Why $2n−1$ comparisons are sometimes necessary to correctly merge two sorted sequences

How we can prove that $2n−1$ comparisons are sometimes necessary to correctly merge two sorted sequences of $n$ elements each into one sorted sequence? I tried to prove it with binary decision tree, but it was not working.
4
votes
1 answer

n points in 2d plane and a method(a,b) that returns all points closer to 0 than (a,b)

Given n points in a 2d plane I.E $ (x_1,y_1),(x_2,y_2)\dots (x_n,y_n) $. Create a data structure that holds the points and a method closer$(a,b)$ that returns all the points in the data structure that are closer to $(0,0) $ than to $(a,b) $. The…
Danny Blozrov
  • 232
  • 1
  • 9
1
2 3
8 9