Common Formulas Flashcards
1
Q
Count number of sliding windows in an array of N and window size K.
A
N-K+1
2
Q
In Binary Heap, if parent node is at index ‘i’, what is index of left node?
A
2i+1
3
Q
In Binary Heap, if parent node is at index ‘i’, what is index of right node?
A
2i+2
4
Q
In Binary Heap, if a node is at index ‘i’, what is the index of parent node?
A
- i is odd: ((i+1)/2) - 1
* i is even: (i/2)-1