mid Flashcards

1
Q

Which of the following are types of LinkedList?

A

d.
singly-linked, doubly-linked, multi-linked

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

An example of logarithmic time complexity is:

A

a.
Binary search

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

Consider the following recursive function fun(x, y).

What is the value of fun(4, 3)

int fun(int x, int y){

  if (x == 0)

      return y;

  return fun(x - 1,  x + y);

}

A

d.
13

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

Linear data structure that follows a particular order in which the operations are performed

A

c.
Queue

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

Look at square numbers: square(1) = 1; square(N) = square(N-1) + 2N -1

Which method below successfully implements this definition?

A

d.
int square( int N ){

if ( N==1 ) {

return 1;

}

else

{

return square(N-1) + 2*N - 1;

}

}

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

Algorithm times are measured in terms of growth of an algorithm.

A

False

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

What does the notation O(n) represent in asymptotic analysis?

A

b.
The worst-case time complexity of an algorithm

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

Which of the following is not a typical application of stacks?

A

c.
Sorting algorithms

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

What is the time complexity of deleting an element from a singly linked list?

A

c.
O(n)

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

What is complexity independent of inputs?

A

a.
Complexity that doesn’t depend on the number of inputs

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

Which of the following usees FIFO method?

A

a.
Queue

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

For a binary search algorithm to work, it is necessary that the array list must be

A

a.
sorted

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

When the function with loops or recursive calls can have constant complexity?

A

b.
Number of iterations or calls independent of input size

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

What is the limitation of calling recursion?

A

limit of the heap memory

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

Specify ArrayList advantages over LinkedList

A

c.
arrayList is better for storing and accessing the data

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

What will Repeat(82, 3) return from the following method declaration?

public static int Repeat(int i, int j){

if (i==0)

  return 0;

else

  return Repeat(i/j, j)+1;

}

A

b.
6

17
Q

Algorithm speed is measured in seconds.

A

False

18
Q

Can a program have loops or recursive calls and still have time complexity that is constant?

A

c.
Yes, as long as the loops or recursive calls have a constant number of iterations or calls

19
Q

Which operation returns the front element from the queue without removing it?

A

b.
peek()

20
Q

What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

A

X will always be a better choice for large inputs

21
Q

Which one of the below mentioned is linear data structure

A

a.
All of the above
b.
Queue
c.
Arrays
d.
Stack

22
Q

Queue operation .Pop:

A

d.
remove from the front

23
Q

Recursion is implemented by the queue, and each time you invoke a method, the method is placed on top of the queue.

A

False

24
Q

What is the main difference between a stack and a queue?

A

a.
A stack is a LIFO data structure, a queue is a FIFO data structure.

25
Q

How does the call stack work in relation to recursive functions?

A

d.
It keeps track of the function calls made

26
Q

What is the time complexity of popping an element from a stack?

A

d.
O(1)

27
Q

Which of the following is not a typical application of queues?

A

d.
Depth-first search algorithm

28
Q

Which of the following factors does not affect the time complexity of an algorithm?

A

c.
The speed of the computer executing the algorithm

29
Q

Linearithmic complexity’s Big-O notation is:

A

c.
O(nlogn)

30
Q

The run time of algorithms is expressed in Big O notation.

A

False