Common Formulas Flashcards

1
Q

Count number of sliding windows in an array of N and window size K.

A

N-K+1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In Binary Heap, if parent node is at index ‘i’, what is index of left node?

A

2i+1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In Binary Heap, if parent node is at index ‘i’, what is index of right node?

A

2i+2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly