S6-P1,2 Flashcards

1
Q
A

4
A

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

2
A
Note: To find Kth number among n numbers, we don’t use excess memory.

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

1
A
Note: Counting sort is for when we know the range and the numbers are integers.

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

Memorize the formula

161

A

1
A

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

3
A

Note On Finding Kth. element: If we use the quick-select approach, then we do not need to sort the array before finding the kth minimum element. The time complexity of the quick-select approach is O(n), where n is the number of elements in the array. Fix that one note where kth element is explained

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

Mind fuck

163

A

4
A
Note On Method 2: when median x > median y, then the upper half of x is bigger than its upper half + y’s lower half, so the xy median must be in the lower half of x or the upper half of y.

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

2
A

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

4
A
Sorting Algorithms

Note: When we partition the array using √n, we have at least √n smaller numbers since we found √nth element (the median) of the first 2√n+1.

Note: The question wants the worst case, worst case is when there’s exactly √n numbers behind the median of 2√n+1 first elements, because it creates the biggest unsorted part after √nth element.

The order of the final recursive formula: draw a tree, nodes on each level =n and since we are doing n-√n in each step, the height would be √n.

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

End Of P1,2

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