Sorting Algorithms Flashcards

1
Q

Sorting definition (1)

A

1.) Arranging elements in a collection in increasing or decreasing order based on certain properties.

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

Why is sorting important (3)

A
  1. ) Some algorithms require sorted lists.
  2. ) To normalise and standardise data.
  3. ) To make searching easier.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Classification of sorting algorithms (4)

A
  1. ) Time complexity.
  2. ) Stability.
  3. ) Memory usage.
  4. ) Recursion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Bubble/Ripple sort (3)

A
  1. ) Brute force.
  2. ) Stable.
  3. ) In place.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Bubble/Ripple how (3)

A
  1. ) Compares adiacent elements in an array.
  2. ) If out of order swaps them, else go on.
  3. ) Continues until no swaps happen in one full pass.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Bubble/Ripple | Big O (2)

A
  1. ) Best: O(n)

2. ) Worst/Average: O( n^2 )

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

Merge sort (1)

A

1.) Divide and conquer.

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

Merge sort how (2)

A
  1. ) Divide list in n sub lists of 1 element.

2. ) Reunite sublists recursively, placing each element in the right order.

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

Merge | Big O (1)

A

1.) O( n log(n) )

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

Quicksort/Partition-Exchange sort (2)

A
  1. ) Divide and conquer

2. ) In-place

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

Quicksort how (5)

A
  1. ) Select a pivot.
  2. ) Scan array from two ends.
  3. ) From left, it looks for elements bigger than the pivot. From right it looks for elements smaller than the pivot.
  4. ) When it finds a element to swap it waits for the other side to find one and then swaps.
  5. ) Repeat step 1 until one element left in the list.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Quicksort Big O (2)

A
  1. ) Best/Average: O( n log(n) )

2. ) Worst: O ( n^2 )

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

Memory usage (1)

A

An algorithm is defined as in-place if it doesn’t require the creation of temporary memory spaces.

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

What is Stability (1)

A

A stable algorithm will maintain the original order of two entries with the same value of the property.

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