Test 1 Questions Flashcards
The time complexity of an algorithm can be Ω(n) and O(n^2)
T/F
TRUE
Interpolation search is ___ on average than binary search.
Faster
Given an unsorted array of n integers, the median element in the array can be found ____ time in the average-case
Θ(n)
Quicksort uses a ____ pivot selection
Randomized.
Is there an algorithm that can factor an integer into its prime factors in polynomial time?
Yes
The asymptotic time complexity for adding two n-bit integers is:
Θ(n)
Timsort is a hybrid of
Merge and Insertion Sort.
Timesort is a ___ sorting algorithm
Stable - Like Merge and Insertion Sort.
In a binary heap (tree), any two leaf nodes have either the same depth or depths differing by one.
T/F
TRUE
Given an array of 1 million records which only a few are out of order and are not far from their correct position, the best choice of sorting algorithm is :
Insertion Sort
Because the array is almost sorted.
What is the selection problem?
What is the name of an algorithm that solves the selection problem?
Find the i-th element in an unsorted array.
Quickselect.
What algorithm have Θ(n ^ (lg2^3)) time complexity?
Divide and Conquer Multiplication.
What is meant by a decrease and conquer algorithm?
Name 3 Decrease and conquer algorithms
With every recursive call the size of the input decreases.
- Binary Search
- Square Root Alg
- Euclid’s Alg
What’s the recurrence relation for quicksort?
T(n)= 2T(n/2) + n
Give the name of another sorting algorithm with the same recurrence relation with quicksort?
Merge Sort