Balanced binary tree
The disadvantage of a binary search tree is
that its height can be as large as N-1
This means that the time needed to perform
insertion and deletion and many other
operations can be O(N) in the worst case
We want a tree with
Multi-Way Search Trees
Multiway Search Trees
An m-way search tree is a tree in which, for
some integer m called the order of the tree,
each node has at most m children.
If n <= m is the number of children of a node,
then it contains exactly n-1
What is a B+ Tree
A B+ tree is a balanced tree in which every path from
the root of the tree to a leaf is of the same length.
Each non-leaf node of the tree has between [n/2] and
[n] children, where n is fixed for a particular tree.
It contains in
Different kinds of list
Commonly used variation of lists are:
A stack is a data structure that works like a
stack of items, such as pile of plates in
Items can be placed onto top of the stack
Formally define Data structure as:
DS describes not only set of objects but the
they are related,
the set of operations which may be applied to the
elements of data object.
Example: INTEGER data structure con
Graph - 1
Material taken from Fundamentals of Data
Structures in C, Ellis Horowitz and Sartaj Sahni
A graph, G=(V, E), consists of two sets:
a finite set of vertices(V), and
a finite, set of edges(E), may possibly be empty
Graph - 2
Minimum Spanning Trees
Some Graph Operations
Given G=(V,E) and vertex v, find all wV,
such that w connects v.
Depth First Search (DFS)
preorder tree traversal
Breadth First Search (BFS)
level order tree traversal
Balanced Binary Trees
What are they?
A redblack tree is a data structure which is a
type of self-balancing binary search tree.
Their relation to 2-4 trees (B-trees of
2-4 trees are search Trees (but not binary
What is a PRIORITY QUEUE?
Queue that gives access ONLY to the MINIMUM item
Items ARRIVE in ANY order
Items EXIT in MINIMUM order
Priority Queue as an Abstract Data Structure
A priority queue is least-first-out
What is C+ ?
C+ is a Object oriented programming
language. Initially named as C with
C+ was developed at AT & T Bell
C+ is superset of C.
Three important facilities are added
Graph - 3
Single-source (single-destination). Find a shortest
path from a given source (vertex s) to each of the
Single-pair. Given two vertices, find a shortest path
between them. Solution to sing
Brief Notes on C
Structure of C program
/for input/output functions
#define const_name value
cfw_ /* each declarations and
statements are separated by
semi colon */
Inheritance : Extending classes
C+ strongly supports the concept of
C+ classes can be reused by creating
new classes and reusing the properties of
New class can be derived from an old
class. It is called inheritance.
Features of OOP
Emphasis on data rather than
Programs are divided into objects.
Data structures are designed such
that they characterize the objects.
Functions that operate on the data of
an object are tied together in the data
Tries Lexicographical Search
Name comes from middle letters of
word retrieval, rhymes with pie
Represents strings of any type such as
Each path from root to a leaf is one
To avoid confusion, can use endmarker
Threaded Binary Tree
Threaded Binary Trees
Two many null pointers (n+1) in current
representation of binary trees
n: number of nodes
number of non-null links: n-1
total links: 2n
null links: 2n-(n-1)=n+1
Replace these null pointers with some useful
What is a Good Algorithm?
Efficiency as a function of input size:
The number of bits in an input number
Number of data elements (numbers, points)
Measuring the Running Time
Introduction - Data structure
Data structures in computer science deal with
the problem of structuring or
organizing data in computer so that it can be used
efficiently and processed by algorithms.
To a certain extent, dat
15.082 and 6.855J
The Shortest Augmenting Path
Algorithm for the Maximum Flow
Shortest Augmenting Path
This is the original network,
and the original residual
15.082J and 6.855J
March 4, 2003
Introduction to Maximum Flows
The Max Flow Problem
flow on arc (i,j)
capacity of flow in arc (i,j)
0 for each i s,t
What are they?
They are search Trees (but not binary search trees)
They are also known as 2-4, 2-3-4 trees
Multi-way Search Trees
Each internal node of a multi-way search tree T:
has at least two children
stores a collection of items of the
A simple example
finding the maximum of a set S of n numbers
Calculation of T(n):
Assume n = 2k,
T(n) = 2T(n/2)+1
=2k-1 = n-1
2T(n/2)+1 , n>2
Inserting a node, v, into an AVL tree changes the
heights of some of the nodes in T.
The only nodes whose heights can increase are
the ancestors of node v.
If insertion causes T to become unbalanced, then
some ancestor of