AVL trees are binary search trees where the heights of the left and right subtrees of every node differ by at most 1. This balancing property ensures the height of an AVL tree is O(log n), where n is the number of nodes. Insertion may cause imbalance, in which case rotations are performed to restore the balancing property by traveling up the tree from the inserted node to the first unbalanced ancestor node.
Graphs in the Database: Rdbms In The Social Networks AgeLorenzo Alberton
Despite the NoSQL movement trying to flag traditional databases as a dying breed, the RDBMS keeps evolving and adding new powerful weapons to its arsenal. In this talk we'll explore Common Table Expressions (SQL-99) and how SQL handles recursion, breaking the bi-dimensional barriers and paving the way to more complex data structures like trees and graphs, and how we can replicate features from social networks and recommendation systems. We'll also have a look at window functions (SQL:2003) and the advanced reporting features they make finally possible.
This is the second lecture in the CS 6212 class. Covers asymptotic notation and data structures. Also outlines the coming lectures wherein we will study the various algorithm design techniques.
It is related to Analysis and Design Of Algorithms Subject.Basically it describe basic of topological sorting, it's algorithm and step by step process to solve the example of topological sort.
We will discuss the following: Sorting Algorithms, Counting Sort, Radix Sort, Merge Sort.Algorithms, Time Complexity & Space Complexity, Algorithm vs Pseudocode, Some Algorithm Types, Programming Languages, Python, Anaconda.
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.
Graphs in the Database: Rdbms In The Social Networks AgeLorenzo Alberton
Despite the NoSQL movement trying to flag traditional databases as a dying breed, the RDBMS keeps evolving and adding new powerful weapons to its arsenal. In this talk we'll explore Common Table Expressions (SQL-99) and how SQL handles recursion, breaking the bi-dimensional barriers and paving the way to more complex data structures like trees and graphs, and how we can replicate features from social networks and recommendation systems. We'll also have a look at window functions (SQL:2003) and the advanced reporting features they make finally possible.
This is the second lecture in the CS 6212 class. Covers asymptotic notation and data structures. Also outlines the coming lectures wherein we will study the various algorithm design techniques.
It is related to Analysis and Design Of Algorithms Subject.Basically it describe basic of topological sorting, it's algorithm and step by step process to solve the example of topological sort.
We will discuss the following: Sorting Algorithms, Counting Sort, Radix Sort, Merge Sort.Algorithms, Time Complexity & Space Complexity, Algorithm vs Pseudocode, Some Algorithm Types, Programming Languages, Python, Anaconda.
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.
Dit is de presentatie die ik heb gehouden bij de schaduwverkiezingen voor de nieuwe burgemeester in de gemeente Heumen. Voor Paul Mengde was dat zijn eerste publieke optreden en ik heb hem daar namens
These are the initial design concepts that our team came up with for the design of an automated frisbee thrower.
This document was produced as part of a project in course 15.980 - Product Design and Development - a core course in the System Design Management (http://sdm.mit.edu) program at MIT. We are sharing the information about the project under the Creative Commons (Non Commercial) license.
Team members (SDM 2006): Samuel Chow , Christian LaFon, Matt LaMantia, Spiros Lekkakos, David Schiller, Yoav Shapira, Eugene Xiao
nanoKnowledge Pioneering Learning & Leadership Program is the Asia Pacific's leading experiential learning and leadership program. Founded in 2006 by nanoKnowledge in Singapore and Australia, the program helps participants, particularly students and teachers, expand their horizons and worldview through a variety of educational travel, sports and social responsibility experiences, involving different learning styles, cultures and environments.
nanoKnowledge Pioneering Learning & Leadership Program invites you to become a pioneer learner in the School of Life. To enquire, please visit the nanoKnowledge website: www.nanoknowledge.co
Currently, the Program is open to registered schools, colleges and universities, in both Singapore and Australia. If your organisation is not from Singapore or Australia, do let us know. We will consider your organisation's application on a case by case basis.
2. AVL Tree
AVL trees are 4
balanced. 44
2 3
An AVL Tree is a 17 78
binary search tree 1 2 1
32 50 88
such that for every
1 1
internal node v of 48 62
T, the heights of the
children of v can differ
by at most 1. An example of an AVL tree where
the heights are shown next to the
nodes:
2
3. Height of an AVL Tree
Proposition: The height of an AVL tree T storing
n keys is O(log n).
Justification: The easiest way to approach this
problem is to find n(h): the minimum number of
nodes in an AVL tree of height h.
We see that n(1) = 1 and n(2) = 2
For h ≥ 3, an AVL tree of height h contains the
root node, one AVL subtree of height h-1 and the
other AVL subtree of height h-1 or h-2.
i.e. n(h) = 1 + n(h-1) + n(h-2)
3
4. Height of an AVL Tree (2)
Knowing n(h-1) >= n(h-2), we get
n(h) = n(h-1) + n(h-2) + 1 > 2n(h-2)
n(h) > 2n(h-2)
> 4n(h-4)
> 8n(h-6)
…
> 2in(h-2i)
When i = h/2-1 we get: n(h) > 2h/2-1n(2) = 2h/2
Taking logarithms: h < 2log n(h)
Thus the height of an AVL tree is O(log n)
4
5. A sharper bound
We will show how to obtain a sharper
bound on the height of an AVL tree.
We prove using induction that the minimum
number of nodes in an AVL tree of height
h, n(h) >= ch, where c is some number >1.
Base case: h=1. Now n(h) >= c > 1.
Suppose claim is true for all h < k
We have to show that n(k) >= ck
5
6. Sharper bound (2)
n(k) = n(k-1)+n(k-2)+1
>= ck-1 + ck-2 (by induction hypothesis)
We will be able to show that n(k) >= ck if we can
show that ck-1 + ck-2 >= ck.
So c should be such that c2-c-1 <= 0.
The quadratic equation c2-c-1=0 has
roots and .
Hence we can take c as which is roughly
1.63
Hence AVL tree on n nodes has height atmost
log1.63 n
6
7. Structure of an AVL tree
Consider an AVL tree on n nodes.
Consider a leaf which is closest to the
root.
Suppose this leaf is at level k.
We will show that the height of the tree is
at most 2k-1.
7
8. Structure of an AVL tree (2)
Claim: Since closest leaf is at level k all nodes at
levels 1..k-2 have 2 children.
Proof is by contradiction
Suppose node u at level k-2 has only 1 child, v.
v is at level k-1 and so cannot be a leaf.
Hence subtree rooted at v has height at least 2.
Height-balanced property is violated at u
k-2
u
k-1
v
8
9. Structure of an AVL tree (3)
By previous claim, all levels 1 to k-1 are
full.
Hence tree has at least 2k-1 nodes.
Since height of tree is at most 2k-1 it has
at most 22k-1 nodes.
Thus 2k-1 <= n <= 22k-1
Substituting h for 2k-1 we get
2(h-1)/2 <= n <= 2h
9
10. Summary of AVL tree structure
In an AVL tree of height h, the leaf closest
to the root is at level at least (h+1)/2.
On the first (h-1)/2 levels the AVL tree is a
complete binary tree.
After (h-1)/2 levels the AVL tree may start
“thinning out”.
Number of nodes in the AVL tree is at least
2(h-1)/2 and at most 2h
10
11. Insertion
A binary tree T is called height-balanced if for
every node v, height of v’s children differ by atmost
one.
Inserting a node into an AVL tree changes the
heights of some of the nodes in T.
If insertion causes T to become unbalanced, we
travel up the tree from the newly created node until
we find the first node x such that its grandparent z
is unbalanced node.
Let y be the parent of node x.
11
12. Insertion (2)
5
44
2
z 4
To rebalance the 17 78
y
subtree rooted at 1 3 1
32 50 88
z, we must perform a 1
2 x
rotation. 48
1
62
54
4
44
2 3 x
17 62 z
y
1 2 2
32 50 78
1 1 1
48 54 88
12