Package edu.princeton.cs.algs4
Class FibonacciMinPQ<Key>
- Object
 - 
- edu.princeton.cs.algs4.FibonacciMinPQ<Key>
 
 
- 
- 
Constructor Summary
Constructors Constructor Description FibonacciMinPQ()Initializes an empty priority queue Worst case is O(1)FibonacciMinPQ(Comparator<Key> C)Initializes an empty priority queue Worst case is O(1)FibonacciMinPQ(Comparator<Key> C, Key[] a)Initializes a priority queue with given keys Worst case is O(n)FibonacciMinPQ(Key[] a)Initializes a priority queue with given keys Worst case is O(n) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeydelMin()Deletes the minimum key Worst case is O(log(n)) (amortized)voidinsert(Key key)Insert a key in the queue Worst case is O(1)booleanisEmpty()Whether the priority queue is empty Worst case is O(1)Iterator<Key>iterator()Gets an Iterator over the Keys in the priority queue in ascending order The Iterator does not implement the remove() method iterator() : Worst case is O(n) next() : Worst case is O(log(n)) (amortized) hasNext() : Worst case is O(1)KeyminKey()Gets the minimum key currently in the queue Worst case is O(1)intsize()Number of elements currently on the priority queue Worst case is O(1)FibonacciMinPQ<Key>union(FibonacciMinPQ<Key> that)Merges two heaps together This operation is destructive Worst case is O(1)- 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface java.lang.Iterable
forEach, spliterator 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
FibonacciMinPQ
public FibonacciMinPQ(Comparator<Key> C)
Initializes an empty priority queue Worst case is O(1)- Parameters:
 C- a Comparator over the Keys
 
- 
FibonacciMinPQ
public FibonacciMinPQ()
Initializes an empty priority queue Worst case is O(1) 
- 
FibonacciMinPQ
public FibonacciMinPQ(Key[] a)
Initializes a priority queue with given keys Worst case is O(n)- Parameters:
 a- an array of keys
 
- 
FibonacciMinPQ
public FibonacciMinPQ(Comparator<Key> C, Key[] a)
Initializes a priority queue with given keys Worst case is O(n)- Parameters:
 C- a comparator over the keysa- an array of keys
 
 - 
 
- 
Method Detail
- 
isEmpty
public boolean isEmpty()
Whether the priority queue is empty Worst case is O(1)- Returns:
 - true if the priority queue is empty, false if not
 
 
- 
size
public int size()
Number of elements currently on the priority queue Worst case is O(1)- Returns:
 - the number of elements on the priority queue
 
 
- 
insert
public void insert(Key key)
Insert a key in the queue Worst case is O(1)- Parameters:
 key- a Key
 
- 
minKey
public Key minKey()
Gets the minimum key currently in the queue Worst case is O(1)- Returns:
 - the minimum key currently in the priority queue
 - Throws:
 NoSuchElementException- if the priority queue is empty
 
- 
delMin
public Key delMin()
Deletes the minimum key Worst case is O(log(n)) (amortized)- Returns:
 - the minimum key
 - Throws:
 NoSuchElementException- if the priority queue is empty
 
- 
union
public FibonacciMinPQ<Key> union(FibonacciMinPQ<Key> that)
Merges two heaps together This operation is destructive Worst case is O(1)- Parameters:
 that- a Fibonacci heap- Returns:
 - the union of the two heaps
 
 
 - 
 
 -