Every True or False Flashcards

1
Q

The time complexity of an algorithm can be Ω(n) and O(n^2)

A

TRUE

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

Interpolation search is faster on average than binary search.

A

TRUE

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

Given an unsorted array of n integers, the median element in the array can be found in Θ(n) time in the average-case

A

TRUE

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

Even if we consider algorithms that run on quantum computers, no algorithm can factor an integer into its prime factors in polynomial time.

A

FALSE

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

The asymptotic time complexity for adding two n-bit integers is Θ(n).

A

TRUE

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

Timesort is a hybrid of Merge Sort and Insertion Sort, and like both Merge Sort and Insertion Sort, it is a stable sorting algorithm.

A

TRUE

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

In a binary heap (considered as a tree), any two leaf nodes have either the same depth or depths differing by one

A

TRUE

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

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.

A

TRUE

Insertion sort is an adaptive sorting algorithm.

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

A function f(n) can be O(n^2) and Ω(n)

A

TRUE

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

A graph G = (V,E) is said to be sparse if |E| = O(|V|)

A

TRUE

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

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.

A

TRUE

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

Prim’s algorithm can find a minimal spanning tree of a graph only if the graph is undirected.

A

FALSE

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

There is an algorithm that tests whether a graph G = (V,E) is acyclic in worst-case time complexity O(V+E)

A

TRUE

DPS&raquo_space; O(V+E)

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

Breadth first search uses a stack

A

FALSE

Uses a QUEUE.

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

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.

A

TRUE

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

The shortest path between two vertices in a minimum-spanning tree is always the shortest path between the two vertices in the full graph.

A

FALSE

17
Q

The Bellman-Ford algorithm, which solves the single-source shortest-path problem in a graph with negative weight edges but no negative cycles, has an asymptotic complexity of Θ(V*E) regardless of whether the graph is sparse or dense.

A

TRUE

18
Q

The single-source shortest path in an acyclic graph can be solved in Θ(V+E) time, even if the graph has negative-cost weights.

A

TRUE

19
Q

The single-source longest-path problem in a graph is just as easy to solve as the single source-path problem in the same graph.

A

FALSE

20
Q

1 + 2 + 3 + . . . + (n-1) + n = O(n)

A

FALSE

21
Q

Merge sort is an in-place algorithm.

A

FALSE

22
Q

The boolean satisfiability problem can be solved by a deterministic polynomial-time algorithm if and only if P = NP.

A

TRUE

23
Q

Any problem that in the complexity class P is also in the complexity class NP.

A

TRUE

24
Q

If a problem is NP-Hard, it is also NP-complete.

A

FALSE