CSE 331 - Exam 2 Runtimes

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

For Binary search what is

  • best case, worst case, In practice runtime 

  • The space complexity

best case —> O(1)

worst case —> O(log n)

in practice —> O(log n)

space complexity —> Iterative → O(1)

__________________Recursive → O(log n)

2
New cards

For Merge Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n log n)

worst —> O(n log n)

in practice —> O(n log n)

space —> O(n)

3
New cards

Is merge sort stable, in place?

stable —> yes

in place —> no

4
New cards

For linear search what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(1)

worst —> O(n)

in practice —> O(n)

space —> O(1)

5
New cards

For Fibonacci what is its runtime

O(2^n)

6
New cards

For Quick Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n log n)

worst —> O(n²)

in practice —> O(n log n)

space —> O(log n)

7
New cards

Is Quick Sort stable, in place?

stable —> no

in place —> yes

8
New cards

For Insertion Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n)

worst —> O(n²)

in practice —> O(n²)

space —> O(1)

9
New cards

Is Insertion Sort stable? In place?

yes and yes

10
New cards

For Selection Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n²)

worst —> O(n²)

in practice —> O(n²)

space —> O(1)

11
New cards

Is Selection Sort stable? In place?

stable —> no

in place —> yes

12
New cards

What is Bubble Sort

  1. Start at the beginning of the list.

  2. Compare the first two numbers.

  3. If the first is bigger, swap them.

  4. Move to the next pair and do the same.

  5. Keep going until you reach the end — the biggest number has now “bubbled up” to the last spot.

  6. Repeat this process for the rest of the list, but stop one earlier each time (since the biggest ones are already at the end).

  7. Keep going until no swaps are needed — the list is sorted.

13
New cards

For Bubble Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n)
worst —> O(n²)
in practice —> O(n²)

14
New cards

Is Bubble Sort stable? In place?

yes and yes

15
New cards

What is heap Sort

16
New cards

For Heap Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

O(n log n)

17
New cards

Is Heap Sort stable? In place?

stable —> no
in place —> yes

18
New cards

For Radix Sort what is

  • best case, worst case, In practice runtime 

  • The space complexity

best —> O(n)

worst —> O(n)

in practice —> O(n)

19
New cards

Is Radix Sort stable? In place?

stable —> yes
in place —> no