140 likes | 283 Views
Chapter 7. Multiway trees. A tree was defined as either an empty structure or a structure whose children are disjoint trees. This means that each node in some kind of trees can have more than two children. This tree is called a multiway tree of order m , or m-way tree
E N D
Chapter 7 Multiway trees
A tree was defined as either an empty structure or a structure whose children are disjoint trees. • This means that each node in some kind of trees can have more than two children. • This tree is called a multiway tree of order m, or m-way tree • A multiway search tree of order m is a multiway tree in which : • Each node has m children and m-1 keys. • The keys in each node are in ascending order. • The keys in the first i children are smaller than the ith key. • The keys in the last m-i children are larger than the ith key.
B-Tree • B- Trees operates closely with secondary storage. • Property: the size of a node can be made as large as a block. • A B- tree of order m is a multi way search tree with the following properties: • The root has at least two subtrees unless it is a leaf. • Each nonroot and each nonleaf node holds k-1 keys and k pointers to subtrees where [m/2] ≤ k ≤ m. • Each leaf node holds k-1 keys where [m/2] ≤ k ≤ m. • All leaves are usually on the same level.
Chapter 8 Graphs
Even though trees are flexible and have many applications, they have one limitation: • They can only represent relations of hierarchical type, such as relations between parent and child. • Other relations are only represented indirectly. • Graph, a generalization of a tree, is a data structure that contain a collection of vertices( or nodes) and the connections between them.
Terminology • Graph • collection of nodes (vertices) • collection of line segments connecting vertices (edges) • Graph • Directed • Each line segment has a direction (Arc) • Undirected • No direction on any line segment (Edge)
Neighbors • Two vertices are said to be neighbors if an edge directly connects them • Path • A sequence of vertices in which each vertex is adjacent to the other • Cycle • A path that start and ends with the same vertex • Loop • A single Arc that begins and ends with the same vertex
Connected Graph • There is a path from any vertex to any other vertex • Vertex Degree • Indegree • Number of arcs entering the vertex • Outdegree • Number of arcs leaving the vertex
Storage Structures Two sets Vertices Edges Two Representations Arrays (Adjacency Matrix) Linked Lists (Adjacency List)