midterm2 Flashcards

1
Q

The most efficient technique for finding nth Fibonacci number is recursion.

A

false

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

We generally use best case running time to measure time complexity T.

A

false

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

STL algorithms operate only on vectors.

A

true

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

If T(n) = 2n + 100n10 + 1000n5 + 10000, then T(n) is O(n10).

A

false

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

f T(n) = n3 + 1000n2log2n + 10000, then T(n) is O(n3)

A

true

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

double f(unsigned n)
{
if(n == 1)
return 1.0;
else
return n + f(n/2);
}

Given the recursive function above, what is the value of f(8)?

A

15

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

The time complexity of binary search is O(log(n))

A

true

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

unsigned f(unsigned n)
{
if(n == 0)
return 0;
else
return f(n / 10) + n % 10;
}

Given the recursive function above, what is the value of f(312)?

A

6

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

Recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem

A

true

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

If you have a vector of integers v, accumulate(v.begin(),v.end(),0) returns the sum of the elements in the vector.

A

true

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

Which of the following data structure is not suitable for binary search?

A

Linked List

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

Each node must have exactly two children in a binary tree

A

false

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

In the array representation of a binary tree, which nodes store the children of node stored at index 6?

A

(13,14)

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

In a binary search tree (BST), left child of a node cannot be greater than its right child.

A

True

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

The node in a tree without an incoming arc is called the leaf.

A

False

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

The worst case computing time of linear search is O(log2n)

A

False

17
Q

Stacks must be implemented using an array.

A

False

18
Q

There is no need to specify the capacity of a linked queue in its declaration

A

True

19
Q

Two variables are needed in a queue to represent the front and the back of the queue

A

true

20
Q

For an array-based queue “myBack == -1” returns true when the queue is empty.

A

False

21
Q

A queue is a first-in-first-out (FIFO) data structure

A

true

22
Q

The array element at index 0 should always be the top of the stack for efficiency.

A

false

23
Q

In a queue, the value of myFront is always less than myBack

A

false

24
Q

A stack is a last-in-first-out (LIFO) data structure.

A

true

25
Q

Stack is a suitable data structure for a base conversion program, which converts a decimal number to a binary number

A

true

26
Q

For an array-based stack “myTop == -1” returns true when the stack is empty.

A

true