mid Flashcards

(30 cards)

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;

}

17
Q

Algorithm speed is measured in seconds.

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?

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.

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
How does the call stack work in relation to recursive functions?
d. It keeps track of the function calls made
26
What is the time complexity of popping an element from a stack?
d. O(1)
27
Which of the following is not a typical application of queues?
d. Depth-first search algorithm
28
Which of the following factors does not affect the time complexity of an algorithm?
c. The speed of the computer executing the algorithm
29
Linearithmic complexity's Big-O notation is:
c. O(nlogn)
30
The run time of algorithms is expressed in Big O notation.
False