Sorting Info Flashcards

(13 cards)

1
Q

Bubble Sort: Best, Average, Worst, Stable?, In Place?, Use

A

Best: O(n)
Average: O(n^2)
Worst: O(n^2)
Stable? Yes
In Place? Yes
Use: Small nearly sorted sets

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

Selection Sort: Best, Average, Worst, Stable?, In Place?, Use

A

Best: O(n^2)
Average: O(n^2)
Worst: O(n^2)
Stable? No, changes relative order of equal elements
In Place? Yes, doesn’t require extra memory
Use: Small nearly sorted sets

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

Insertion Sort: Best, Average, Worst, Stable?, In Place?, Use

A

Best: O(n)
Average: O(n^2)
Worst: O(n^2)
Stable? Yes
In Place? Yes
Use: Small nearly sorted sets, timsort

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

Merge Sort: Best, Average, Worst, Stable?, In Place?, Use

A

Best: O(nlogn)
Average: O(nlogn)
Worst: O(nlogn)
Stable? Yes
In Place? No
Use: large dataset, extra space not a concern

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

Quick Sort: Best, Average, Worst, Stable?, In Place?, Use

A

Best: O(nlogn)
Average: O(nlogn)
Worst: O(n^2)
Stable? No
In Place? Yes
Use: general purpose, efficient, speed, large dataset. avoid worst case.

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

Stack (FILO) First in Last Out Running Time and Uses

A

Running Time: O(1)

Undo Redo
Browser Back
Memory

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

Queue (FIFO) First in, first out

A

Running Time: O(1)

Simulations Traffic/Airport
Print spools
Process/job queue

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

Min max Priotity Queue Running Time and Uses

A

Running time: O(1)

Process/CPU Schedules
Task List
Ticketing System

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

Ordered Map and Set

A

Running Time: O(log(n))

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

Unordered map and set

A

Running Time: O(1)

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

Array/vector Running Time (back, middle, front)

A

Running Time: O(1) for access and insertion at back
O(n) for insertion and removal elsewhere

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

List

A

Running Time: O(1) for insertion and removal, but not for random access

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

Stack, queue, priority queue Running Time

A

O(1) for adding to, removing from, wnd accessing proper ends

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