Bài giảng Cấu trúc dữ liệu & giải thuật: Balanced search trees
Số trang: 28
Loại file: pdf
Dung lượng: 1.70 MB
Lượt xem: 15
Lượt tải: 0
Xem trước 3 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Bài giảng "Cấu trúc dữ liệu và giải thuật: Balanced search trees" cung cấp cho người học các kiến thức: Balanced search trees, 2-3 Trees, 2-3-4 Trees. Đây là một tài liệu hữu ích dành cho các bạn sinh viên ngành Công nghệ thông tin và những ai quan tâm dùng làm tài liệu học tập và nghiên cứu.
Nội dung trích xuất từ tài liệu:
Bài giảng Cấu trúc dữ liệu & giải thuật: Balanced search trees 2 Balanced Search Trees 2-3 Trees 2-3-4 Trees Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 1 3 Height of a binary search tree sensitive to order of insertions and removals Minimum= log2 (n + 1) Maximum = n Various search trees can retain balance despite insertions and removals Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 4 FIGURE 19-1 (a) A binary search tree of maximum height; (b) a binary search tree of minimum height Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 2 5 A 2-3 tree not a binary tree A 2-3 tree never taller than a minimum-height binary tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 6 Placing data items in nodes of a 2-3 tree A 2-node (has two children) must contain single data item greater than left child’s item(s) and less than right child’s item(s) A 3-node (has three children) must contain two data items, S and L , such that S is greater than left child’s item(s) and less than middle child’s item(s); L is greater than middle child’s item(s) and less than right child’s item(s). Leaf may contain either one or two data items. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 3 7 FIGURE 19-3 Nodes in a 2-3 tree: (a) a 2-node; (b) a 3-node Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013` 8 A 2-3 tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 4 9 Traverse 2-3 tree in sorted order by performing analogue of inorder traversal on binary tree: Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 10 Retrieval operation for 2-3 tree similar to retrieval operation for binary search tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 5 11 Data Structures and Problem Solving with C++: ...
Nội dung trích xuất từ tài liệu:
Bài giảng Cấu trúc dữ liệu & giải thuật: Balanced search trees 2 Balanced Search Trees 2-3 Trees 2-3-4 Trees Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 1 3 Height of a binary search tree sensitive to order of insertions and removals Minimum= log2 (n + 1) Maximum = n Various search trees can retain balance despite insertions and removals Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 4 FIGURE 19-1 (a) A binary search tree of maximum height; (b) a binary search tree of minimum height Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 2 5 A 2-3 tree not a binary tree A 2-3 tree never taller than a minimum-height binary tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 6 Placing data items in nodes of a 2-3 tree A 2-node (has two children) must contain single data item greater than left child’s item(s) and less than right child’s item(s) A 3-node (has three children) must contain two data items, S and L , such that S is greater than left child’s item(s) and less than middle child’s item(s); L is greater than middle child’s item(s) and less than right child’s item(s). Leaf may contain either one or two data items. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 3 7 FIGURE 19-3 Nodes in a 2-3 tree: (a) a 2-node; (b) a 3-node Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013` 8 A 2-3 tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 4 9 Traverse 2-3 tree in sorted order by performing analogue of inorder traversal on binary tree: Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013 10 Retrieval operation for 2-3 tree similar to retrieval operation for binary search tree Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013CuuDuongThanCong.com https://fb.com/tailieudientucntt 5 11 Data Structures and Problem Solving with C++: ...
Tìm kiếm theo từ khóa liên quan:
Cấu trúc dữ liệu Cấu trúc dữ liệu và giải thuật Bài giảng Cấu trúc dữ liệu Balanced search trees Cấu trúc câyGợi ý tài liệu liên quan:
-
Đề cương chi tiết học phần Cấu trúc dữ liệu và giải thuật (Data structures and algorithms)
10 trang 317 0 0 -
Giáo trình cấu trúc dữ liệu và giải thuât part 2
16 trang 166 0 0 -
3 trang 162 3 0
-
Giải thuật và cấu trúc dữ liệu
305 trang 161 0 0 -
Giáo trình Cấu trúc dữ liệu và giải thuật: Phần 2 - Trần Hạnh Nhi
123 trang 156 0 0 -
Bài giảng Phân tích thiết kế phần mềm: Chương 1 - Trường ĐH Ngoại ngữ - Tin học TP.HCM
64 trang 150 0 0 -
Tập bài giảng Thực hành kỹ thuật lập trình
303 trang 143 0 0 -
Giáo trình Cấu trúc dữ liệu và thuật toán (Tái bản): Phần 1
152 trang 139 0 0 -
10 trang 138 0 0
-
57 trang 132 1 0