Every True or False Flashcards
The time complexity of an algorithm can be Ω(n) and O(n^2)
TRUE
Interpolation search is faster on average than binary search.
TRUE
Given an unsorted array of n integers, the median element in the array can be found in Θ(n) time in the average-case
TRUE
Even if we consider algorithms that run on quantum computers, no algorithm can factor an integer into its prime factors in polynomial time.
FALSE
The asymptotic time complexity for adding two n-bit integers is Θ(n).
TRUE
Timesort is a hybrid of Merge Sort and Insertion Sort, and like both Merge Sort and Insertion Sort, it is a stable sorting algorithm.
TRUE
In a binary heap (considered as a tree), any two leaf nodes have either the same depth or depths differing by one
TRUE
Given an array of 1,000,000 records in which only a few are out of order and they are not far from their correct position, the best choice of a sorting algorithm is Insertion sort because the array is almost sorted.
TRUE
Insertion sort is an adaptive sorting algorithm.
A function f(n) can be O(n^2) and Ω(n)
TRUE
A graph G = (V,E) is said to be sparse if |E| = O(|V|)
TRUE
For a priority queue implemented as a binary heap, the two operations of inserting an element and removing an element (and maintaining the heap property) each have O(log n) complexity, where n is the size of the priority queue.
TRUE
Prim’s algorithm can find a minimal spanning tree of a graph only if the graph is undirected.
FALSE
There is an algorithm that tests whether a graph G = (V,E) is acyclic in worst-case time complexity O(V+E)
TRUE
DPS»_space; O(V+E)
Breadth first search uses a stack
FALSE
Uses a QUEUE.
An optimal solution to the fractional knapsack problem can be found by a greedy algorithm, whereas an optimal solution to the 0/1 knapsack problem cannot.
TRUE