Questions tagged [leftist-tree]
10 questions
3
votes
1 answer
Leftist heap two version create implementation
Recently, I am reading the book Purely-functional-data-structures
when I came to “Exercise 3.2 Define insert directly rather than via a call to merge” for Leftist_tree。I implement a my version insert.
let rec insert x t =
try
match t with
| E ->…

Sughiy
- 45
- 5
3
votes
1 answer
What's the real purpose of the rank in Leftist Heap?
Leftist heap maintains a key and a rank for every node. The rank of a node is the number of nodes along in the shortest path to a leaf.
The whole tree needs two properties to be maintained:
node.key < node.left.key && node.key <…

Jackson Tale
- 25,428
- 34
- 149
- 271
1
vote
1 answer
Worst Case Runtimes of Skew Heap vs Leftist Heap
I'm studying for some technical interviews coming up and was just going over lecture slides from a year or two ago about data structures.
I'm not clear on why the worst case runtimes of merge for a leftist heap is O(log n) whereas for a skew heap…

imyjimmy
- 711
- 2
- 11
- 18
1
vote
1 answer
Complexity of heapify on a leftist heap queue
"Data Structures and Network Algorithms" by Tarjan states the heapify function in leftiest heaps as following:
heap function heapify (list q);
do |q| ≥ 2 → := q[3..] & meld (q(1), q(2)) od;
return if q = [ ] → null | q != [ ] → q(1) fi
end…

Alexander Weber
- 789
- 4
- 16
1
vote
0 answers
A d leftist heap implementation
So I've managed to get a working recursive version of a binary leftist heap using the following code.
public class Node>
{
public T data;
public Node left;
public Node right;
public int npl;
public…

StrawHatPirate
- 11
- 2
1
vote
2 answers
Is this Leftist Tree piece of code from Wikipedia correct?
Link
public Node merge(Node x, Node y) {
if(x == null)
return y;
if(y == null)
return x;
// if this was a max height biased leftist tree, then the
// next line would be: if(x.element < y.element)
…

they changed my name
- 481
- 2
- 8
- 12
1
vote
1 answer
Need assistance with the result of a simple Leftist Heap Insert
I have a (min) Leftist Heap as show below:
1
/ \
8 6
/ \ / \
10 12 14 16
/\ /
18 20 22
And I am asked to show the result of inserting 21.…

Rekson
- 1,293
- 3
- 12
- 13
0
votes
1 answer
Percolating up a C++ leftist heap results in seg fault
I have implemented a removeSelection function that removes a specific node from a leftist heap. The code locates the node via a hashtable that keeps track of the keys that have been inserted into the heap. The node is then percolated to the root of…

Netsuki
- 53
- 9
0
votes
1 answer
Leftist heap is merging VERY slowly
My implementation behaves correctly with a small, traceable number of items. This leftist heap takes several seconds to insert 50,000 items when it takes a skew heap a few milliseconds.
So I believe I have the algorithm implemented correctly, but…

Alouette
- 1
- 3
-2
votes
2 answers
leftist heap implementation in c++
good afternoon, i am trying to implement leftist heap
here is my header file and source file
for header file
#include
template
class leftistheap;
template
class leftistnode
{
comparable element;
…

Aleksi Beriashvili
- 105
- 2
- 10