study_2
This is an old revision of the document!
Binary Heaps
enqueue or dequeue items in O(logn)
Priority Queues use a min heap or max heap
Reverse Singly Linked List
prev = None cur = head while cur: next_node = cur.next cur.next = prev prev = cur cur = next_node head = prev
Reverse Double Linked List
void reverse() {
Node temp = null;
Node current = head;
/* swap next and prev for all nodes of
doubly linked list */
while (current != null) {
temp = current.prev;
current.prev = current.next;
current.next = temp;
current = current.prev;
}
/* Before changing head, check for the cases like empty
list and list with only one node */
if (temp != null) {
head = temp.prev;
}
}
Power Sets
Tries
N Choose K
n!/((n-k)!k!)
Knapsack
Coins
Quick Sort
Heaps
Spiral
Quick Sort
study_2.1592505360.txt.gz · Last modified: 2020/06/18 18:36 by jrseti