Explore topic-wise MCQs in Data Structures and Algorithms.

This section includes 46 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the competitive analysis of the FIFO algorithm?

A. k/k+1
B. k+1
C. k(k+1)
D. k/(k-h+1)
Answer» E.
2.

Optimal page replacement algorithm is also called as __________

A. LIFO
B. NRU
C. Clairvoyant replacement algorithm
D. Page buffering
Answer» D. Page buffering
3.

In a optimal page replacement algorithm, when a page is to be replaced, which of the following pages is chosen?

A. Oldest page
B. Newest page
C. Frequently occurred page in the future
D. Not frequently occurred page in the future
Answer» E.
4.

Which of the following is the main drawback of FIFO page replacement algorithm?

A. Requirement of large memory
B. Frame allocation
C. Reduction in multiprogramming
D. Reduced optimality
Answer» D. Reduced optimality
5.

Which of the following page replacement algorithms return the minimum number of page faults?

A. LRU replacement algorithm
B. Optimal page replacement algorithm
C. FIFO
D. Counting based replacement
Answer» C. FIFO
6.

__________ algorithm associates with each page the time when the page was brought into memory.

A. Optimal page replacement
B. FIFO
C. LRU replacement algorithm
D. Counting based replacement
Answer» C. LRU replacement algorithm
7.

FIFO algorithm is used by __________ operating system.

A. Linux
B. Mac
C. Windows
D. VAX/VMS
Answer» E.
8.

In a stack algorithm, the set of pages in a k-frame memory is always a subset of pages in a __________ frame memory.

A. k-1
B. k
C. k+1
D. k(k+1)
Answer» D. k(k+1)
9.

________ is a typical online problem from the competitive analysis to determine the optimal solution.

A. Page replacement algorithm
B. Segmentation
C. Paging
D. Segmentation with paging
Answer» B. Segmentation
10.

__________ has the lowest fault rate of all the page replacement algorithms.

A. Optimal page replacement algorithm
B. LRU replacement algorithm
C. FIFO
D. Counting based
Answer» B. LRU replacement algorithm
11.

Optimal page replacement algorithm is implemented in __________

A. General-purpose operating system
B. Special-purpose operating system
C. In any kind of operating system
D. In Windows only
Answer» C. In any kind of operating system
12.

The cost required to execute a FIFO algorithm is expensive.

A. True
B. False
Answer» C.
13.

Which of the following is the simplest page replacement algorithm?

A. FIFO
B. Optimal page replacement
C. LRU replacement
D. Counting based replacement
Answer» B. Optimal page replacement
14.

_________ states that, on a page fault, the frame that has been in memory the longest is replaced.

A. Belady's anomaly
B. Second chance algorithm
C. Partial second chance algorithm
D. LRU replacement algorithm
Answer» B. Second chance algorithm
15.

Which of the following is required to determine the number of page faults in FIFO?

A. Page number
B. Page frame number
C. Memory capacity
D. Segment number
Answer» C. Memory capacity
16.

Analysis of the optimal paging problem has been done through___________

A. Deterministic algorithm
B. Online algorithm
C. Euclid algorithm
D. Optimal algorithm
Answer» C. Euclid algorithm
17.

The code length does not depend on the frequency of occurrence of characters.

A. true
B. false
Answer» C.
18.

Under which of the following scenarios is page replacement algorithm required?

A. When total memory exceeds physical memory
B. To determine the number of frames for each process
C. When paging and segmentation are to be used
D. Execution of a process, not in memory
Answer» B. To determine the number of frames for each process
19.

Fractional knapsack problem is also known as __________

A. 0/1 knapsack problem
B. Continuous knapsack problem
C. Divisible knapsack problem
D. Non continuous knapsack problem
Answer» C. Divisible knapsack problem
20.

A page that is not going to be used for the next 7 seconds will be swapped out over a page that is going to be used within the next 0.7 seconds.

A. True
B. False
Answer» B. False
21.

Optimal page replacement algorithm is said to satisfy __________

A. Online algorithm
B. Stack algorithm
C. Queue algorithm
D. Array algorithm
Answer» C. Queue algorithm
22.

Fractional knapsack problem is solved most efficiently by which of the following algorithm?

A. Divide and conquer
B. Dynamic programming
C. Greedy algorithm
D. Backtracking
Answer» D. Backtracking
23.

Time complexity of fractional knapsack problem is ____________

A. O(n log n)
B. O(n)
C. O(n2)
D. O(nW)
Answer» B. O(n)
24.

How many printable characters does the ASCII character set consists of?

A. 120
B. 128
C. 100
D. 98
Answer» D. 98
25.

Which of the following algorithms is the best approach for solving Huffman codes?

A. exhaustive search
B. greedy algorithm
C. brute force algorithm
D. divide and conquer algorithm
Answer» C. brute force algorithm
26.

The type of encoding where no character code is the prefix of another character code is called?

A. optimal encoding
B. prefix encoding
C. frequency encoding
D. trie encoding
Answer» C. frequency encoding
27.

The main time taking step in fractional knapsack problem is ___________

A. Breaking items into fraction
B. Adding items into knapsack
C. Sorting
D. Looping through sorted items
Answer» D. Looping through sorted items
28.

Which bit is reserved as a parity bit in an ASCII set?

A. first
B. seventh
C. eighth
D. tenth
Answer» D. tenth
29.

An optimal code will always be present in a full tree.

A. true
B. false
Answer» B. false
30.

How many bits are needed for standard encoding if the size of the character set is X?

A. log X
B. X+1
C. 2X
D. X2
Answer» B. X+1
31.

Which of the following statement about 0/1 knapsack and fractional knapsack problem is correct?

A. In 0/1 knapsack problem items are divisible and in fractional knapsack items are indivisible
B. Both are the same
C. 0/1 knapsack is solved using a greedy algorithm and fractional knapsack is solved using dynamic programming
D. In 0/1 knapsack problem items are indivisible and in fractional knapsack items are divisible
Answer» E.
32.

What is the objective of the knapsack problem?

A. To get maximum total value in the knapsack
B. To get minimum total value in the knapsack
C. To get maximum weight in the knapsack
D. To get minimum weight in the knapsack
Answer» B. To get minimum total value in the knapsack
33.

What is the running time of the Huffman encoding algorithm?

A. O(C)
B. O(log C)
C. O(C log C)
D. O( N log C)
Answer» D. O( N log C)
34.

The result of the fractional knapsack is greater than or equal to 0/1 knapsack.

A. True
B. False
Answer» B. False
35.

Fractional knapsack problem can be solved in time O(n).

A. True
B. False
Answer» B. False
36.

What will be the cost of the code if character ci is at depth di and occurs at frequency fi?

A. cifi
B. ∫cifi
C. ∑fidi
D. fidi
Answer» D. fidi
37.

What is the running time of the Huffman algorithm, if its implementation of the priority queue is done using linked lists?

A. O(C)
B. O(log C)
C. O(C log C)
D. O(C2)
Answer» E.
38.

Given items as {value,weight} pairs {{40,20},{30,10},{20,5}}. The capacity of knapsack=20. Find the maximum value output assuming items to be divisible.

A. 60
B. 80
C. 100
D. 40
Answer» B. 80
39.

Given items as {value,weight} pairs {{60,20},{50,25},{20,5}}. The capacity of knapsack=40. Find the maximum value output assuming items to be divisible and nondivisible respectively.

A. 100, 80
B. 110, 70
C. 130, 110
D. 110, 80
Answer» E.
40.

In Huffman coding, data in a tree always occur?

A. roots
B. leaves
C. left sub trees
D. right sub trees
Answer» C. left sub trees
41.

When all software that runs on a system is known beforehand, optimal page replacement algorithm can be used in a general-purpose operating system.

A. True
B. False
Answer» B. False
42.

Consider a reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 of frame size 3. Calculate the number of page faults using optimal page replacement algorithm.

A. 10
B. 9
C. 8
D. 7
Answer» C. 8
43.

Consider a reference string:7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 of frame size 4. Using FIFO algorithm, determine the number of page faults.

A. 12
B. 16
C. 10
D. 14
Answer» D. 14
44.

Consider a reference string:7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 of frame size 3. Using FIFO algorithm, determine the number of page faults.

A. 12
B. 16
C. 14
D. 15
Answer» E.
45.

In a FIFO algorithm, when a page is to be replaced, which of the following page is chosen?

A. Oldest page
B. Newest page
C. Frequently occurred page in past
D. Frequently occurred page in future
Answer» B. Newest page
46.

As the number of frames available increases, the number of page faults decreases.

A. True
B. False
Answer» B. False