Font size
S
M
L
XL
WorksheetsADS ULTRA (AITU)
Total questions: 153
Worksheet time: 51mins
Name
Class
Date
1.
What is the time complexity for adding an element to the end of Linked List?
a)
O(1)
b)
O(Nˆ2)
c)
O(logN)
d)
O(N)
2.
Which of the following is not the type of queue?
a)
Ordinary queue
b)
Circular queue
c)
Priority queue
d)
Single ended queue
3.
What is double-linked list?
a)
each node points to the next node
b)
last node points to the first
c)
each node points to all previous nodes
d)
each node points to the next and previous nodes
4.
Which among the following is the worst-case time complexity for appending an element in a variable-length array?
a)
O(n)
b)
O(n2)
c)
O(log n)
d)
O(1)
5.
Specify ArrayList advantages over LinkedList
a)
arrayList is better for manipulating the data
b)
adding and removing an element
c)
less memory usage
d)
increasing the size
6.
What will be the result of nested statements/loops or recursion?
a)
O(1)
b)
O(n^2 + n)
c)
O(n^2)
d)
O(n)
7.
We can use the following recursive function to search an array of sorted numerical values to find a specific number in that array (or return -1 if the value isn't in the array):
function searchSortedArray(number, array, beginIndex = 0, endIndex = array.length - 1)
{
let middleIndex = Math.floor((beginIndex + endIndex)/2);
if (array[middleIndex] === number)
{
return middleIndex;
}
else if (beginIndex >= endIndex)
{
return -1;
}
else if (array[middleIndex] < number)
{
beginIndex = middleIndex + 1;
return searchSortedArray(number, array, beginIndex, endIndex);
}
else if (array[middleIndex] > number)
{
endIndex = middleIndex - 1;
return searchSortedArray(number, array, beginIndex, endIndex);
}
}
a)
O(n*n)
b)
O(nlogn)
c)
O(logn)
d)
O(n)
8.
hich of the statements below is not related to recursion
a)
Termination when loop-continuation condition fails
b)
Problem division
c)
Implementation of the selection statements
d)
Repetitve method calls
9.
This method will return true onlu in case if:
public static boolean check (String s)
{
return s.length( ) >= 2 && (s.charAt(0) == s.charAt(1) || check(s.substring(1)));}
a)
The string s contains two or more of the same character that are next to each other.
b)
The string s contains two or more of the same characters.
c)
The string s ends with two or more of the same characters
d)
The string s starts with two or more of the same characters.
10.
Find the complexity of the below program:
static void function(int n)
{
if (n==1)
return;
{ for (int i=1; i<=n; i++)
{ for (int j=1; j<=n; j++)
System.out.print("*");
break;
}
System.out.println();
}
}
a)
O(logn)
b)
O(n*n)
c)
O(n)
d)
O(nlogn)
11.
What will be the output of the following program?
class RecursiveFor{
public static void main(String[] args)
{ int out = 15;
for (int i = 4; i < 6; i++)
{ for (int j = 7; j >= 5; j--)
{ if (i == j) continue;
if (i > j){ out += main(i, j);
} else { out += main(j, i); }
}
}
System.out.println("out = " + out);
}
private static int main(int a, int b)
{ if (a + b == 0)
{ return 2; }
return a + main(a - 1, b); }
}
a)
Goes into infinite loop
b)
out = 80
c)
out = 78
d)
compilation error
e)
out = 100
12.
What is complexity independent of inputs?
a)
Complexity that only depends on certain input types
b)
Complexity that doesn't depend on the number of inputs
c)
Complexity that depends on the number of inputs
d)
Complexity that varies with the input size
13.
What is the time complexity of an algorithm that performs a constant number of operations?
a)
O(n^2)
b)
O(nlogn)
c)
O(1)
d)
O(n)
14.
What is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity?
a)
Algorithm efficiency
b)
Order of growth
c)
Linear time complexity
d)
Big-O notation
15.
Which of the following factors does not affect the time complexity of an algorithm?
a)
The number of operations performed by the algorithm
b)
The number of input data
c)
The size of the input data
d)
The speed of the computer executing the algorithm
16.
Linearithmic complexity's Big-O notation is:
a)
O(long)
b)
O(n*n)
c)
O(n)
d)
O(nlogn)
17.
Example of logarithmic time complexity is:
a)
Simple search
b)
Searching in a Hash table
c)
Bubble sort
d)
Binary search
18.
Following the law of addition in Big-O notation, what is the result of the following expression? 100n^2 + 3n − 100
a)
O(n)
b)
O(n^2)
c)
O(1)
d)
O(n^2+n)
19.
When you run recursive methods, the computer creates for you:
a)
Heap
b)
Linked List
c)
Stack
d)
Queue
20.
What advantage does a linked list have over an array?
a)
all of the above
b)
You can add or remove elements from the middle of the list.
c)
Size of the list doesn't need to be mentioned at the beginning of the program
d)
The linked list doesn't have a size limit
21.
What is circular-linked list?
a)
each node points to the next node
b)
each node points to the next and previous nodes
c)
each node points to all previous nodes
d)
last node points to the first
22.
The worst case complexity of deleting any arbitrary node value element from heap is __________
a)
O(logn)
b)
O(nlogn)
c)
O(n^2)
d)
O(n)
23.
. What is the time complexity of pop() operation when the stack is implemented using an array?
a)
O(logn)
b)
O(1)
c)
O(nlogn)
d)
O(n)
24.
Heap can be used as ________________
a)
A decreasing order array
b)
Normal Array
c)
Priority queue
d)
Stack
25.
A queue follows __________
a)
FIFO (First In First Out) principle
b)
Linear tree
c)
LIFO (Last In First Out) principle
d)
Ordered array
26.
What is the space complexity for deleting a linked list?
a)
O(logn)
b)
Either O(1) or O(n)
c)
O(1)
d)
O(n)
27.
Process of inserting an element in stack is called ____________
a)
Evaluation
b)
Push
c)
Pop
d)
Create
28.
What is the time complexity for adding an element at the beginning of LinkedList?
a)
O(1)
b)
O(Nˆ2)
c)
O(logN)
d)
O(N)
29.
___________ is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.
a)
Big-O notation
b)
Counting operations
c)
Linear complexity
d)
None of the above.
30.
Data structure that has the same size throughout the program
a)
Array
b)
ArrayList
c)
LinkedList
d)
HashTable
31.
What is direct addressing?
a)
Fewer keys than array positions
b)
Distinct array position for every possible key
c)
Fewer array positions than keys
d)
Same array position for all keys
32.
A machine needs a minimum of 200 sec to sort 1000 elements by Quick sort. The minimum time needed to sort 200 elements will be approximately __________
a)
20 sec
b)
45.54 sec
c)
60.2 sec
d)
31.11 sec
33.
Which of the following sorting algorithms is the fastest?
a)
Insertion sort
b)
Merge sort
c)
Quick sort
34.
Which one of the following sorting algorithm is best suited to sort an array of 1 million elements?
a)
Merge sort
b)
Quick sort
c)
Insertion sort
d)
Bubble sort
35.
Quick sort follows Divide-and-Conquer strategy.
a)
False
b)
True
36.
The insert() procedure, given below, builds the BST on the input elements, which is the first step of the binary tree sort. Choose the correct to fill the condition.
void insert(Tree* node, int newElement)
{
if(node== NULL)
{
node = createNewNode();
node-> value = newElement;
node -> left = NULL;
node -> right = NULL;
return;
}
else if(__________________)
{
insert(node->left, newElement);
}
else
{
insert(node->right, newElement);
}
}
a)
newElement < node->value
b)
newElement == root->value
c)
newElement > node->value
d)
newElement != root->value
37.
What is its wort case time complexity of Heap sort?
a)
O(n3)
b)
O(n2)
c)
O(nlogn)
d)
O(n2logn)
38.
How many arrays are required to perform deletion operation in a heap?
a)
2
b)
1
c)
4
d)
3
39.
Heap sort is an extremely stable algorithm.
a)
True
b)
false
40.
What is the time taken to perform a delete min operation?
a)
O(N)
b)
O(log N)
c)
O(N2)
d)
O(N log N)
41.
Quick sort uses which of the following method to implement sorting?
a)
Partitioning
b)
Exchanging
c)
Merging
d)
Selection
42.
In what time can a binary heap be built?
a)
O(N)
b)
O(N log N)
c)
O(N2)
d)
O(log N)
43.
Which of the following is not a technique to avoid a collision?
a)
Use uniform hashing
b)
Make the hash function appear random
c)
Increasing hash table size
d)
Use the chaining method
44.
State the complexity of algorithm given below.
int function(vector<int> arr)
int len=arr.length();
if(len==0)
return;
temp=arr[len-1];
arr.pop_back();
return temp;
a)
O(n logn)
b)
O(1)
c)
o(n)
d)
O(logn)
45.
What is the space complexity of searching in a heap?
a)
O(1)
b)
O(n)
c)
O(nlogn)
d)
O(logn)
46.
If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?
a)
DCAB
b)
ABCD
c)
ABDC
d)
DCBA
47.
Which of the following is true about add() method of Array List
a)
method has a return value
b)
all of the above
c)
method inserts the specified element at the specified position in this list
d)
method inserts value to the next node of the specified element
48.
6. Which of the following array position will be occupied by a new element being pushed for a stack of size N elements(capacity of stack > N)?
a)
S[N-1]
b)
S[1]
c)
S[0]
d)
S[N]
49.
If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start. The value of root node after second iteration is 2 if leaf node is chosen at start
a)
17
b)
2
c)
3
d)
100
50.
Which of the following areBtypes of Linked List
a)
singly-linked, doubly-linked, circular-linked
b)
circular-linked, doubly-linked, multi-linked
c)
singly-linked, circular-linked, multi-linked
d)
singly-linked, doubly-linked, multi-linked
51.
Which of the following is an advantage of using variable-length arrays?
a)
Faster execution of code
b)
Memory allocation at compile time
c)
Deciding the length of an array at the time of execution
d)
Initializing array at compile time
52.
An array consists of n elements. We want to create a heap using the elements. The time complexity of building a heap will be in order of
a)
O(n*n)
b)
O(n*n*logn)
c)
O(n *logn *logn)
d)
O(n*logn)
53.
What index value is used to locate the last element in the numbers Array List?
a)
numbers.size()-1
b)
numbers.size()
c)
numbers.length()
d)
numbers.length() - 1
54.
LinkedList can NOT be of generic type <T>
a)
true
b)
false
55.
Find the complexity of the below program:
static void function(int n)
{
int count = 0;
for (int i = n / 2; i <= n; i++)
for (int j = 1; j <= n; j = 2 * j)
for (int k = 1; k <= n; k = k * 2)
count++;
}
a)
O(n)
b)
O(log n)
c)
O(n log^2 n)
d)
O(n*n)
56.
The execution of the recursion stops at the moment when
a)
loop condition fails
b)
Failing of the base case
c)
finishing repeated self calls
d)
Base case recognition
57.
We can use the following function below to determine the sum of an array of sequential numbers. What is the Big O notation for this algorithm?
const array = [1,2,3,4,5,6,7,8];
function determineSumOfSequentialArray(array)
{let sum = 0;
for (let i = 0; i < array.length; i++)
{sum += array[i];}
return sum;}
a)
O(n*n)
b)
O(1)
c)
O(n)
d)
O(logn)
58.
Which traversal algorithm is typically implemented using a stack data structure?
a)
Neither BFS nor DFS
b)
BFS
c)
DFS & BFS
d)
DFS
59.
Adjacency matrix of all graphs are symmetric.
a)
False
b)
True
60.
What would be the time complexity of the following function which adds an edge between two vertices i and j, with some weight ‘weigh’ to the graph having V vertices?
vector<int> adjacent[15] ;
vector<int> weight[15];
void addEdge(int i,int j,int weigh)
{
adjacent[a].push_back(i);
adjacent[b].push_back(j);
weight[a].push_back(weigh);
weight[b].push_back(weigh);
}
a)
O(V)
b)
O(1)
c)
O(log V)
d)
O(V*V)
61.
Space complexity for an adjacency list of an undirected graph having large values of V (vertices) and E (edges) is ___________
a)
O(E+V)
b)
O(E)
c)
O(V*V)
d)
O(V)
62.
Which of the following statements is/are TRUE for an undirected graph? P: The number of odd-degree vertices is even Q: Sum of degrees of all vertices is even
a)
P Only
b)
Q Only
c)
Neither P nor Q
d)
Both P and Q
63.
The number of elements in the adjacency matrix of a graph having 7 vertices is __________
a)
7
b)
49
c)
36
d)
14
64.
Which of the following is true?
a)
A graph may contain no edges and no vertices
b)
A graph may contain no edges and many vertices
c)
A graph may contain no vertices and many edges
d)
A graph may contain many edges and no vertices
65.
What is the sequence of the level order traversal in the following graph?
a)
A, D, G, J, C, E, I, F, B, H
b)
F, B, J, C, E, I, H, A, D, G
c)
F, B, G, J, C, H, A, D, E, I
d)
F, B, H, A, D, G, J, C, E, I
66.
Space complexity for an adjacency list of an undirected graph having large values of V (vertices) and E (edges) is __________
a)
O(V)
b)
O(E)
c)
O(E*E)
d)
O(E+V)
67.
A graph with all vertices having equal degree is known as a __________
a)
Complete Graph
b)
Regular Graph
c)
Simple Graph
d)
Multi Graph
68.
What is the complexity of adding an element to the heap.
a)
O(h)
b)
O(n)
c)
O(log n) & O(h)
d)
O(log n)
69.
3. What does ‘stack underflow’ refer to?
a)
accessing item from an undefined stack
b)
index out of bounds exception
c)
adding items to a full stack
d)
removing items from an empty stack
70.
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)
5
b)
The method never returns due to infinite recursion.
c)
4
d)
7
e)
6
71.
Time complexity of the given example is: public static int fib(int n){if (n<=1) return n;return fib(n-2)+fib(n-1)}
a)
exponential
b)
logaithmic
c)
linearithmic
d)
quadratic
72.
True or False? Order of growth focuses on lower-order terms
a)
False
b)
True
73.
What does it mean for a problem to have complexity independent of inputs?
a)
The complexity of the problem increases as the number of inputs increase.
b)
The complexity of the problem depends on the input size
c)
The complexity of the problem decreases as the number of inputs
d)
The complexity of the problem remains constant no matter how many inputs are given.
74.
What is the focus of determining the order of growth?
a)
Dominant terms.
b)
Leading coefficients.
c)
Lower-order terms.
d)
All terms.
75.
Following the law of addition in Big-O notation, what is the result of the following expression? 7n-2
a)
O(n^2+logn )
b)
O(1)
c)
O(n^2)
d)
O(n)
76.
What is the need for a circular queue?
a)
to delete elements based on priority
b)
implement LIFO principle in queues
c)
effective usage of memory
d)
easier computations
77.
2. Process of removing an element from stack is called __________
a)
Push
b)
Evaluation
c)
Create
d)
Pop
78.
A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?
a)
Queue
b)
Dequeue
c)
Circular queue
d)
Priority queue
79.
Choose the definition for Linked List
a)
Linked List is a series of connected edges
b)
Linked List is a collection type with indexes
c)
Linked List is a collection type with fixed size
d)
Linked List is a series of connected nodes
80.
Data structure that can increase by itself
a)
ArrayList
b)
LinkedList
c)
HashTable
d)
Array
81.
What is the time complexity of enqueue operation?
a)
O(nlogn)
b)
O(logn)
c)
O(1)
d)
O(n)
82.
Which statement is the correct declaration and initialization of an ArrayList of String values?
a)
String<ArrayList> name;
name = new String<ArrayList>();
b)
ArrayList<String> name;
name = new ArrayList<String>();
c)
ArrayList<String> name;
name = ArrayList<String>()
d)
ArrayList name;
name = new ArrayList<String>();
83.
What is the average case complexity of QuickSort?
a)
O(nlogn)
b)
O(n)
c)
O(logn)
d)
O(n2)
84.
Quick Sort is a __________
a)
greedy algorithm
b)
divide and conquer algorithm
c)
backtracking algorithm
d)
dynamic programming algorithm
85.
Merge sort uses which of the following method to implement sorting?
a)
Exchanging
b)
Merging
c)
Selection
d)
partitioning
86.
What will be the best case time complexity of merge sort?
a)
O(n log n)
b)
O(n log n2)
c)
O(n2)
d)
O(n2 log n)
87.
What is a hash table?
a)
A structure used for storage
b)
A structure that maps values to keys
c)
A structure used to implement stack and queue
d)
A structure that maps keys to values
88.
What is the auxiliary space complexity of merge sort?
a)
O(n log n)
b)
O(n)
c)
O(1)
d)
O(log n)
89.
What is the worst case time complexity of a quick sort algorithm?
a)
O(log N)
b)
O(N log N)
c)
O(N2)
d)
O(N)
90.
Which of the following method is used for sorting in merge sort?
a)
selection
b)
Merging
c)
Partitioning
d)
Exchanging
91.
What is the best case time complexity of the binary tree sort?
a)
O(n2)
b)
O(logn)
c)
O(nlogn)
d)
O(n)
92.
Consider the Quick sort algorithm which sorts elements in ascending order using the first element as pivot. Then which of the following input sequence will require a maximum number of comparisons when this algorithm is applied on it?
a)
22 25 56 67 89
b)
52 25 76 67 89
c)
22 25 76 67 50
d)
52 25 89 67 76
93.
Circular Queue is also known as ________
a)
Ring Buffer
b)
Rectangle Buffer
c)
Curve Buffer
d)
Square Buffer
94.
Array implementation of Stack is not dynamic, which of the following statements supports this argument?
a)
a runtime exception halts execution
b)
improper program compilation
c)
user unable to give the input for stack operations
d)
space allocation for array is fixed and cannot be changed during run-time
95.
Choose the method provided to change an element in Linked List
a)
add()
b)
set()
c)
insert()
d)
update()
96.
Heap exhibits the property of a binary tree?
a)
True
b)
False
97.
What is the time complexity to count the number of elements in the linked list?
a)
O(n)
b)
O(logn)
c)
O(1)
d)
O(n^2)
98.
Given an array of element 5, 7, 9, 1, 3, 10, 8, 4. Which of the following are the correct sequences of elements after inserting all the elements in a min-heap?
a)
1,3,4,5,8,7,9,10
b)
1,3,7,4,8,5,9,10
c)
1,3,4,5,7,8,9,10
d)
1,4,3,9,8,5,7,10
99.
A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as _____________
a)
Queue
b)
Linked list
c)
Stack
d)
Tree
100.
What is the time complexity for removing the first element of Linked List?
a)
O(Nˆ2)
b)
O(N)
c)
O(logN)
d)
O(1)
101.
What will be the output of the following recursive pseudocode?
class Main(a, b)
{
if (a == b)
{
return 2;
}
return a + Main(a - 1, b);
}
class ForRecursion {
out = 15;
for (int i = 4; i< 6; i++)
{ for (int j = 7; j >= 5; j --)
{ if (i == j) continue;
if (i > j)
{ out will be incremented by main (i, j); }
else { out will be incremented by main (j, i);
}
}
}
}
a)
compilation error
b)
Goes into infinite loop
c)
out = 100
d)
out = 80
e)
out = 78
102.
Given the following adjacency matrix of a graph(G) determine the number of components in the G.
[0 1 1 0 0 0],
[1 0 1 0 0 0],
[1 1 0 0 0 0],
[0 0 0 0 1 0],
[0 0 0 1 0 0],
[0 0 0 0 0 0].
a)
3
b)
1
c)
2
d)
4
103.
What would be the number of zeros in the adjacency matrix of the given graph?
a)
0
b)
10
c)
6
d)
16
104.
The time complexity to calculate the number of edges in a graph whose information in stored in form of an adjacency matrix is ___________
a)
O(V2)
b)
O(E2)
c)
O(E)
d)
O(V)
105.
In which case adjacency list is preferred in front of an adjacency matrix?
a)
Sparse graph
b)
Complete graph
c)
Dense graph
d)
Adjacency list is always preferred
106.
Can a constant time algorithm have loops or recursive calls?
a)
Yes, but only if the number of iterations or calls is independent of the input size
b)
No, it is not possible
c)
Yes, but only if the number of iterations or calls is proportional to the input size
d)
Yes, but only if the number of iterations or calls is greater than the input size
107.
When you run a program, the computer creates a _______ for you
a)
map
b)
queue
c)
recursion
d)
stack
108.
Which time complexity grows as log of size of one of its inputs?
a)
Linear time complexity
b)
Exponential time complexity
c)
Constant time complexity
d)
Logarithmic time complexity
109.
Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________
a)
Crash
b)
Overflow
c)
Underflow
d)
User flow
110.
What is the time complexity for removing the last element of LinkedList?
a)
O(Nˆ2)
b)
O(N)
c)
O(logN)
d)
O(1)
111.
A variable that stores the address of the first node of the linked list is called?
a)
Node
b)
Tail
c)
Next
d)
Head
112.
2. What is the best case complexity in building a heap?
a)
O(n2)
b)
O(nlogn)
c)
O(n*longn *logn)
d)
O(n)
113.
What is the time complexity of inserting at the end in dynamic arrays?
a)
O(logn)
b)
Either O(1) or O(n)
c)
O(n)
d)
O(1)
114.
In a stack, if a user tries to remove an element from an empty stack it is called _________
a)
Empty collection
b)
Overflow
c)
Garbage Collection
d)
Underflow
115.
What will be printed when the following code executes?
ArrayList< Integer> arrayList = new ArrayList<Integer>();
arrayList.add(7);
arrayList.add(8);
arrayList.add(9);
System.out.println(arrayList.remove(0));
a)
8
b)
0
c)
9
d)
7
116.
How many sub arrays does the quick sort algorithm divide the entire array into?
a)
One
b)
Four
c)
Two
d)
Three
117.
Which of the following is not true about QuickSort?
a)
in-place algorithm
b)
can be implemented as a stable sort
c)
pivot position can be changed
d)
adaptive sorting algorithm
118.
What is a hash function?
a)
A function that creates an array
b)
A function has allocated memory to keys
c)
A function that computes the location of the values in the array
d)
A function that computes the location of the key in the array
119.
Which of the following is not a stable sorting algorithm?
a)
Bubble sort
b)
Merge sort
c)
Quick sort
120.
Quick sort is a stable sorting algorithm.
a)
True
b)
False
121.
What is the average running time of a quick sort algorithm?
a)
O(N log N)
b)
O(N2)
c)
O(log N)
d)
O(N)
122.
If several elements are competing for the same bucket in the hash table, what is it called?
a)
Collision
b)
Diffusion
c)
Duplication
d)
Replication
123.
What is the worst case time complexity of merge sort?
a)
O(n2 log n)
b)
O(n2)
c)
O(n log n2)
d)
O(n log n)
124.
Which is the correct code to acess the second node in a linked list?
a)
none of the above
b)
head.getData()
c)
head.hasNext().getNext().getData()
d)
head.getNext().getData()
125.
If A[x+3][y+5] represents an adjacency matrix, which of these could be the value of x and y.
a)
x=3, y=5
b)
x=3, y=3
c)
x=5, y=5
d)
x=5, y=3
126.
Time complexity to find if there is an edge between 2 particular vertices is _________
a)
O(E)
b)
O(V)
c)
O(1)
d)
O(V+E)
127.
Which of these adjacency matrices represents a simple graph?
a)
[ [0, 0, 1], [1, 0, 1], [1, 0, 0] ]
b)
[ [1, 0, 0], [0, 1, 0], [0, 1, 1] ]
c)
[ [1, 1, 1], [1, 1, 1], [1, 1, 1] ]
d)
[ [0, 0, 1], [0, 0, 0], [0, 0, 1] ]
128.
Which traversal algorithm is typically implemented using a queue data structure?
a)
Neither BFS nor DFS
b)
DFS & BFS
c)
BFS
d)
DFS
129.
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)
5
b)
7
c)
The method never returns due to infinite recursion.
d)
4
e)
6
130.
We can use the following algorithm to see if a numerical value exists in an array. The algorithm will find the first place where the number exists and return its index. What is the Big O runtime of this algorithm? function findFirstIndexOfNumber(number, array) { for (let i = 0; i < array.length; i++) { if (array[i] === number) { return i;}}return -1}
a)
O(logn)
b)
O(nlogn)
c)
O(n)
d)
O(1)
131.
What is the limitation of calling recursion?
a)
limit of the heap memory
b)
500 calls
c)
No limits
d)
limit should be specified in recursion
132.
Following the law of addition in Big-O notation, what is the result of the following expression? log n − 100
a)
O(logn)
b)
O(n^2)
c)
O(n)
d)
O(1)
133.
True or False? Run time of algorithms is expressed in Big O notation.
a)
False
b)
True
134.
Which time complexity is independent of input?
a)
Exponential time complexity
b)
Logarithmic time complexity
c)
Linear time complexity
d)
Constant time complexity
135.
Following the law of addition in Big-O notation, what is the result of the following expression? 100n^2 + 3n*log n
a)
O(1)
b)
O(n)
c)
O(n^2+logn)
d)
O(n^2)
136.
What is the worst case time complexity of the binary tree sort?
a)
O(n2)
b)
O(n)
c)
O(logn)
d)
O(nlogn)
137.
What is the typical running time of a heap sort algorithm?
a)
O(log N)
b)
O(N log N)
c)
O(N)
d)
O(N2)
138.
If we implement heap as maximum heap , adding a new node of value 15 to the left most node of right subtree. What value will be at leaf nodes of the right subtree of the heap.
a)
15 and 1
b)
3 and 1
c)
25 and 1
d)
2 and 3
139.
The Breadth First Search Algorithm has been implemented using a queue data structure. Which one of the following is a possible order of visiting the nodes in the graph below?
a)
QMNROP
b)
NQMPOR
c)
MNOPQR
d)
POQNMR
140.
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?
a)
Y will always be a better choice for small inputs
b)
X will always be a better choice for all inputs
c)
X will always be a better choice for small inputs
d)
X will always be a better choice for large inputs
141.
Which time complexity denotes an algorithm whose growth is increasing exponentially (doubles in most cases) with each addition to the input data set?
a)
Linear time complexity
b)
Constant time complexity
c)
Exponential time complexity
d)
Logarithmic time complexity
142.
Quick Sort can be categorized into which of the following?
a)
Greedy algorithm
b)
Brute Force technique
c)
Divide and conquer
d)
Dynamic programming
143.
Quick sort uses join operation rather than merge operation.
a)
True
b)
false
144.
Which of the following sorting algorithms can be considered as improvement to the binary tree sort?
a)
Heap sort
b)
Selection sort
c)
Insertion sort
d)
Quick sort
145.
Data structure which works best for data manipulation?
a)
Array
b)
ArrayList
c)
HashTable
d)
LinkedList
146.
True or False? Big- notation of the following expression is eqal to linear complexity O(n)+O(n*n)=O(n)
a)
False
b)
True
147.
In binary tree sort, we first construct the BST and then we perform _______ traversal to get the sorted order.
a)
Preorder
b)
Inorder
c)
Postorder
d)
level order
148.
What is the average case time complexity of merge sort?
a)
O(n2)
b)
O(n log n)
c)
O(n2 log n)
d)
O(n log n2)
149.
Complete the given snippet of code for the adjacency list representation of a weighted directed graph.
class neighbor
{
int vertex, weight;
____ next;
}
class vertex
{
string name;
_____ adjlist;
}
vertex adjlists[101];
a)
vertex, vertex
b)
neighbor, neighbor
c)
vertex, neighbor
d)
neighbor, vertex
150.
True or False? Order of growth does not ignore leading coefficients
a)
True
b)
False
151.
Merge sort is preferred for arrays over linked lists.
a)
false
b)
True
152.
Can a program have loops or recursive calls and still have time complexity that is constant?
a)
No, loops or recursive calls always increase time complexity
b)
None of the above
c)
Yes, as long as the loops or recursive calls have a constant number of iterations or calls
d)
It depends on the type of inputs the program receives
153.
For a given graph G having v vertices and e edges which is connected and has no cycles, which of the following statements is true?
a)
v=e
b)
v + 1 = e
c)
v = e-1
d)
v = e+1
Reset
