340+ Data Structure and Algorithms (DSA) Solved MCQs

134
80.8k
1.

A. true, false
B. false, true
C. true, true
D. false, false
2.

A graph is said to be complete if there is no edge between every pair of vertices.

A. true, false, true
B. true, true, false
C. true, true, true
D. false, true, true
3.

Space Complexity iii) Is the strategy guaranteed to find the solution when there in one.

A. a-iii, b-ii, c-i
B. a-i, b-ii, c-iii
C. a-iii, b-i, c-ii
D. a-i, b-iii, c-ii
4.

A. true, false
B. false, true
C. false, false
D. true, true
5.

A. true, true
B. false, true
C. false, false
D. true, false
6.

To find the predecessor, it is required to traverse the list from the first node in case of singly linked list.

A. i-only
B. ii-only
C. both i and ii
D. none of both
Answer» C. both i and ii
7.

A. true, true
B. true, false
C. false, true
D. false, false
8.

A. true, true
B. true, false
C. false, true
D. false, false
9.

Insertion b) Deletion c) Retrieval d) Traversal

A. only a,b and c
B. only a and b
C. all of the above
D. none of the above
Answer» D. none of the above
10.

A. true, false
B. false, true
C. true, true
D. false, false
11.

The complexity of the average case of an algorithm is

A. much more complicated to analyze than that of worst case
B. much more simpler to analyze than that of worst case
C. sometimes more complicated and some other times simpler than that of worst case
D. none or above
Answer» A. much more complicated to analyze than that of worst case
12.

The Average case occur in linear search algorithm

A. when item is somewhere in the middle of the array
B. when item is not in the array at all
C. when item is the last element in the array
D. when item is the last element in the array or is not there at all
Answer» A. when item is somewhere in the middle of the array
13.

A. best case
B. worst case
C. average case
D. null case
14.

The space factor when determining the efficiency of algorithm is measured by

A. counting the maximum memory needed by the algorithm
B. counting the minimum memory needed by the algorithm
C. counting the average memory needed by the algorithm
D. counting the maximum disk space needed by the algorithm
Answer» A. counting the maximum memory needed by the algorithm
15.

The time factor when determining the efficiency of algorithm is measured by

A. counting microseconds
B. counting the number of key operations
C. counting the number of statements
D. counting the kilobytes of algorithm
Answer» B. counting the number of key operations
16.

Two main measures for the efficiency of an algorithm are

A. processor and memory
B. complexity and capacity
C. time and space
D. data and space
17.

A. float
B. local
C. character
D. non-local
18.

A. character
B. integer
C. float
D. numeric
19.

A. array
B. list
C. string
D. block
20.

A. null
B. binary
C. totalled
D. list
21.

C. bit
D. byte
22.

A. main strings
B. substring
C. index
D. block
23.

A. length
B. breath
C. width
D. none
24.

A. insertion
B. deletion
C. searching
D. replacement
25.

________ is the problem of deciding whether or not a given String pattern P appears in a text T.

A. pattern matching
B. searching
C. sorting
D. deletion
26.

A. node
C. variable
D. null
27.

A. node
C. variable
D. null
28.

A. dynamic
B. static
C. semi static
D. global
29.

In _______ storage, each cell is divided into two parts---- the path stores a single character, while the second part contains the address of the cell containing the next character.

A. fixed length
C. variable length
D. sequential
30.

A. insertion
B. deletion
C. concatenation
D. replacement
31.

A. dynamic
B. static
C. semi static
D. global
32.

B. array
C. pointer
D. stack
33.

A. linear array
B. pointer
D. tree
34.

A. upper bound
B. lower bound
C. size
D. variable
35.

A. size
B. index
C. variable
D. constant
36.

Which of the following items are not part of the array declaration?

A. name of the array
B. data type of the array
C. index set of the array
D. length of the array
Answer» D. length of the array
37.

A. dynamically
B. statically
C. successively
D. alternatively
38.

A. deleting
B. inserting
C. traversing
D. searching
39.

A. searching
B. sorting
C. traversing
D. inserting
40.

A. integer
B. boolean
C. matrix
D. real
41.

________ is a list in which the order of the items is significant, and the items are not necessarily sorted.

A. ordered list
B. indexed list
C. sequential list
D. unordered list
42.

A. row-major
B. row
C. column-major
D. column
43.

A. triangular
B. diagonal
C. sparse
44.

_______ arrays are where the elements in the different arrays with the same subscript belongs to the same record.

A. one dimensional
B. parallel
C. two dimensional
D. static
45.

A. dynamic
B. static
C. simple
D. parallel
46.

A. triangular
B. tridiagonal
C. sparse
D. simple
47.

Elements of of an arrays are accessed by

A. accessing fuction in built in data structure
B. mathematical fuction
C. index
D. none of the above
48.

Array is a

A. index data structure
B. non liturenear data structure
C. complx data structure
D. none of the above
Answer» D. none of the above
49.

Row -major order in two -dimentional array refers to an arrangement where

A. all elements of a row are stored in memory in sequence followed by next row in sequence,and so on
B. all elements of row are stored in memory in sequence followed by next column in sequence ,and so on
C. all elements of row are stored in memory in sequence followed by next column in sequence
D. none of the above
Answer» A. all elements of a row are stored in memory in sequence followed by next row in sequence,and so on
50.

Array is

A. data in physical order
B. data in logical order
C. both a& b
D. none of the above
Answer» A. data in physical order
51.

A. m
B. m^2
C. m(m+1)
D. m(m+2)
52.

A. all "0"
B. all "1"
C. both 0&1
D. different
53.

A. sorting
B. searching
C. function
D. complexity
54.

A. pointer
B. primary key
C. secondary key
D. function
55.

A. insertion
B. exchange
C. selection
D. deletion
56.

A. sequential
B. indexed
C. random
D. bubble
57.

A. tree
B. hash table
C. stack
D. graph
58.

_________ is a search for data that uses an index to locate the item.

A. binary search
B. sequential search
C. indexed search
D. jump search
59.

If the input array is unsorted, then only a linear ______ can be used.

A. binary search
B. sequential search
C. indexed search
D. jump search
60.

_______ is a attribute of a sort, indicating that data with equal keys maintain their relative input order in the output.

A. sort order
B. sort stability
C. sort efficiency
D. collision
61.

In ______ method of hashing, selected digit are extracted from the key and used as the address.

A. subtraction
B. digit extraction
C. rotation
D. folding
62.

________ hashing method is used in combination with other methods.

A. subtraction
B. digit extraction
C. rotation
D. division
63.

If two different keys yield the same hash address, it is called _______ .

A. binary search
B. sequential search
C. collision
D. rotation
64.

A. merge
C. shell
D. selection
65.

A. k-way
B. balanced
C. polyphase
66.

________ method of collision resolution involves maintaining two tables in memory.

A. linear probing
B. chaining
D. double hashing
67.

A. balanced
B. polyphase
D. k-way
68.

One of the statement is false

A. tree is an abstract data type
B. array is a linear data structure
C. typedef is derived data type
D. float is built in data type
Answer» C. typedef is derived data type
69.

Examples of sorting algorithms are

A. bubble sort
B. selection sort
C. insertion sort
70.

Give timing complexities of three sorting algorithms bubble sort,selection sort,insertion sort respectively.

A. 0(log n), 0(log n), o(log n)
B. o(n2), o(n2), o(n2)
C. o(n2), o(n log n), o(n log n)
D. o(n log n), o(n2), o(n log n)
71.

A. n
B. n-1
C. n+2
D. n-2
72.

Best and the worst case timing complexities of insertion sort are_________.

A. o(n2), o(n2)
B. o(n log n), o(n2)
C. o(n), o(n2)
D. o(n), o(n3)
73.

Which sorting algorithm can exploit the partially sorted data in a list?

A. bubble sort
B. selection sort
C. insertion sort
D. all of them
74.

Sorting is useful for_________

A. report genration
B. minimizing the storage needed
C. making searching easier and efficient
D. responding to queries easily
Answer» C. making searching easier and efficient
75.

The getch() library function returns___

A. a character when any key is pressed
B. a character when enter is pressed
C. displays a character on the screen when any key is pressed
D. none of these
Answer» A. a character when any key is pressed
76.

A. 0 or 1
B. -1, 0 or 1
C. a character
D. nothing
77.

A variable P is called pointer if__

A. p contains the address of an element in data
B. p points to the address of first element in data
C. p can store only memory address
D. p contain the data and the address of data
78.

A. arrays
B. records
C. pointers
D. none
79.

The difference between linear array and a record is_____

A. an array is suitable for homogeneous data but the data items in a record may have different data type
B. in a record,theremay not be a natural ordering in opposed ti linear array
C. a record form a hierarchical structure but a linear array does not
D. all of above
80.

If s1 is "ABC" and s2 is "DEF" then strcat(s1,s2)will give the following result.

A. s1="abcdef" and s2="def"
B. s1="abcdef" and s2="def"
C. s1="abc" and s2="abcdef"
D. s1="abc" and s2="abcdef"
81.

Give output of the following programint main(){inta[]={2,3,4,5,6};printf("%d",2[a]);}

A. compilation error
B. run time error
C. 4
D. 2
82.

Where do we use the operator --> ?

A. to access a member of structure
B. to access member of union
C. to access an array
D. both(a) and(b).
83.

The function strcmp(s1,s2)will return -1 if____

A. s1>s2
B. s1=s2
C. s1<s2
D. function does not return -1.
84.

A. arrays
B. records
C. pointers
D. none
85.

A. 7
B. 6
C. 10
D. 5
86.

A sorting algorithm is stable if

A. its time complexity is constant irrespective of the nature of input
B. preserves the original order of records with equal keys
C. its space complexity is constant irrespective of the nature of input
D. it sorts any volume of data in a constant time
Answer» B. preserves the original order of records with equal keys
87.

A. o(2n)
B. o(n3)
C. o(n2)
D. o(2n)
88.

A. 15
B. 8
C. 1
D. 4
89.

A sort which compares adjacent elements in a list and switches where necessary is

A. insertion sort
B. heap sort
C. quick sort
D. bubble sort
90.

A sort which iteratively passes through a list to exchange the first element with any element less than it and then repeats with a new first element is called

A. insertion sort
B. selection sort
C. heap sort
D. quick sort
91.

A. 11
B. 12
C. 13
D. 14
92.

A. stable
B. consistent
C. external
D. linear
93.

You want to check whether a given set of items is sorted. Which of the following sorting methods will be most efficient if it is already in sorted order?

A. bubble sort
B. selection sort
C. insertion sort
D. merge sort
94.

Which of the following sorting methods will be the best if number of swappings done, is the only measure of efficienty?

A. bubble sort
B. selection sort
C. insertion sort
D. merge sort
95.

You are asked to sort 15 randomly generated numbers. You should prefer

A. bubble sort
B. selection sort
C. insertion sort
D. merge sort
96.

A. Θ(n)
B. Θ(n log n)
C. Θ(n2)
D. Θ(n2 log n)
97.

A. 6
B. 5
C. 7
D. 8
98.

A. lower bound
B. upper bound
C. range
D. extraction
99.

Which of the following sorting methods would be most suitable for sorting a list which is almost sorted

A. bubble sort
B. selection sort
C. insertion sort
D. merge sort
100.

A. o(n)
B. o(log n)
C. o(n2)
D. o(n log n)