Font size
WorksheetsDAA Tutorial-1
Total questions: 70
Worksheet time: 36mins
Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1?
T(1) = 2T (n/2) + log n
θ(n)
θ(n logn)
θ(n2)
θ(logn)
The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:
θ(n logn), θ(n logn),θ(n2)
θ(n2),θ(n2), θ(nlogn)
θ(n2), θ(n logn), θ(n logn)
θ(n2), θ(n logn),θ(n2)
To main measures of the efficiency of an algorithm are?
time and space complexity
data and space
processor and memory
complexity and capacity
Which of the following data structure is used to perform recursion?
linked list
stack
array
queue
Identify the best case time complexity of selection sort?
O(nlogn)
O(n^2)
O(n)
O(1)
What is the time complexity of the binary search algorithm?
O(log(2n))
O(n)
O(1)
O(n^2)
Algorithm can be represented as
Pseudocode
Flowchart
Flowchart & Pseudocode
none
Alorithm should have finite number of steps
True
False
sometimes
none
which is not the important aspect of Loop
Initial condition
nested loop
invariant relation
termination
What is time complexity of fun()?
int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count += 1;
return count;
}
O(n2)
O(nLogn)
O(n)
O(nLognLogn)
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4?
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = nLogn
f4(n) = n^(Logn)
f3, f2, f4, f1
f3, f2, f1, f4
f2, f3, f1, f4
f2, f3, f4, f1
This characteristic describes whether the data items are arranged in chronological sequence, such as with an array, or in an unordered sequence, such as with a graph.
Static or dynamic
Linear or non-linear
Homogeneous or non-homogeneous
It is a method of solving problems that involves breaking a problem down into smaller and smaller sub problems until you get to a small enough problem that it can be solved trivially.
Recursion
Iteration
Looping
In this type of search, a sequential search is made over all items one by one.
Search
Binary Search
Linear Search
It is used to implement an associative array, a structure that can map keys to values.
linked list
hashing
trees
array
It is a linear data structure that stores a collection of elements. Operates on first in first out (FIFO) algorithm.
stack
data structure
queue
array
push() and pop() functions are found in..
stacks
trees
queues
lists
How is an array initialized in C language?
int a[3] = {1, 2, 3};
int a = {1, 2, 3};
int a[] = new int[3]
int a(3) = [1, 2, 3];
Which of the following is not the type of queue?
Priority queue
Single-ended queue
Circular queue
Ordinary queue
What will the output of the following code snippet?
void solve() {
int a[] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++) {
if(i % 2 == 0) {
sum += *(a + i);
}
else {
sum -= *(a + i);
}
}
cout << sum << endl;
}
15
syntax error
3
2
How are String represented in memory in C?
LinkedList of characters.
The object of some class.
An array of characters.
Same as other primitive data types.
In Binary trees nodes with no successor are called......
Final nodes
Last nodes
Terminal nodes
End nodes
The operation of processing each element in the list is known as
Inserting
Traversal
Merging
Sorting
In ........, search start at the beginning of the list and check every element in the list.
Binary Search
Binary Tree Search
Hash Search
Linear Search
Any node is the path from the root to the node is called
Ancestor node
Internal node
Successor node
None of the above
A graph is a tree if and only if graph is
Directed graph
Contains no cycles
Planar
Completely connected
A graph in which all vertices have equal degree is known as __
Simple graph
Multi graph
Regular graph
Complete graph
Which of following data structure is more appropriate for
implementing quick sort iteratively?
Deque
Priority queue
Stack
Queue
If two trees have same structure and node content, then they are
called __
Equivalent trees
Synonyms trees
Similar trees
Joint trees
Which of the following is not the type of queue?
Ordinary queue
Single and queue
Circular queue
Priority queue
Finding the location of a given item in a collection of items is called ……
Discovering
Mining
Finding
Searching
Linked list are not suitable data structure of which one of the following problems ?
Insertion sort
Binary search
Polynomial manipulation
Radix sort
What is the worst case time complexity of merge sort?
O(n log n)
O(n2)
O(n2 log n)
O(n log n2)
If a problem can be solved by combining optimal solutions to non-overlapping problems, the strategy is called _____________
Dynamic programming
Greedy
Divide and conquer
Recursion
........................... , ........................ and ...........................are the different ways in which an algorithm can be specified.
Asymptotic Notations, Flowchart, Pseudocode
English like statements, Flowchart, Pseudocode
English like statements,Sets, Pseudsocode
None of the above
Algorithm can be represented graphically using...........................
barchart
Graph
Pie chart
Flowchart
..............................is defined as the amount of Computer time required to complete the execution of a program/problem
Space Complexity
Time complexity
CPU Time
None of these
Upper bound running time complexity of an algorithm is also called as.....................
Best case time complexity
Worst case time complexity
Average case time complexity
None of these
Lower bound running time complexity of an algorithm is also called as.................
Best case time complexty
Worst case time complexity
Average case time complexity
None of these
............................Notation is used to represent strict upper bound running time complexity of an algotihm
Big-oh
Big-Omega
Theta
None of these
........................................Notations are called as Asymptotic Notations.
Big-oh
Big-Omega
little-Theta
little-oh
theta
Let f(n) and g(n) be two non-negative functions,f(n)=O(g(n)) if and only if..........................
f(n)<=c*g(n)
f(n)>=c*g(n)
f(n)<c*g(n)
f(n)<c*g(n)
Let f(n) and g(n) be two non-negative functions,f(n)= ω (g(n)) if and only if..........................
f(n)<=c*g(n)
f(n)>=c*g(n)
f(n)<c*g(n)
f(n)<c*g(n)
Let f(n) and g(n) be two non-negative functions,f(n)= θ (g(n)) if and only if..........................
c1*g(n)<=f(n)<=c2*g(n)
c1*g(n)>=f(n)>=c2*g(n)
c1*g(n)<f(n)<c2*g(n)
c1*g(n)>f(n)>c2*g(n)
...................................are the characteristics of an algorithm
Input
infiniteness
Effectiveness
output
finiteness
Find the time complexity for the following algorithm using step count method.
Algorithm sum(a,n)
{
nsum=0;
for(i=1;i<=n;i++)
{
nsum=nsum+a[i];
}
}
2n+2 units
2n+1 units
n+1 units
n+2 units
The worst case running time of shell sort, using Shell’s increments is?
O(N)
O(N log N)
O(log N)
O(N2)
On how many increment sequences does the worst case analysis of shell sort depends?
1
2
3
4
Shell sort is an improvement on ____
insertion sort
selection sort
binary tree sort
quick sort
On which algorithm is heap sort based on?
Fibonacci heap
Binary tree
Priority queue
FIFO
In what position does the array for heap sort contains data?
0
1
-1
Anywhere
Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)?
Both execute at same speed
Linear search(recursive) is faster
Linear search(Iterative) is faster
Cant be said
Is the space consumed by the linear search(recursive) and linear search(iterative) same?
No, recursive algorithm consumes more space
No, recursive algorithm consumes less space
Yes
Nothing can be said
Linear search(recursive) algorithm used in _____________
When the size of the dataset is low
When the size of the dataset is large
When the dataset is unordered
Never used
The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm)
3rd call
4th call
6th call
5th call
What is the advantage of recursive approach than an iterative approach?
Consumes less memory
Less code and easy to implement
Consumes more memory
More code has to be written
Which of the following is not an application of binary search?
To find the lower/upper bound in an ordered sequence
Union of intervals
Debugging
To search in unordered list
Binary Search can be categorized into which of the following?
Brute Force technique
Divide and conquer
Greedy algorithm
Dynamic programming
Which of the following method is used for sorting in merge sort?
merging
partitioning
selection
exchanging
Which of the following is not a variant of merge sort?
in-place merge sort
bottom up merge sort
top down merge sort
linear merge sort
is a recursive algorithm that continually splits a list in half. If the list is empty or has one item, it is sorted by definition (the base case).
Shell Sort
Merge Sort
Quick Sort
Can we divide problem into more than 2 sub problems?
Yes
No
In a stack, if a user tries to remove an element from empty stack it is called _________
Underflow
Empty collection
Overflow
Garbage Collection
Process of inserting an element in stack is called ____________
Create
Push
Evaluation
Pop
Consider the usual algorithm for determining whether a sequence of parentheses is balanced.
Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).
The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?
1
2
3
4 or more
User perform following operations on stack of size 5 then -
push(1);
pop();
push(2);
push(3);
pop();
push(2);
pop();
pop();
push(4);
pop();
pop();
push(5);
Overflow Occurs
Stack Operations will be performed Smoothly
Underflow Occurs
None of these
What is the value of the postfix expression 6 3 2 4 + – *
1
40
74
-18
To evaluate an expression without any embedded function calls:
One stack is enough
Two stacks are needed
As many stacks as the height of the expression tree are needed
A Turing machine is needed in the general case
Which one of the following is an application of Stack Data Structure?
Managing function calls
The stock span problem
Arithmetic expression evaluation
All of the above
