Quiz Review Flashcards

1
Q

Karatsuba’s divide and conquer multiplication algorithm is faster in practice than the grade-school multipleication algorithm no matter what the size of the integers its multiples.

A

FALSE

Karatsuba works slower with very small numbers.

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

An array of 100 integers can be sorted in O(1) time.

A

TRUE

100 Integers is a given constant input, meaning it will always return a constant time.

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

Tail-Recursive Function

A

Uses Linear recursion
Makes a recrusive call as its very last operation

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

What is the selection problem? What is the name of an algorithm that solves the selection problem, and what is its average case complexity?

A

Find the element in an unsorted array of numbers.
Quick Select
Average Case Complexity : Linear (n)

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

Describe a better way to pick the pivot

A
  1. Get First, Last, and Middle element. Get Median as pivot.
  2. Randomly select element.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Best-Case complexity for Quicksort

A

T(n) = 2T(n/2) + n
O(n log n)

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

Worst Case Complexity for Quicksort

A

T(n) = T(n-1) + n
O(n^2)

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

If a heap is used to represent a priority queue, and the first element is
removed, the heap property is restored by moving the last element to the root
of the tree, and then running MAX-HEAPIFY on the new root element. What
is the worst-case complexity of restoring the heap property in this way?

A

Worst: Log(n)

Best: Constant

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

Describe an algorithm that takes worst-case linear time to find the 100 largest elements in an array of n elements.

A
  1. Build Max Heap
  2. Turn into Priority Queue
  3. Remove/Collect 1st 100 Largest Elements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

“In Place” Algorithm

A

Uses at most O(1) space beyond initial array.

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

“In Place “ Algorithm Examples

A

Heap
Insertion
Selection

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

“Stable” Algorithm

A

Does not change duplicate’s original ordering relative to each other.

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

“Stable” Algorithm Examples

A

Merge
Insertion
Timsort

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

“Adaptive” Algorithm

A

Runs faster when input is already partially or fully sorted.

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

“Adaptive” Algorithm Examples

A

Timsort
Insertion

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

Give an example of a hydrid sorting algorithm:

A

Quicksort but when arrays get smaller, swtich to Insertion Sort.

Introselect

17
Q

Name 3 Decrease and conquer algorithms:

A

Quick Sort
Binary Search
Euclid Algorithm
Square Root Algorithm
Heap Select

18
Q

Name 3 Divide and Conquer Algorithms

A

Merge Sort
Quicksort
Russian Multiplcation (AKA Divide and Conquer Multiplication)

19
Q

Name a sublinear-time algorithm

A

Binary Search
Interpolation Search

20
Q

Name a linearithmic time algorithm:

A

Merge Sort
Quick Sort
Heap Sort

21
Q

Name an algorithm with log-logarithmic average-case time complexity.

A

Interpolation Sort