Objective Questions-CP-II
Objective Questions-CP-II
UNIT-I
1. What is the GCD of a and b?
a) a + b
b) gcd (a-b, b) if a>b
c) gcd (a+b, a-b)
d) a – b
2. If gcd (a, b) is defined by the expression, d=a*p + b*q where d, p, q are positive integers
and a, b is both not zero, then what is the expression called?
a) Bezout’s Identity
b) Multiplicative Identity
c) Sum of Product
d) Product of Sum
3. What is the total running time of Euclid’s algorithm?
a) O(N)
b) O(N log M)
c) O(N log N)
d) O(log N +1)
6. Which of the following algorithms has better computational complexity than standard
division algorithms?
a) Montgomery algorithm
b) Classical modular exponentiation algorithm
c) ASM algorithm
d) FSM algorithm
7. The time complexity to perform the modular exponentiation of a ≡ cg (mod m).
a) O(m+a)
b) O(a*g)
c) O(gm)
d) O(g)
#include <stdio.h>
int ETF(int n)
int a, result = n;
if (n % a == 0)
while (n % a == 0)
n = n / a;
result = result - result / a;
if (n > 1)
return result;
int main()
int n;
printf("%d\n", ETF(n));
return 0;
a) 0 1 2 3
b) 0 1 2 4
c) 1 1 2 2
d) 1 2 3 4
12. The Euclid’s algorithm runs efficiently if the remainder of two numbers is divided by the
minimum of two numbers until the remainder is zero.
a) True
b) False
13. Which of the following is the correct mathematical application of Euclid’s algorithm?
a) Determination of prime numbers
b) Lagrange’s four square theorem
c) Cauchy-Euler theorem
d) Residue theorem
UNIT- 2
1) To insert a new node in linked list free node will be available in ........
A. Available list
B. Avail list
C. Free node list
D. Memory space list
2) A singly linked list is also called as ........
A. linked list
B. one way chain
C. two way chain
D. right link
3) A ..... list is a header list where the node points back to the header node.
A. Circular header
B. Grounded header
C. Two way header
D. One way header
4) .......... may take place only when there is some minimum amount(or) no space left in free
storage list.
A. Memory management
B. Garbage collection
C. Recycle bin
D. Memory management
5) A linear list in which the last node points to the first node is ........
Sub: DSU MCQ on Unit-4 Linked List
A. singly linked list
B. circular linked list
C. doubly linked list
D. none of the above
6) What is the time complexity to count the number of elements in the linked list?
A. O(1)
B. O(n)
C. O(logn)
D. O(n2)
7) What is the space complexity for deleting a linked list?
A. O(1)
B. O(n)
C. O(logn)
D. O(n2)
8) Which of these is not an application of a linked list?
A. To implement file systems
B. For separate chaining in hash-tables
C. To implement non-binary trees
D. Random Access of elements
9) What differentiates a circular linked list from a normal linked list?
A. You cannot have the 'next' pointer point to null in a circular linked list
B. It is faster to traverse the circular linked list
C. You may or may not have the 'next' pointer point to null in a circular linked list
D. All of the mentioned
10) In a circular linked list:-
a) Components are all linked together in some sequential manner.
b) There is no beginning and no end.
c) Components are arranged hierarchically.
d) Forward and backward traversal within the list is permitted.
11. A linear collection of data elements where the linear node is given by
means of pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) None
12. Which of the following operations is performed more efficiently by doubly linked list
than by singly linked list?
a) Deleting a node whose location in given
b) Searching of an unsorted list for a given item
c) Inverting a node after the node with given location
d) Traversing a list to process each node
13. Consider an implementation of unsorted singly linked list. Suppose it has its
representation with a head and tail pointer. Given the representation, which of
the following operation can be implemented in O(1) time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list
a) I and II
b) I and III
c) I,II and III
d) I,II and IV
14. In linked list each node contain minimum of two fields. One field is data field to store the
data second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
15. The concatenation of two list can performed in O(1) time. Which of the following
variation of linked list can be used?
a) Singly linked list
b) Doubly linked list
c) Circular doubly linked list
d) Array implementation of list
16. Consider the following definition in c programming language
struct node
{
int data;
struct node * next;
}
typedef struct node NODE;
NODE *ptr;
Which of the following c code is used to create new node?
a) ptr=(NODE*)malloc(sizeof(NODE));
b) ptr=(NODE*)malloc(NODE);
c) ptr=(NODE*)malloc(sizeof(NODE*));
d) ptr=(NODE)malloc(sizeof(NODE));
17. A variant of linked list in which last node of the list points to the first node
of the list is?
a) Singly linked list c) Circular linked list
b) Doubly linked list d) Multiply linked list
UNIT-III
1. What is the worst case complexity of bubble sort?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
2. Which of the following is not an advantage of optimised bubble sort over other
sorting techniques in case of sorted elements?
a) It is faster
b) Consumes less memory
c) Detects whether the input is already sorted
d) Consumes less time
11. Find the pivot element from the given input using median-of-three partitioning
method.
8, 1, 4, 9, 6, 3, 5, 2, 7, 0.
a) 8
b) 7
c) 9
d) 6
12. Which of the following sorting techniques is most efficient if the range of input data
is not significantly greater than a number of elements to be sorted?
a) selection sort c) counting sort
b) bubble sort d) insertion sort
13. Which of the following sorting techniques is stable?
a) quick sort
b) counting sort
c) heap sort
d) selection sort
14. What is the best case and worst case complexity of ordered linear search?
a) O(nlogn), O(logn)
b) O(logn), O(nlogn)
c) O(n), O(1)
d) O(1), O(n)
15. Binary Search can be categorized into which of the following?
a) Brute Force technique
b) Divide and conquer
c) Greedy algorithm
d) Dynamic programming
Unit –IV
1. In a stack, if a user tries to remove an element from an empty stack it is called
_________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
2. Pushing an element into stack already having five elements and stack size of 5, then
stack becomes ___________
a) Overflow
b) Crash
c) Underflow
d) User flow
3. Entries in a stack are “ordered”. What is the meaning of this statement?
a) A collection of stacks is sortable
b) Stack entries may be compared with the ‘<‘ operation
c) The entries are stored in a linked list
d) There is a Sequential entry that is one by one
4. Which of the following is not the application of stack?
a) A parentheses balancing program
b) Tracking of local variables at run time
c) Compiler Syntax Analyzer
d) Data Transfer between two asynchronous process
#define MAX 10
int top;
int item[MAX];
} stack;
if(s->top == -1)
return 1;
else return 0;
a) full stack
b) invalid index
c) empty stack
d) infinite stack
if(isEmpty())
return first.getEle();
a) pop
b) delete the top-of-the-stack element
c) retrieve the top-of-the-stack element
d) push operation
12. Which of the following data structures can be used for parentheses matching?
a) n-ary tree
b) queue
c) priority queue
d) stack
UNIT – V
2. Which of the following is not the algorithm to find the minimum spanning tree of
the given graph?
a) Boruvka’s algorithm
b) Prim’s algorithm
c) Kruskal’s algorithm
d) Bellman–Ford algorithm
3. Consider the graph shown below. Which of the following are the edges in the
MST of the given graph?
a) (a-c)(c-d)(d-b)(d-b)
b) (c-a)(a-d)(d-b)(d-e)
c) (a-d)(d-c)(d-b)(d-e)
d) (c-a)(a-d)(d-c)(d-b)(d-e)
10. What is the average case time complexity for finding the height of the binary tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
11. In a full binary tree if number of internal nodes is I, then number of nodes N are?
a) N = 2*I
b) N = I + 1
c) N = I – 1
d) N = 2*I + 1
12. Which of the following is incorrect with respect to binary trees?
a) Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level
k
b) Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes
c) Let T be a binary tree with N nodes. Then the number of levels is at least
ceil(log (N + 1))
d) Let T be a binary tree with N nodes. Then the number of levels is at least
floor(log (N + 1))
13. Figure below is a balanced binary tree. If a node inserted as child of the node R,
how many nodes will become unbalanced?
a) 2
b) 1
c) 3
d) 0
UNIT – VI
1. Which of the following is/are property/properties of a dynamic programming
problem?
a) Optimal substructure
b) Overlapping subproblems
c) Greedy approach
d) Both optimal substructure and overlapping subproblems
7. Suppose you have coins of denominations 1, 3 and 4. You use a greedy algorithm,
in which you choose the largest denomination coin which is not greater than the
remaining sum. For which of the following sums, will the algorithm NOT produce
an optimal answer?
a) 20
b) 12
c) 6
d) 5
8. Suppose you have coins of denominations 1,3 and 4. You use a greedy algorithm,
in which you choose the largest denomination coin which is not greater than the
remaining sum. For which of the following sums, will the algorithm produce an
optimal answer?
a) 14
b) 10
c) 6
d) 100
12. The 0-1 Knapsack problem can be solved using Greedy algorithm.
a) True
b) False