Hot answers tagged

5 votes

Is possible to have a "pointer" to a tree node in a functional language?

You are looking for the zipper data structure.
user avatar
  • 28.2k
2 votes

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

Levels by levels, the indexes of a binary heap are $$0\\1\ \ \ \ \ \ \ \ \ \ \ \ \ 2\\3\ \ \ \ \ \ 4\ \ \ \ \ \ 5\ \ \ \ \ \ 6\\7\ 8\ 9\ 10\,11\,12\,13\,14\\\cdots$$ and it is rather clear that the ...
user avatar
  • 3,910
1 vote
Accepted

Calculating number of inversions in array using AVL Finger Tree

I think there is something wrong with the definition of $TreeRank(x)$. Shouldn't it be define as the position of $x$ among the inserted items in the tree and not $A$ entirely? Otherwise, it will not ...
user avatar
  • 1,403
1 vote
Accepted

Is there a solution to the following thought experiment / problem involving trees?

What you're trying to build is kind of a crossword. This link shows an algorithm that generates crosswords. It's not quite your case, but it's close enough. Basically the algorithm does this (starting ...
user avatar
  • 316

Only top scored, non community-wiki answers of a minimum length are eligible