Data Structure and Algorithms MCQs on Data Structures, Abstract Data Types, and Applications , Analysis Tools, Experimental Analysis, Asymptotic Notation, Asymptotic Analysis, Arrays , Arrays, Lists (Singly Linked List, Doubly Linked List), Stacks Stacks, Queues , Trees, Foundations, Tree Traversals, Binary Trees , Binary Search Trees (BST): Basics, BST Analysis . Balanced Binary Trees, AVL Trees , Red-Black Trees (optional) Hash Tables: Hash Functions, Hash Tables, Chaining, Open Addressing , Priority Queues, Binary Heaps , Heaps, Binary Heaps, HeapSort , Sorting, Insertion Sort, Selection Sort, Merge sort , Quicksort, Bucket-Sort, Radix-Sort (optional) , Data Compression, Huffman Coding , Tries , Standard, Compressed, Suffix Tries , Data Structures for Graphs , Depth First Search, Breadth First Search , Weighted Graphs: Minimum Spanning Trees, Topological Sort , Directed Graphs, Connected Components , Shortest-Path Algorithms, Dijkstra’s Algorithm , Network Flow Problem, Advanced DS: Distributed Hash Tables ,Bloom Filters, Memory Locality, Parallel Algorithms
Data Structure and Algorithms MCQs
If s = 67 is an integer variable and its address is saved in pointer variable t. In how many ways we can display value of p.
A. cout<<*s
B. cout<<t
C. cout<<*t
D. None of above
View Answer
Which of the following statement(s) about a pointer variable is/are FALSE.
A. Pointer variable has ability to save both the data and address
B. Pointer variable saves address only
C. Pointer variable saves data only
D. Both A and C
View Answer
Consider the following code. What will be the output.
int *ptr
int x[2] = {56, 57}
ptr = &x[1]
cout<<*(ptr) + 2 << *(ptr – 1).
A. 57, 56
B. 57, 57
C. 59, 56
D. 56, 57
View Answer
What will the output of following code.
void main()
{
int a; /*Suppose address of a is 2048 */
int *b = &a
a = 10
*b = *b * 3
cout<<“value of a=”<<a<<”value by pointer is =”<<*b
}.
A. 30 30
B. 30 10
C. 10 10
D. 10 30
View Answer
What will be the output of following code.
int i = 10, j = 15
int *p = &i
j = *p + 4
cout<<*p + j.
A. 15
B. 9
C. 24
D. None of above
View Answer
Which operator are considered while computing cost of an algorithm.
A. Addition (+) operator
B. Assignment (=) operator
C. Comparison (==) operator
D. Both A and C
View Answer
Consider following algorithm. What will be its cost? Assume IF condition is TRUE.
ALGO ABC()
{
s = a * d
PRINT “MCS”
IF (s != 0 and b == 9)
{
j = j – 2 + s;
PRINT s
}
}.
A. 2
B. 4
C. 6
D. 5
View Answer
Compute the cost of following code. Assume IF condition is TRUE. Also add the cost when FOR loop is terminated.
FOR (i = 2 to 17)
IF (s == i)
answer = 0.
A. 20
B. 21
C. 10
D. 33
View Answer
What will be the cost of following group of statements.
a = 65 + a % 3
s = a * 3
PRINT s + 9.
A. 6
B. 3
C. 4
D. All of above
View Answer
Read Also >>Theory of Automata MCQs
Can we swap the values of two pointer variable without using third variable.
A. TRUE
B. FALSE
View Answer
Which of the following code multiply the numbers of the array a[10] having some integer values.
A. s = 1
for (i = 0; i <= 9 i++)
s = a[i] * a{i+1]
B. s = 0
for (i = 0; i <= 9 i++)
s = s * a[i]
C. s = 1
for (i =0; i <= 9 i++)
s = s * a[i]
D. None of above
View Answer
Consider an array arr[5] and a pointer variable ptr. Which of the following C statement about saving address of last location of array in pointer is correct.
A. ptr = arr
B. ptr = &arr[3]
C. ptr = arr[5]
D. ptr = &arr[4]
View Answer
Which of the following is the major advantage of arrays over link list?
A. Arrays have contiguous locations while link list is collection of non-contiguous nodes
B. Arrays has limited space for storing objects as compared to link list
C. Arrays has single name as compared with link list
D. Both A and C
View Answer
How do you initialize a character array in C.
A. char arr[5] = (“array”)
B. char arr(5) = {“array”}
C. char arr[5] = “array”
D. char arr(5) = (a, r, r, a, y)
View Answer
Assuming float is of 4 bytes, what is the size of float arr[15].
A. 10 bytes
B. 15 bytes
C. 50 bytes
D. 30 bytes
View Answer
In link list, the elements are accessed in ______ order.
A. Ascending order
B. Sequential order
C. Random order
D. Both A and B
View Answer
In stack which operation is used to delete an element from the top.
A. Push operation
B. Delete operation
C. Pop operation
D. None of above
View Answer
Which of the following operations can be applied on Binary Tree.
A. Delete the node
B. Insert the node
C. Traverse the tree
D. All of above
View Answer
Which of the sorting algorithm works better on sorting the array having the elements in opposite order.
A. Quick Sort
B. Binary Search
C. Insertion Sort
D. Selection Sort
View Answer
Which of the following is NOT the searching algorithm.
A. Insertion sort
B. Selection sort
C. Quick sort
D. All of above
View Answer
The bubble sort algorithms works on which of the following techniques.
A. It compares the adjacent elements throughout the array and swaps them if they are in wrong order
B. It sorts the array by repeatedly finding the minimum element and place in its exact position
C. It sorts the array by dividing the array and then merge these elements by placing then in correct order
D. None of above
View Answer
How many times the loop will run, also include when loop terminates.
for (j = 43 to 16)
j = j + 2.
A. 14 times
B. 15 times
C. 16 times
D. 43 times
View Answer
Which of the data structure works in LIFO order.
A. Stacks
B. Queues
C. Arrays
D. Link list
View Answer
Deleting an element from an empty queue, then queue becomes.
A. Overflow
B. Crash
C. Underflow
D. All of above
View Answer
If the elements ‘I’, ‘J’, ‘M’ and ‘N’ are inserted in a stack and are removed one by one, what will be the order of the elements that were removed.
A. I J M N
B. N M I J
C. N M J I
D. N J I M
View Answer
In data structure, the queue uses ____ operation to insert element.
A. Enqueue
B. Push
C. Dequeue
D. None of above
View Answer
Number of comparison needed to sort 10 elements using Bubble Sort are
A. 20
B. 30
C. 80
D. 45
View Answer
What are the properties of multi graphs.
A. The graphs having multiple edges only
B. The graphs having disconnected vertices
C. The graphs having loops on the vertices
D. None of above
View Answer
Every tree is a graph but every graph is not a tree. True or False.
A. TRUE
B. FALSE
View Answer
In graphs, cyclic path is defined as.
A. Sequences of vertices from one vertex to other vertex with no repeating vertex
B. Sequences of vertices from one vertex to other vertex with repeating vertex
C. A subset of the edges making a path such that the first node of the path corresponds to the last
D. None of above
View Answer
Adjacency matrix is used to represent ________ in computer system.
A. Link list.
B. Array.
C. Graph.
D. Both A and B.
View Answer
What is the difference between Graph and Tree.
A. Graph may have cyclic path but tree must not have cyclic path
B. Graph may have some disconnected vertices but tree must have all vertices connected
C. Graph must have two child nodes at every node
D. Both A and B
View Answer
Maximum height of nodes in binary tree of height h are.
A. 3h + 1
B. 2h + 1
C. 2h – 1
D. 2h
View Answer
What is the correct order of Pre-order traversal of Binary tree
A. Right subtree, left subtree, root
B. Left subtree, Right subtree, root
C. Root, Left subtree, Right subtree
D. Left subtree, Root, Right subtree
View Answer
Which of the following is the postfix notation of (A + B) * C.
A. ABC*+
B. AB*C+
C. AB+C*
D. *+ABC
View Answer
Which of the following is the correct representation of A + B * C/ (E -F) in to prefix.
A. +A/*BC-EF-
B. +AB*C-EF/
C. +AB-EF*C/
D. None of above
View Answer
Which traversal of BST gives the root at the start of traversal.
A. Post order
B. Pre-Order
C. Depth First
D. Inorder
View Answer
Which data structure is used to save the visited vertices in the procedure of Depth First Search (DFS) of tree or graph.
A. Stack
B. Queue
C. Array
D. Both A and C
View Answer
What is the cost of following code? Also include the cost when for loop terminates.
for (j = 10 to 5) //suppose increment is 1
PRINT j
}
A. 5
B. 9
C. 6
D. 11
View Answer
What is the cost of following code? Also include the cost when for loop terminates.
for (j = 98 to 1)
{
PRINT j
j = j – 2
}.
A. 98
B. 100
C. 49
D. 50
View Answer
Which of the following are disadvantages of using link list.
A. Slow insertion and deletion
B. Memory wastage
C. Quick access
D. Both A and B
View Answer
What are the disadvantages of pointer variables.
A. Memory wastage
B. Unallocated pointer variables may cause problem
C. Adjacent location of nodes in memory
D. Both A and B
View Answer
If character takes 2 bytes of memory, what will be the maximum positive value stored in integer.
A. 127
B. 128
C. 129
D. -127
View Answer
Assigning float type address to integer type pointer will give
A. Compile error
B. Run time error
C. Syntax error
D. None of above
View Answer
If we add and integer and a float data, and store the sum in an integer variable, what will happen.
A. Overflow
B. Underflow
C. Memory wastage
D. Syntax error
View Answer
Read More >> Digital logic Design MCQs