Sorting Flashcards

1
Q

What two things are taken into consideration when determining the complexity of a sort?

A
  1. ) traversals

2. )comparisons

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

What two parts do the insertion and selection consist of?

A

unsorted & sorted

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

What is the procedure for a selection sort?

A
  • traverse to find the next value in the sorted part
  • swap this value with the first unsorted value
  • this new index is now the sorted part
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the procedure for an insertion sort?

A
  • take first value in the unsorted
  • traverse through the sorted and insert at that point
  • mark that as sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the worst time complexity of the insertion and selection sort?

A

O(N^2)

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

What is the complexity of the merge sort?

A

O(N*log N)

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