• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Greedy Algorithms with Answers

Question 1

A networking company uses a compression technique to encode the message before transmitting over the network. Suppose the message contains the following characters with their frequency: 

C
character   Frequency
    a	          5
    b             9
    c             12
    d             13
    e             16
    f             45

Note : Each character in input message takes 1 byte. If the compression technique used is Huffman Coding, how many bits will be saved in the message?

  • 224

  • 800

  • 576

  • 324

Question 2

What is the time complexity of Huffman Coding?

  • O(N)

  • O(NlogN)

  • O(N(logN)^2)

  • O(N^2)

Question 3

In question #2, which of the following represents the word "dead"?

  • 1011111100101

  • 0100000011010

  • Both A and B

  • None of these

Question 4

Which of the following is true about Kruskal and Prim MST algorithms? 

Assume that Prim is implemented for adjacency list representation using Binary Heap and Kruskal is implemented using union by rank.

  • Worst case time complexity of both algorithms is same.

  • Worst case time complexity of Kruskal is better than Prim

  • Worst case time complexity of Prim is better than Kruskal

  • None of these

Question 5

Which of the following is true about Huffman Coding?

  • Huffman coding may become lossy in some cases

  • Huffman Codes may not be optimal lossless codes in some cases

  • In Huffman coding, no code is prefix of any other code.

  • All of the above

Question 6

What is the other name of Dijkstra algorithm?

  • single-source shortest path problem

  • multiple-source shortest path problem

  • multiple-destination shortest path problem

  • single-destination shortest path problem

Question 7

Consider the undirected graph below:  Using Prim's algorithm to construct a minimum spanning tree starting with node A, which one of the following sequences of edges represents a possible order in which the edges would be added to construct the minimum spanning tree?

[caption width="800"] [/caption]
  • (E, G), (C, F), (F, G), (A, D), (A, B), (A, C)

  • (A, D), (A, B), (A, C), (C, F), (G, E), (F, G)

  • (A, B), (A, D), (D, F), (F, G), (G, E), (F, C)

  • (A, D), (A, B), (D, F), (F, C), (F, G), (G, E)

Question 8

A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24 respectively. The optimal Huffman coding technique will have the average length of:

  • 2.40

  • 2.16

  • 2.26

  • 2.15

Question 9

Six files F1, F2, F3, F4, F5 and F6 have 100, 200, 50, 80, 120, 150 records respectively. In what order should they be stored so as to optimize act. Assume each file is accessed with the same frequency

  • F3, F4, F1, F5, F6, F2

  • F2, F6, F5, F1, F4, F3

  • F1, F2, F3, F4, F5, F6

  • Ordering is immaterial as all files are accessed with the same frequency.

Question 10

The number of permutations of the characters in LILAC so that no character appears in its original position, if the two L’s are indistinguishable, is ________ . Note - This question was Numerical Type.
  • 12
  • 10
  • 8
  • 15

There are 20 questions to complete.

Last Updated :
Take a part in the ongoing discussion