Data Structures Unit 4
Data Structures Unit 4
• https://www.youtube.com/watch?v=86mQ1gD3Zgg
Balanced Trees
• A balanced tree is where equal (“almost”) number of nodes exists in
left and right sub trees of each node
• However in practice this is hard to enforce
• We can expect the trees to remain shallow (trivial) by “randomizing”
a data set before inserting to a tree
• Need O(n) operations to randomize the data set
• A relaxed balanced condition can be used in building a “good” tree
12/8/2022 131
`
Floyd Warshall Algorithm-
• Floyd Warshall Algorithm consists of three loops over all the nodes.
• The inner most loop consists of only constant complexity operations.
• Hence, the complexity of Floyd Warshall algorithm is O(n3).
• Here, n is the number of nodes in the given graph.
When Floyd Warshall Algorithm Is Used?