Algorithm Design and Analysis Chapter 4 Greedy Algorithm Work

True or False

1-1
Only when the local optimal solution is consistent with the global optimal solution, the greedy method can give the correct solution.

T F

1-2
Let S be the set of all activities in the Activity Selection Problem (Activity Selection Problem). Then there must be a certain maximum compatible activity subset of S that contains the earliest end activity am​​.
Insert picture description here
T F

1-3
Let S be the set of all activities in the Activity Selection Problem. Then the earliest ending activity am must be included in all the largest compatible activity subsets of S.
Insert picture description here
TF

1-4
In the Activity Selection Problem, let S be the set of activities. Based on the greedy principle of "collecting the latest activities to start each time", the largest subset of mutually compatible activities in S can be correctly found.

T F

1-5
Let C be a letter set, where each character c has a corresponding frequency c.freq. If the size of C is n, the optimal prefix code length of any character c will not exceed n−1.

T F

Multiple choice

2-1
Given 4 characters (a, b, c, d) in a piece of text. Let a and b have the lowest frequency of occurrence. Which of the following sets of codes are possible Huffman codes for this text?

A.a: 000, b:001, c:01, d:1
B.a: 000, b:001, c:01, d:11
C.a: 000, b:001, c:10, d:1
D.a: 010, b:001, c:01, d:1

According to the nature of the parent node of a Huffman tree, there must be two leaf nodes;

2-2
Given 4 characters (u,v,w,x) in a piece of text and their frequency of occurrence (f​u​​ ,f​v​​ ,f​w​​ ,f​x​​) . If the corresponding Huffman code is u: 00, v: 010, w: 011, x: 1, which group of the following frequencies may correspond to (f​u​​ ,f​v​​ ,f​w​​, f​x​​ )?
Insert picture description here
A.15, 23, 16, 45
B.30, 21, 12, 33
C.41, 12, 20, 32
D.55, 22, 18, 46

The two Huffman codes in the middle are the longest and show that the deeper the depth, the lower the frequency;

Guess you like

Origin blog.csdn.net/Jessieeeeeee/article/details/111870583