Adn 5
Adn 5
Structures
Tree
In computers, a tree is an abstract model of a hierarchical structure
A tree consists of nodes with a parent-child relation
Applications: Organization charts, File systems, Programming
environments A
Root: node without parent (A)
Internal node: node with at least one child B C D
(A, B, C, F)
E F G H
External node (or leaf node ): node without
children (E, I, J, K, G, H, D) I J K
h (n - 1)/2
e 2h
h log2 e
h log2 (n + 1) - 1
Traversals in a tree
A traversal visits the nodes of a tree in a systematic manner
In a preorder traversal, a node is visited before its descendants
Application: print a structured document
a
In a postorder traversal, a node is visited after its
descendants b e
U V W X
A 1 1 0 0
B 0 1 0 1
C 1 0 1 0
D 0 1 1 0
E 0 0 1 1
Adjacency matrix
U V W X
U 0 1 1 0
V 1 0 1 1
W 1 1 0 1
X 0 1 1 0
Adjacency List
an array indexed by vertex numbers points to a singly-linked list of
the neighbors of each vertex.
In a complete graph each pair of vertices is joined by an edge, that
is, the graph contains all possible edges.
In a bipartite graph, the vertices can be divided into two
sets, W and X, so that every edge has one vertex in each of the two
sets.
A planar graph can be drawn in a plane with no crossing
edges (i.e., embedded in a plane).
Eulerian path is a path in a graph which visits
each edge exactly once and returns to the starting vertex.
A Graph has a Eulerian Path if all vertices have even
degree.
Hamiltonian path (or traceable path) is a path in an undirected
graph which visits each vertex exactly once. Hamiltonian
cycle (or Hamiltonian circuit) is a cycle in an undirected graph which
visits each vertex exactly once and also returns to the starting
vertex.
Independent set or stable set is a set of vertices in a graph, no two of
which are adjacent. That is, it is a set I of vertices such that for every
two vertices in I, there is no edge connecting the two.
A maximum independent set is a largest independent set for a given
graph G.
Maximum Independent set is { U,Z,Y}
Vertex Cover