Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.1 MB, 123 trang )
Tree – Ví dụ
- Leaf node?
- Degree of a Node of a Tree?
- Degree of a Tree?
- Level of a Node?
- Height – Depth of a Tree?
Chương 7: Cây (Tree)
Trắc nghiệm
12
The depth of a tree is the _______ of a tree
a)
b)
c)
d)
number of nodes on the tree
number of levels of a tree
number of branches
level
Give the binary tree with root A. The root has
left child B and right child C. B has left child
D and right child E. There are no other nodes in
the tree. The height of the tree is _______.
a)
b)
c)
d)
0
3
1
2
Chương 7: Cây (Tree)
Nội dung
17
Cấu trúc cây
Cấu trúc cây
Cấu trúc cây
Search Tree)
Cấu trúc cây
(AVL Tree)
Chương 7: Cây (Tree)
(Tree)
nhị phân (Binary Tree)
nhị phân tìm kiếm (Binary
nhị phân tìm kiếm cân bằng
Binary Tree – Định nghĩa
18
Cây nhị phân là cây mà mỗi nút có tối đa
2 cây con (cây có bậc là 2)
Chương 7: Cây (Tree)
Binary Tree – Ví dụ
19
Cây con
trái
Cây con
phải
Hình ảnh môôt cây nhị phân
Chương 7: Cây (Tree)
Binary Tree – Ví dụ
Cây lệch trái và cây lệch phải
Chương 7: Cây (Tree)
Binary Tree – Ví dụ
Cây nhị phân đầy đủ (A full binary tree)
Chương 7: Cây (Tree)
Binary Tree – Ứng dụng
22
Cây biểu thức: được dùng để biểu diễn một biểu thức
toán học
Chương 7: Cây (Tree)
Binary Tree – Ví dụ
23
Cây quyết định: được dùng để hỗ trợ quá
trình ra quyết định
Chương 7: Cây (Tree)
Binary Tree – Một số tính chất
24
Số nút nằm ở mức i ≤ 2i
Số nút lá ≤ 2h-1, với h là chiều cao của cây
Số nút trong cây ≤ 2h-1, với h là chiều cao của cây
Chiều cao của cây ≥ log2N, với N là số nút trong cây
Chương 7: Cây (Tree)
Trắc nghiệm
25
A binary tree is a tree in which each node
references at most _____ node(s)
2
24
6
8
What is the minimum height of a binary tree
with 31 nodes?
3
The maximum number of leaf-nodes in a binary
tree of height 4 is:
10
47
5
3
If the depth of a binary tree is 3, then what
is the maximum size of the tree?
3
Chương 7: Cây (Tree)
4
6
8