SlideShare a Scribd company logo
1 of 25
Algorithm
Different Applications of Algorithms
List and discuss different applications of algorithm
Apply algorithms to the following areas:
• Sorting
• Searching
• String Processing
• Combinational problems
• Geometric Problems
• Numerical Problems
• Different Applications
• Sorting
• Searching
• String Processing
• Combinational problems
• Geometric Problems
• Numerical Problems
IMPORTANT PROBLEM TYPES
•sorting
•searching
•string processing
•graph problems
•combinatorial problems
•geometric problems
•numerical problems
SORTING
Rearrange the items of a given list in ascending order.
Input: A sequence of n numbers <a1, a2, …, an>
Output: A reordering <a´
1, a´
2, …, a´
n> of the input sequence such
that a´
1≤ a´
2 ≤ … ≤ a´
n.
Why sorting?
Help searching
Algorithms often use sorting as a key subroutine.
Sorting key
A specially chosen piece of information used to guide sorting. E.g.,
sort student records by names.
SORTING
Examples of sorting algorithms
Selection sort Bubble sort
Insertion sort Merge sort Heap sort …
Evaluate sorting algorithm complexity: the number of key
comparisons.
Two properties
Stability: A sorting algorithm is called stable if it preserves the
relative order of any two equal elements in its input.
In place : A sorting algorithm is in place if it does not require
extra memory, except, possibly for a few memory units.
SEARCHING
• Find a given value, called a
search key, in a given set.
• Examples of searching
algorithms
• Sequential search
• As its name suggests, you go through
whole data sequentially until you find
the match.
• Binary search
• As its name suggests, at each stage
you can divide data into two (bi) parts.
Here you don’t have to traverse
through whole data.
Example: searching in a sorted array. you
will start comparing with middle, if value
to be searched is less than middle you
know it is somewhere in the left half and if
it is greater than middle one, you know it
is in second half. you can continue the
same process until you find your match.
binary search tree is another classical example of
binary search. In this data is not sorted but it is
stored in the memory that way.
STRING PROCESSING
A string is a sequence of characters from an alphabet.
Text strings: letters, numbers, and special characters.
String matching: searching for a given word/pattern in a text.
Examples:
(i) searching for a word or phrase on WWW or in a
Word document
(ii) searching for a short read in the reference
genomic sequence
GRAPH PROBLEMS
A graph is a collection of points called vertices, some
of which are connected by line segments called
edges.
Modeling real-life problems
Modeling WWW
Communication networks
Project scheduling …
Examples of graph algorithms
Graph traversal algorithms
Shortest-path algorithms
Topological sorting
FUNDAMENTAL DATA STRUCTURES
List
 Array
 Linked list
 String
Stack
Queue
Priority queue/heap
Graph
Tree and binary tree
Set and dictionary
LINEAR DATA STRUCTURES
ARRAYS
A sequence of n items of the same data type that are
stored contiguously in computer memory and made
accessible by specifying a value of the array’s index.
LINKED LIST
A sequence of zero or more nodes each containing two
kinds of information: some data and one or more links
called pointers to other nodes of the linked list.
Singly linked list (next pointer)
Doubly linked list (next + previous pointers)
ARRAY VS LINKED LIST
ARRAYS
fixed length (need preliminary reservation of memory)
contiguous memory locations
direct access
Insert/delete
LINKED LISTS
dynamic length
arbitrary memory locations
access by following links
Insert/delete
STACKS AND QUEUES
STACKS
A stack of plates
insertion/deletion can be done only at the top.
LIFO / FILO
Two operations (push and pop)
QUEUES
A queue of customers waiting for services
Insertion/enqueue from the rear and
deletion/dequeue from the front.
FIFO / LILO
Two operations (enqueue and dequeue)
PRIORITY QUEUE AND HEAP
 Priority queues (implemented using heaps)
 A data structure for maintaining a set of
elements, each associated with a key/priority, with
the following operations
 Finding the element with the highest priority
 Deleting the element with the highest priority
 Inserting a new element
 Scheduling jobs on a shared computer
GRAPHS
Formal definition
A graph G = <V, E> is defined by a pair of two
sets: a finite set V of items called vertices and a
set E of vertex pairs called edges.
Undirected and directed graphs (digraphs).
What’s the maximum number of edges in an undirected
graph with |V| vertices?
Complete, dense graphs
Graph Representation
• Adjacency matrix
• n x n boolean matrix if |V| is n.
• The element on the ith row and jth column is 1 if there’s an
edge from ith vertex to the jth vertex; otherwise 0.
• The adjacency matrix of an undirected graph is symmetric.
• Adjacency linked lists
• A collection of linked lists, one for each vertex, that contain all
the vertices adjacent to the list’s vertex.
WEIGHTED GRAPHS
WEIGHTED GRAPHS
• Graphs or digraphs with numbers assigned to
the edges.
1 2
3 4
6
8
5
7
9
GRAPH PROPERTIES
Paths
A path from vertex u to v of a graph G is defined as a
sequence of adjacent (connected by an edge)
vertices that starts with u and ends with v.
Simple paths: All edges of a path are distinct.
Path lengths: the number of edges, or the number of
vertices – 1.
Connected graphs
A graph is said to be connected if for every pair of its
vertices u and v there is a path from u to v.
Connected component
The maximum connected subgraph of a given graph.
GRAPHS
CYCLE
A simple path of a positive length that starts and
ends a the same vertex.
ACYCLIC GRAPH
A graph without cycles
DAG (Directed Acyclic Graph)
1 2
3 4
TREES
TREES
A tree (or free tree) is a connected acyclic graph.
Forest: a graph that has no cycles but is not necessarily
connected.
PROPERTIES OF TREES
For every two vertices in a tree there always exists
exactly one simple path from one of these vertices to
the other.
Rooted trees: The above property makes it possible to select
an arbitrary vertex in a free tree and consider it as the root of
the so called rooted tree.
Levels in a rooted tree.
ROOTED TREES
Ancestors
For any vertex v in a tree T, all the vertices on the
simple path from the root to that vertex are called
ancestors.
Descendants
All the vertices for which a vertex v is an ancestor
are said to be descendants of v.
Parent, child and siblings
If (u, v) is the last edge of the simple path from the
root to vertex v, u is said to be the parent of v and v
is called a child of u.
Vertices that have the same parent are called
siblings.
ROOTED TREES
LEAVES
A vertex without children is called a leaf.
SUBTREE
A vertex v with all its descendants is called the
subtree of T rooted at v.
DEPTH OF A VERTEX
The length of the simple path from the root to the
vertex.
HEIGHT OF A TREE
The length of the longest simple path from the root
to a leaf.
ROOTED TREE
Height = 2
Depth 1 = 1
Depth 2 = 2
Depth 5 = 1
Depth 4 = 1
1
3
2
4 5
ORDERED TREES
ORDERED TREES
• An ordered tree is a rooted tree in which all the children
of each vertex are ordered.
BINARY TREES
• A binary tree is an ordered tree in which every vertex
has no more than two children and each children is
designated s either a left child or a right child of its
parent.
BINARY SEARCH TREES
• Each vertex is assigned a number.
• A number assigned to each parental vertex is larger than
all the numbers in its left subtree and smaller than all the
numbers in its right subtree.

More Related Content

Similar to ntroduction to Algorithm 2.pptx

Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
Data structure study material introduction
Data structure study material introductionData structure study material introduction
Data structure study material introduction
SwatiShinde79
 

Similar to ntroduction to Algorithm 2.pptx (20)

Bsc cs ii dfs u-3 tree and graph
Bsc cs  ii dfs u-3 tree and graphBsc cs  ii dfs u-3 tree and graph
Bsc cs ii dfs u-3 tree and graph
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graph
 
Q
QQ
Q
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
 
Graphs
GraphsGraphs
Graphs
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
data structures and algorithms Unit 2
data structures and algorithms Unit 2data structures and algorithms Unit 2
data structures and algorithms Unit 2
 
Graphs data structures
Graphs data structuresGraphs data structures
Graphs data structures
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
 
presentation on important DAG,TRIE,Hashing.pptx
presentation on important DAG,TRIE,Hashing.pptxpresentation on important DAG,TRIE,Hashing.pptx
presentation on important DAG,TRIE,Hashing.pptx
 
PM.ppt
PM.pptPM.ppt
PM.ppt
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
PM.ppt
PM.pptPM.ppt
PM.ppt
 
Graph Basic In Data structure
Graph Basic In Data structureGraph Basic In Data structure
Graph Basic In Data structure
 
Data structure study material introduction
Data structure study material introductionData structure study material introduction
Data structure study material introduction
 
1597380885789.ppt
1597380885789.ppt1597380885789.ppt
1597380885789.ppt
 
Unit VI - Graphs.ppt
Unit VI - Graphs.pptUnit VI - Graphs.ppt
Unit VI - Graphs.ppt
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
 
18 Basic Graph Algorithms
18 Basic Graph Algorithms18 Basic Graph Algorithms
18 Basic Graph Algorithms
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

ntroduction to Algorithm 2.pptx

  • 3. List and discuss different applications of algorithm Apply algorithms to the following areas: • Sorting • Searching • String Processing • Combinational problems • Geometric Problems • Numerical Problems
  • 4. • Different Applications • Sorting • Searching • String Processing • Combinational problems • Geometric Problems • Numerical Problems
  • 5. IMPORTANT PROBLEM TYPES •sorting •searching •string processing •graph problems •combinatorial problems •geometric problems •numerical problems
  • 6. SORTING Rearrange the items of a given list in ascending order. Input: A sequence of n numbers <a1, a2, …, an> Output: A reordering <a´ 1, a´ 2, …, a´ n> of the input sequence such that a´ 1≤ a´ 2 ≤ … ≤ a´ n. Why sorting? Help searching Algorithms often use sorting as a key subroutine. Sorting key A specially chosen piece of information used to guide sorting. E.g., sort student records by names.
  • 7. SORTING Examples of sorting algorithms Selection sort Bubble sort Insertion sort Merge sort Heap sort … Evaluate sorting algorithm complexity: the number of key comparisons. Two properties Stability: A sorting algorithm is called stable if it preserves the relative order of any two equal elements in its input. In place : A sorting algorithm is in place if it does not require extra memory, except, possibly for a few memory units.
  • 8. SEARCHING • Find a given value, called a search key, in a given set. • Examples of searching algorithms • Sequential search • As its name suggests, you go through whole data sequentially until you find the match. • Binary search • As its name suggests, at each stage you can divide data into two (bi) parts. Here you don’t have to traverse through whole data. Example: searching in a sorted array. you will start comparing with middle, if value to be searched is less than middle you know it is somewhere in the left half and if it is greater than middle one, you know it is in second half. you can continue the same process until you find your match. binary search tree is another classical example of binary search. In this data is not sorted but it is stored in the memory that way.
  • 9. STRING PROCESSING A string is a sequence of characters from an alphabet. Text strings: letters, numbers, and special characters. String matching: searching for a given word/pattern in a text. Examples: (i) searching for a word or phrase on WWW or in a Word document (ii) searching for a short read in the reference genomic sequence
  • 10. GRAPH PROBLEMS A graph is a collection of points called vertices, some of which are connected by line segments called edges. Modeling real-life problems Modeling WWW Communication networks Project scheduling … Examples of graph algorithms Graph traversal algorithms Shortest-path algorithms Topological sorting
  • 11. FUNDAMENTAL DATA STRUCTURES List  Array  Linked list  String Stack Queue Priority queue/heap Graph Tree and binary tree Set and dictionary
  • 12. LINEAR DATA STRUCTURES ARRAYS A sequence of n items of the same data type that are stored contiguously in computer memory and made accessible by specifying a value of the array’s index. LINKED LIST A sequence of zero or more nodes each containing two kinds of information: some data and one or more links called pointers to other nodes of the linked list. Singly linked list (next pointer) Doubly linked list (next + previous pointers)
  • 13. ARRAY VS LINKED LIST ARRAYS fixed length (need preliminary reservation of memory) contiguous memory locations direct access Insert/delete LINKED LISTS dynamic length arbitrary memory locations access by following links Insert/delete
  • 14. STACKS AND QUEUES STACKS A stack of plates insertion/deletion can be done only at the top. LIFO / FILO Two operations (push and pop) QUEUES A queue of customers waiting for services Insertion/enqueue from the rear and deletion/dequeue from the front. FIFO / LILO Two operations (enqueue and dequeue)
  • 15. PRIORITY QUEUE AND HEAP  Priority queues (implemented using heaps)  A data structure for maintaining a set of elements, each associated with a key/priority, with the following operations  Finding the element with the highest priority  Deleting the element with the highest priority  Inserting a new element  Scheduling jobs on a shared computer
  • 16. GRAPHS Formal definition A graph G = <V, E> is defined by a pair of two sets: a finite set V of items called vertices and a set E of vertex pairs called edges. Undirected and directed graphs (digraphs). What’s the maximum number of edges in an undirected graph with |V| vertices? Complete, dense graphs
  • 17. Graph Representation • Adjacency matrix • n x n boolean matrix if |V| is n. • The element on the ith row and jth column is 1 if there’s an edge from ith vertex to the jth vertex; otherwise 0. • The adjacency matrix of an undirected graph is symmetric. • Adjacency linked lists • A collection of linked lists, one for each vertex, that contain all the vertices adjacent to the list’s vertex.
  • 18. WEIGHTED GRAPHS WEIGHTED GRAPHS • Graphs or digraphs with numbers assigned to the edges. 1 2 3 4 6 8 5 7 9
  • 19. GRAPH PROPERTIES Paths A path from vertex u to v of a graph G is defined as a sequence of adjacent (connected by an edge) vertices that starts with u and ends with v. Simple paths: All edges of a path are distinct. Path lengths: the number of edges, or the number of vertices – 1. Connected graphs A graph is said to be connected if for every pair of its vertices u and v there is a path from u to v. Connected component The maximum connected subgraph of a given graph.
  • 20. GRAPHS CYCLE A simple path of a positive length that starts and ends a the same vertex. ACYCLIC GRAPH A graph without cycles DAG (Directed Acyclic Graph) 1 2 3 4
  • 21. TREES TREES A tree (or free tree) is a connected acyclic graph. Forest: a graph that has no cycles but is not necessarily connected. PROPERTIES OF TREES For every two vertices in a tree there always exists exactly one simple path from one of these vertices to the other. Rooted trees: The above property makes it possible to select an arbitrary vertex in a free tree and consider it as the root of the so called rooted tree. Levels in a rooted tree.
  • 22. ROOTED TREES Ancestors For any vertex v in a tree T, all the vertices on the simple path from the root to that vertex are called ancestors. Descendants All the vertices for which a vertex v is an ancestor are said to be descendants of v. Parent, child and siblings If (u, v) is the last edge of the simple path from the root to vertex v, u is said to be the parent of v and v is called a child of u. Vertices that have the same parent are called siblings.
  • 23. ROOTED TREES LEAVES A vertex without children is called a leaf. SUBTREE A vertex v with all its descendants is called the subtree of T rooted at v. DEPTH OF A VERTEX The length of the simple path from the root to the vertex. HEIGHT OF A TREE The length of the longest simple path from the root to a leaf.
  • 24. ROOTED TREE Height = 2 Depth 1 = 1 Depth 2 = 2 Depth 5 = 1 Depth 4 = 1 1 3 2 4 5
  • 25. ORDERED TREES ORDERED TREES • An ordered tree is a rooted tree in which all the children of each vertex are ordered. BINARY TREES • A binary tree is an ordered tree in which every vertex has no more than two children and each children is designated s either a left child or a right child of its parent. BINARY SEARCH TREES • Each vertex is assigned a number. • A number assigned to each parental vertex is larger than all the numbers in its left subtree and smaller than all the numbers in its right subtree.

Editor's Notes

  1. Example: Selection discussed earlier
  2. In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation). A string is generally considered as a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. String may also denote more general arrays or other sequence (or list) data types and structures.
  3. MAX EDGE = ( n (n-1) ) / 2 A graph with every pair of its vertices connected by an edge is called complete, K|V| Dense – graph with number of edges close to the maximum number of edges for the graph