# Questions tagged [data-structures]

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

1,869 questions
Filter by
Sorted by
Tagged with
12 views

### Applications of Complete Binary Tree?

Wondering what are the real word applications of the Complete binary trees or Almost complete binary trees where the the last level of the tree may not be complete and all nodes in the last level are ...
6 views

### Efficient algorithm for finding assignable zones

This is an actual logistics problem I'm facing at work and I'd like an advice on what algorithmic approach is suitable for solving this. I have two data structures: Container and Zone defined as ...
12 views

### What is the time complexity of comparing two Merkle trees?

I have a simple recursive function that compares two merkle trees and accumulates the differences in the leaf nodes. However, I am unable to measure the time complexity of it. Specifically, I would ...
44 views

### Observations about the structure of an optimal Binary Search Tree

My question is about part 15.5 in CLRS (third edition)*, on optimal binary search trees. I am confused about the following sentences: Consider any subtree of a binary search tree. It must contain ...
14 views

### Tree data structure is for behavior modeling or optimizing operations?

Its little vague question. I am not able to visualize - Tree data structure is used to represent hierarchical entities in real world or is meant to organize data to optimize certain operations like ...
88 views

153 views

### Number of contiguous subsequences summing to a given target

I could not figure out an efficient way (better than $O(n^2)$) to count the number of contiguous subsequences of an array of both positive and negative integers summing up to a given number $k$. For ...
34 views

### kdtree or balltree supporting insertion/deletion

I'm looking for a data structure to perform nearest-neighbor searches in 3D Euclidean space. I have used kd- and balltrees for this purpose before, but my problem is more sophisticated this time. I'd ...
163 views

### Method to change value in a key for a min heap

How would you write a method to change the value of a min heap where bool changeKey(int oldKey, int newKey). The keys are unique, no duplicate keys are permitted. If there is a key in the heap with ...
32 views

2k views

### Why does the formula floor((i-1)/2) find the parent node in a binary heap?

I learned that when you have a binary heap represented as a vector / list / array with indicies [0, 1, 2, 3, 4, 5, 6, 7, 8, ...] the index of the parent of element at index i can be found with parent ...
273 views

### The Height of subtree in Heap

In order to find the recurrence function of The Height in Heap, the following figure is drawn. Question 1: How can we compute the height if Right subtree in form of Log in base 3, and why do we have ...