Quicksort Flashcards

1
Q

What is divide and conquer?

A

It’s a recursion algorithm

To solve a problem using D&C, there are two steps:
1. Figure out the base case. This should be the simplest possible case.
2. Divide or decrease your problem until it becomes the base case.

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

What is quicksort?

A

It’s a sorting algorithm, faster than selection sort and used more in real life, that use divide and conquer technique

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

What is the pivot?

A

It’s the element that we use to sort in quick sort algorithm

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

What is partitioning?

A

When we use the pivot, the array divided into:

A sub-array of all the numbers less than the pivot
The pivot
A sub-array of all the numbers greater than the pivot

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

How does quick sort algorithm work?

A
  1. Pick a pivot.
  2. Partition the array into two sub-arrays: elements less than the pivot and elements greater than the pivot.
  3. Call quicksort recursively on the two sub-arrays.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the if O for quick sort?

A

In the best case and average case=> o(n log n)
In the worst case => o(n^2)

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