The document provides information about different types of trees:
- A tree is a connected undirected graph without cycles. It has a unique path between any two vertices.
- Rooted trees have one distinguished root vertex. They define the level, height and relationships between parent/child and ancestor/descendant vertices.
- Binary trees restrict each vertex to having zero, one or two children. Ordered binary trees further define the left and right children.
- Expression trees represent mathematical expressions, with operators in internal nodes and operands in leaves. Their structure dictates evaluation order.
- Other tree properties discussed include those of full/complete binary trees and algorithms for finding minimum spanning trees like Prim's and K
a. Concept and Definition
b. Binary Tree
c. Introduction and application
d. Operation
e. Types of Binary Tree
• Complete
• Strictly
• Almost Complete
f. Huffman algorithm
g. Binary Search Tree
• Insertion
• Deletion
• Searching
h. Tree Traversal
• Pre-order traversal
• In-order traversal
• Post-order traversal
Slides at myblog
http://www.ashimlamichhane.com.np/2016/07/tree-slide-for-data-structure-and-algorithm/
Assignments at github
https://github.com/ashim888/dataStructureAndAlgorithm/tree/dev/Assignments/assignment_7
a. Concept and Definition
b. Binary Tree
c. Introduction and application
d. Operation
e. Types of Binary Tree
• Complete
• Strictly
• Almost Complete
f. Huffman algorithm
g. Binary Search Tree
• Insertion
• Deletion
• Searching
h. Tree Traversal
• Pre-order traversal
• In-order traversal
• Post-order traversal
Slides at myblog
http://www.ashimlamichhane.com.np/2016/07/tree-slide-for-data-structure-and-algorithm/
Assignments at github
https://github.com/ashim888/dataStructureAndAlgorithm/tree/dev/Assignments/assignment_7
We will discuss the following: Graph, Directed vs Undirected Graph, Acyclic vs Cyclic Graph, Backedge, Search vs Traversal, Breadth First Traversal, Depth First Traversal, Detect Cycle in a Directed Graph.
This slide was made for my University presentation .
In this slide is full of the basic of Tree.I hope, you will get most basic information from this slide.
We will discuss the following: Graph, Directed vs Undirected Graph, Acyclic vs Cyclic Graph, Backedge, Search vs Traversal, Breadth First Traversal, Depth First Traversal, Detect Cycle in a Directed Graph.
This slide was made for my University presentation .
In this slide is full of the basic of Tree.I hope, you will get most basic information from this slide.
This Slide was made for my university presentation in "Bangladesh Studies" course.In this slide ,you will get all logical information about Bangladesh from the pre-ancient period to till now.I think that's will help you by giving information about Bangladeshi Political History of All in All.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
2. Tree
Definition 1. A tree is a connected
undirected graph with no simple circuits.
Theorem 1. An undirected graph is a tree if
and only if there is a unique simple path
between any two of its vertices.
2
4. Is it a tree?
NO!
yes! All the nodes are yes! (but not
not connected a binary tree)
NO!
There is a cycle yes! (it’s actually
and an extra the same graph as
edge (5 nodes the blue one) – but
and 5 edges) usually we draw
tree by its “levels”4
5. Rooted Trees
q Rooted tree is a tree in which one vertex is
distinguished and called a root
q Level of a vertex is the number of edges
between the vertex and the root
q The height of a rooted tree is the
maximum level of any vertex
q Children, siblings and parent vertices in a
rooted tree
q Ancestor, descendant relationship
between vertices
5
6. q The parent of a non-root vertex is the unique vertex
u with a directed edge from u to v.
q A vertex is called a leaf if it has no children.
q The ancestors of a non-root vertex are all the
vertices in the path from root to this vertex.
q The descendants of vertex v are all the vertices that
have v as an ancestor.
q The level of vertex v in a rooted tree is the length of
the unique path from the root to v.
q The height of a rooted tree is the maximum of the
6
levels of its vertices.
7. A Tree Has a Root
root node
a
internal vertex parent of g
b c
d e f g
leaf
siblings
h i
7
9. The level of a vertex v in a rooted tree is
the length of the unique path from the root
to this vertex.
level 2
level 3
10. a
b c
d e f g
subtree with b as its
h i root
subtree with c as its
root
11. Tree Properties
q There is one and only one path between
every pair of vertices in a tree, T.
q A tree with n vertices has n-1 edges.
q Any connected graph with n vertices and n-1
edges is a tree.
q A graph is a tree if and only if it is minimally
connected. 11
12. Tree Properties
Theorem . There are at most 2 H leaves in a
binary tree of height H.
Corallary. If a binary tree with L leaves is
full and balanced, then its height is
H = log2 L .
12
13. Properties of Trees
There are at most mh leaves in an m-ary
tree of height h.
A rooted m-ary tree of height h is called
balanced if all leaves are at levels h or h-1.
14. Properties of Trees
A full m-ary tree with
(i) n vertices has i = (n-1)/m internal
vertices and l = [(m-1)n+1]/m leaves.
(ii) i internal vertices has n = mi + 1
vertices and l = (m-1)i + 1 leaves.
(iii) l leaves has n = (ml - 1)/(m-1) vertices
and i = (l-1)/(m-1) internal vertices.
15. Properties of Trees
A full m-ary tree with i internal vertices
contains n = mi+1 vertices.
16. Proof
q We know n = mi+1 (previous
theorem) and n = l+i,
q n – no. vertices
q i – no. internal vertices
q l – no. leaves
q For example, i = (n-1)/m
17. Binary Tree
A rooted tree in which each vertex has either
no children, one child or two children.
The tree is called a full binary tree if every
internal vertex has exactly 2 children.
A
B C right child of A
left subtree
of A D E F G
right
subtree of
H C 17
I J
18. Ordered Binary Tree
Definition 2’’. An ordered rooted tree is a
rooted tree where the children of each
internal vertex are ordered.
In an ordered binary tree, the two
possible children of a vertex are called
the left child and the right child, if they
exist.
18
20. Is this binary tree balanced?
A rooted binary tree of height
Lou H is called balanced if all its
leaves are at levels H or H-1.
Hal Max
Ed Ken Sue
Joe Ted
20
21. Searching takes time . . .
So the goal in computer programs is to find
any stored item efficiently when all stored
items are ordered.
A Binary Search Tree can be used to store
items in its vertices. It enables efficient
searches.
21
22. A Binary Search Tree (BST) is . . .
A special kind of binary tree in which:
1. Each vertex contains a distinct key value,
2. The key values in the tree can be compared using
“greater than” and “less than”, and
3. The key value of each vertex in the tree is
less than every key value in its right subtree, and
greater than every key value in its left subtree.
23. A Binary Expression Tree is . . .
A special kind of binary tree in which:
l Each leaf node contains a single operand,
l Each nonleaf node contains a single binary
operator, and
l The left and right subtrees of an operator
node represent subexpressions that must be
evaluated before applying the operator at
the root of the subtree.
23
24. Expression Tree
q Each node contains an
operator or an operand
q Operands are stored in
leaf nodes
q Parentheses are not stored (x + y)*((a + b)/c)
in the tree because the tree structure
dictates the order of operand evaluation
q Operators in nodes at higher levels are
evaluated after operators in nodes at lower
levels
24
25. A Binary Expression Tree
‘*’
‘+’ ‘3’
‘4’ ‘2’
What value does it have?
( 4 + 2 ) * 3 = 18
25
26. A Binary Expression Tree
‘*’
‘+’ ‘3’
‘4’ ‘2’
Infix: ((4+2)*3)
Prefix: * + 4 2 3 evaluate from right
Postfix: 4 2 + 3 * evaluate from left
26
27. Levels Indicate Precedence
When a binary expression tree is used to
represent an expression, the levels of the
nodes in the tree indicate their relative
precedence of evaluation.
Operations at higher levels of the tree are
evaluated later than those below them.
The operation at the root is always the
last operation performed.
27
29. A binary expression tree
‘*’
‘-’ ‘/’
‘8’ ‘5’ ‘+’ ‘3’
‘4’ ‘2’
Infix: ((8-5)*((4+2)/3))
Prefix: *-85 /+423 evaluate from right
Postfix: 85- 42+3/* evaluate from left
29
31. Complete Binary Tree
Also be defined as a full binary tree in which all
leaves are at depth n or n-1 for some n.
In order for a tree to be the latter kind of complete
binary tree, all the children on the last level must
occupy the leftmost spots consecutively, with no
spot left unoccupied in between any two
A A
B B C
C
D F G D E F G
E
H I J K L M N O
H I 31
Complete binary tree Full binary tree of depth 4
32. Difference between binary and
complete binary tree
BINARY TREE ISN'T NECESSARY THAT ALL OF
LEAF NODE IN SAME LEVEL BUT
COMPLETE BINARY TREE MUST HAVE ALL LEAF
NODE IN SAME LEVEL.
Binary Tree
32
Complete Binary Tree
33. SPANNING TREES
q A spanning tree of a connected graph G is
a sub graph that is a tree and that includes
every vertex of G.
q A minimum spanning tree of a weighted
graph is a spanning tree of least weight
(the sum of the weights of all its edges is
least among all spanning tree).
q Think: “smallest set of edges needed to
connect everything together”
33
34. A graph G and three of its
spanning tree
We can delete any edge without deleting any vertex (to remove
the cycle), but leave the graph connected.
34
35. PRIM’S ALGORITHM
q Choose any edge with smallest weight,
putting it into the spanning tree.
q Successively add to the tree edges of
minimum weight that are incident to a
vertex already in the tree and not forming a
simple circuit with those edges already in
the tree.
q Stop when n – 1 edges have been added.
35
36. EXAMPLE
PRIM’S ALGORITHM
Use Prim’s algorithm to find a minimum spanning tree
in the weighted graph below:
a 2 b 3 c 1 d
3 1 2 5
e 4 f 3 g 3 h
4 2 4 3
i 3 j 3 k 1 l 36
37. SOLUTION
Choice Edge Weight
1 {b, f} 1
a 2 b c 1 d 2 {a, b} 2
3 {f, j} 2
3 1 2 4 {a, e} 3
f 3 g 3 h 5 {i, j} 3
e
6 {f, g} 3
2 3 7 {c, g} 2
8 {c, d} 1
i j 9 {g, h} 3
3 k 1 l
10 {h, l} 3
11 {k, l} 1
Total: 24
37
38. KRUSKAL’S ALGORITHM
q Choose an edge in the graph with
minimum weight.
q Successively add edges with minimum
weight that do not form a simple circuit
with those edges already chosen.
q Stop after n – 1 edges have been
selected.
38
39. Kruskal’s Algorithm
q Pick the cheapest link (edge)
available and mark it
q Pick the next cheapest link available
and mark it again
q Continue picking and marking link
that does not create the circuit
***Kruskal’s algorithm is efficient and
optimal 39
40. EXAMPLE
KRUSKAL’S ALGORITHM
Use Kruskal’s algorithm to find a minimum spanning
tree in the weighted graph below:
a 2 b 3 c 1 d
3 1 2 5
e 4 f 3 g 3 h
4 2 4 3
i 3 j 3 k 1 l 40
41. SOLUTION
Choice Edge Weight
1 {c, d} 1
2 {k, l} 1
a 2 b 3 c 1 d 3 {b, f} 1
4 {c, g} 2
3 1 2 5 {a, b} 2
f g 3 h 6 {f, j} 2
e
7 {b, c} 3
2 8 {j, k} 3
9 {g, h} 3
i j 3 10 {i, j} 3
3 k 1 l
11 {a, e} 3
Total: 24
41
42. TRAVELLING SALESMAN
PROBLEM (TSP)
The goal of the Traveling Salesman Problem
(TSP) is to find the “cheapest” tour of a select
number of “cities” with the following
restrictions:
●
You must visit each city once and only once
●
You must return to the original starting point
42
43. TSP
TSP is similar to these variations of Hamiltonian Circuit
problems:
●
Find the shortest Hamiltonian cycle in a
weighted graph.
●
Find the Hamiltonian cycle in a weighted
graph with the minimal length of the
longest edge. (bottleneck TSP).
A route returning to the beginning is known as a
Hamiltonian Circuit
A route not returning to the beginning is known as a
43
Hamiltonian Path