Design and Analysis of Algorithms MCQs with Answers
Practice important Design and Analysis of Algorithms MCQs with answers and explanations.
Multiple Choice Questions
Q201: Huffman encoding uses what type of codes?
- A: Fixed-length codes
- B: Variable-length codes
- C: Random-length codes
- D: Character codes
View Answer
B
Q202: What is the expected length of a string encoded with Huffman coding compared to ASCII?
- A: Shorter
- B: Longer
- C: The same
- D: Unpredictable
View Answer
A
Q203: In Huffman encoding, how do you determine the frequency of each character?
- A: By analyzing the frequency of use in the world
- B: By parsing the message string
- C: By asking the user
- D: By random assignment
View Answer
B
Q204: What does the prefix property in Huffman coding ensure?
- A: No codeword is a prefix of another codeword
- B: All codewords are the same length
- C: All characters are represented equally
- D: Every character has a unique codeword
View Answer
A
Q205: How does the cost of an encoding tree T relate to the character probabilities?
- A: It is independent of the probabilities
- B: It decreases as the probabilities increase
- C: It increases as the probabilities decrease
- D: It reflects the expected number of bits needed to encode text
View Answer
D
Q206: If a string has 10 characters, what is the length of the encoded string using 8-bit ASCII?
- A: 10 bits
- B: 80 bits
- C: 60 bits
- D: 40 bits
View Answer
B
Q207: The greedy approach in Huffman encoding aims to minimize which of the following?
- A: The total length of the encoded string
- B: The number of characters
- C: The size of the tree
- D: The time taken to encode text
View Answer
A
Q208: Fill in the blank: A greedy algorithm sometimes produces a solution that is optimal and is called a __________.
- A: greedy heuristic
- B: greedy approximation
- C: greedy algorithm
- D: greedy function
View Answer
A
Q209: Fill in the blank: The __________ algorithm for the coin change problem sets up a table for minimum coins required.
- A: dynamic programming
- B: greedy
- C: hierarchical
- D: direct search
View Answer
A
Q210: What is the main difference between the 0-1 knapsack problem and the fractional knapsack problem?
- A: Only whole items can be taken in 0-1 knapsack
- B: Only fractions of items can be taken in fractional knapsack
- C: Both allow fractional items
- D: Neither allow fractions
View Answer
A