Lecture 6 Flashcards

1
Q

Why bother with sorting alogirthms?

A

The algorithms are quite small and manageable:

1) They can be implemented in a short period of time
2) They are relatively simple to analyse

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

How do u conduct Bubble sort?

A

1) Repeatdealy compare adjacent pairs of elements
2) Swap the elements in pair putting the smaller element first
3) Reapeat

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

What is Quick sort

A

Quicksort is a divide and conquer algorithm
Quicksort picks an element from the list as the pivot, and partitions the list into two pieces:
Those elements smaller than the pivot value (not necessarily in order)
Those elements larger than the pivot value (not necessarily in order)
Quicksort is then called recursively on both pieces

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

Time complexities of Bubblesort

A

Best=O(n)

Average and Worst= O(n^2)

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

Time complexities of Quicksort

A

Best and Average =O(nLog2(n))

Worse=O(n)

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

What is Radix Sort?

A

The Radix sort method works only on binary or integer data
Radix sort works by using a binary bucket sort for each binary digit
We first “sort” by the least significant bit
Split input into 2 sets based on the bit – those that have a 0 or those that have a 1
Otherwise, maintain the order…
Then proceed to the next least significant bit and repeat until we run out of bits…

O(nb) time complexity

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