CSCI 2320 Data Structure Exam 2

advertisement
CSCI 2320 Data Structure Exam 2
Name:___________________
Question 1 (15 pts)
1.1 For the tree showed in figure1, if we implement by the representation of one
dimensional array, what should the tree looks like?
0
10
1
20
11
2
10
12
3
40
13
35
4
5
14
5
18
15
6
30
16
7
17
8
2
18
9
19
1.2 For the tree showed in figure1, if we implement by the representation of a general tree,
what should the tree looks like?
(Representation of a general tree format:
)
Figure1
1.3 For the tree showed in figure1, if we implement by the representation of a binary tree,
what should the tree looks like?
(Representation of a Binary tree format:
)
Question 3 (15 pts)
Given the following binary search tree:
Figure 1
Figure 2
Figure 3
3.1 Draw the AVL tree in Figure 1 after insert the element 25 (5 pts)
3.2 Convert Figure 2 into AVL tree (5 pts)
3.3 Convert Figure 3 into AVL tree and then draw the AVL tree after Delete the element
20 (5 pts)
Question 4:
4.1 Based on the given sequence, construct a Binary Heap using build heap function
(15 pts)
0
---
1
91
2
15
3
13
4
20
5
33
6
67
7
1
8
2
9
58
10
60
11
17
12
90
4.2 Draw the Binary Heap in (1) after insert the element 5 (5 pts)
4.3 Draw the Binary Heap in (2) after one deleteMin operation (5 pts)
4.4 Draw the Binary Heap in (3) after one deleteMin operation (5 pts)
13
30
14
22
15
73
Question 5 (13 pts):
Suppose we have the following message:
BACADAEAFABBBAAACCEFFFF
Please construct the Huffman Encoding tree for the message.
Based the tree you constructed, what is the representation for
A: 01
B: 10
C: 001
D: 0000
E: 0001
F: 11
Download