SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Introduction to Algorithms
By
Nilesh Dalvi
Lecturer, Patkar-Varde College.Lecturer, Patkar-Varde College.
http://www.slideshare.net/nileshdalvi01
Java and DataJava and Data
StructuresStructures
Algorithm
The algorithm is defined as the a collection of
unambiguous instructions occurring in some specific
sequence and such an algorithm should produce
output for given set of input in finite amount of time.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm
• write an algorithm to count the sum of n numbers
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm sum (1, n)
{
//Problem Desc: Algorithm for finding sum of n numbers
//Input: 1 to n numbers
//Output: Sum of n numbers
result := 0;
for i:= 1 to n do i:= i + 1
result := result + i;
}
Algorithm
• write an algorithm to check whether the given no is
even or odd.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm EvenOddTest(val)
{
//Problem Desc: Algorithm for checking whether the given no is even or odd.
//Input: 1 to n number
//Output: Even or odd number
if(val % 2 == 0)
write("No is even");
esle
write ("No is odd");
}
Algorithm
• write an algorithm for sorting the given elements
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm Sort (a, n)
{
//Problem Desc: Algorithm for sorting the elements.
//Input: An array
//Output: Sorted array
for i:=1 to n do
{
for j:= i +1 to n-1 do
{
if(a[i]) > a[j]) then
{
temp := a[i];
a[i] := a[j];
a[j] := temp;
}
}
write("List is sorted!");
}
}
Algorithm
• write an algorithm for calculating factorial of n
numbers
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm factCalc (n)
{
//Problem Desc: For calculating factorial of given no
//Input: Number
//Output: Factorial of given number
if n := 1 then
return 1;
else
return n * factCalc(n - 1);
}
Algorithm
• write an algorithm for multiply two matrices
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Algorithm mulMatrix (A, B, n)
{
//Problem Desc: Multilpy two matrices
//Input: Matrix A and Matrix B
//Output: Matrix C
for i := 1 to n do
for j := 1 to n do
C[i][j] := 0;
for k := 1 to n do
C[i][j] := C[i][j] + A[i][k] * B[k][j];
}
Fundamentals of analysis of algorithms
• The efficiency of an algorithm can be decided by
measuring the performance of an algorithm.
• We can measure the performance of an algorithm by
computing two factors
– Amount of time required by an algorithm to execute (time
complexity)
– Amount of storage required by an algorithm (space
complexity)
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Space Complexity
• Space complexity can be defined as amount of memory
required by an algorithm to run.
• To compute space complexity we use two factors : constant
space and variable space
• Constant space includes instructions, variables and constants
• Variable space includes dynamic allocations, function recursion.
• Space requirement, s(p) = C + sp
• sp is the space dependent upon instance characteristics.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Time Complexity
• The time complexity of an algorithm is the amount of computer
time required by an algorithm to run complete the task.
• The time complexity, T(p), taken by a program p is the sum of
the compile time and the run time.
• Total Time, T(p) = compile time + run (execution) time
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Asymptotic Notations:
• To choose the best algorithm, we need to check efficiency of
each algorithm.
• Efficiency can be measured by computing space and time
complexity.
• So, Asymptotic notation is a shorthand way to represent the
time complexity.
• Using asymptotic notations we can give time complexity as
“fastest possible”, “slowest possible” or “average time”.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Big Oh Notation:
• Denoted by ‘O’
• Method if representing upper time of representing the upper
bound of algorithms running time.
• Using big Oh notation we can give longest amount of time taken
by the algorithm to complete.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Omega Notation:
• Denoted by ‘Ω’
• It is used to represent the lower bound of algorithm running
time.
• Using omega (Ω) notation we can denote shortest amount of
time taken by algorithm.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Theta Notation:
• Denoted by ‘Θ’
• By this method the running time is between upper bound and
lower bound.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Data Structure
• Data may be organized in many different ways.
• A data structure is a arrangement of data in a
computer memory or on a disk.
• The logical or mathematical model of a particular
organization of data is called data structure.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Data Structure
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Data Structure Operation
Data appearing in data structures are processed by
means of operations.
Operations are:
•Traversing: Accessing each record exactly once so that
certain items in the record may be processed.
•Searching: Finding the location of the record with a
given key value, or finding the locations of all records
which satisfy one or more conditions.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Data Structure Operation
• Inserting: Adding the new record to the structure.
• Deleting: Removing a record from the structure.
Special operations:
• Sorting: Arranging the records in some logical order
• Merging: Combining the records in two-different
sorted files into a single-sorted file.
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Linear
1. Array:
2. Stack
3. Queue
4. Linked List
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Array
• An array is a collection of homogeneous type of data
elements.
• An array is consisting of a collection of elements .
• Operation Performed On Array:
1. Traversing
2. Search
3. Insertion
4. Deletion
5. Sorting
6. Merging
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
1
2
3
4
5
Representation of array
Stack
• A Stack is a list of elements in which an element may
be inserted or deleted at one end which is known as
TOP of the stack.
• Operation Performed On Array:
1. Push: add an element in stack
2. Pop: remove an element in stack
3. Peek :Current processed element
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
a
b
c TOP
Queue
• A queue is a linear list of element in which insertion
can be done at one end which is known as REAR and
deletion can be done which is known as FRONT.
• Operation:
1. Insertion : add a new element in queue
2. Deletion: Removing an element in queue
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Queue
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Linked List
• A Linked list is a linear collection of data elements .
• It has two part one is info and other is link part.
• info part gives information and link part is address of
next node
• Operation:
1. Traversing
2. Searching
3. Insertion
4. Deletion
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Non-Linear
1. Graph
2. Tree
3. Table
4. Set
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Graph
• A graph is a collection of sets V and E where V is a
finite non-empty set of vertices and E is finite non-
empty set of edges.
• Vertices – node in graph
• Edges – Two adjacent nodes are joined by edges.
• Graph G = {V, E}
• Operation:
1. Insertion
2. Deletion
3. Searching
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Tree
• Tree is a finite set of one or more nodes such that
– There is a specially designed node called root.
– The remaining nodes are partitioned into n>=0 disjoint sets T1, T2, T3,
…., Tn are called the sub-trees of the Root.
• Operation:
1. Insertion
2. Deletion
3. Searching
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Tables
• This is kind of data structure plays an important role in
information retrieval.
• Types of tables:
– Rectangular
– Jagged
– Inverted
– Hash
• Operation:
1. Insertion
2. Deletion
3. Searching
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Key Value
0 “Abc”
1 “Pqr”
Sets
• Heap is a complete binary tree
Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)Ravi Kant Sahu
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming ConceptsBhushan Nagaraj
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaGlenn Guden
 
Session 05 - Strings in Java
Session 05 - Strings in JavaSession 05 - Strings in Java
Session 05 - Strings in JavaPawanMM
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending ClassesNilesh Dalvi
 
Farhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd YearFarhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd Yeardezyneecole
 
05 Java Language And OOP Part V
05 Java Language And OOP Part V05 Java Language And OOP Part V
05 Java Language And OOP Part VHari Christian
 

Was ist angesagt? (19)

7. Multithreading
7. Multithreading7. Multithreading
7. Multithreading
 
11. Arrays
11. Arrays11. Arrays
11. Arrays
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
14. Linked List
14. Linked List14. Linked List
14. Linked List
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Arrays in Java
Arrays in Java Arrays in Java
Arrays in Java
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
List classes
List classesList classes
List classes
 
Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Generics
GenericsGenerics
Generics
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 
Session 05 - Strings in Java
Session 05 - Strings in JavaSession 05 - Strings in Java
Session 05 - Strings in Java
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
Farhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd YearFarhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd Year
 
05 Java Language And OOP Part V
05 Java Language And OOP Part V05 Java Language And OOP Part V
05 Java Language And OOP Part V
 

Andere mochten auch

6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception HandlingNilesh Dalvi
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and IntefacesNilesh Dalvi
 
Presentation for handyman
Presentation for handymanPresentation for handyman
Presentation for handymansteven cornett
 
Palacio Gyeongbokgung (Seoul)
Palacio Gyeongbokgung (Seoul) Palacio Gyeongbokgung (Seoul)
Palacio Gyeongbokgung (Seoul) F. Ovies
 
Partes del computador
Partes del computadorPartes del computador
Partes del computadorCamilo Ospina
 
презентация от РПК групп
презентация от РПК групппрезентация от РПК групп
презентация от РПК группIgor Levchuk
 
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...André Fatala
 

Andere mochten auch (14)

6. Exception Handling
6. Exception Handling6. Exception Handling
6. Exception Handling
 
5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces5. Inheritances, Packages and Intefaces
5. Inheritances, Packages and Intefaces
 
MEDIO AMBIENTE
MEDIO AMBIENTEMEDIO AMBIENTE
MEDIO AMBIENTE
 
Color clipping
Color clippingColor clipping
Color clipping
 
Presentation for handyman
Presentation for handymanPresentation for handyman
Presentation for handyman
 
Palacio Gyeongbokgung (Seoul)
Palacio Gyeongbokgung (Seoul) Palacio Gyeongbokgung (Seoul)
Palacio Gyeongbokgung (Seoul)
 
Partes del computador
Partes del computadorPartes del computador
Partes del computador
 
Liderazgo terminado
Liderazgo terminadoLiderazgo terminado
Liderazgo terminado
 
презентация от РПК групп
презентация от РПК групппрезентация от РПК групп
презентация от РПК групп
 
Ntick tecnología
Ntick tecnologíaNtick tecnología
Ntick tecnología
 
Ciudadanía digital
Ciudadanía digitalCiudadanía digital
Ciudadanía digital
 
Token03
Token03Token03
Token03
 
Strings
StringsStrings
Strings
 
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...Devcommerce 2016: Migração plataforma Magazine Luiza e seu  laboratório de in...
Devcommerce 2016: Migração plataforma Magazine Luiza e seu laboratório de in...
 

Ähnlich wie 10. Introduction to Datastructure

Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using javaNarayan Sau
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfArumugam90
 
Array sorting
Array sortingArray sorting
Array sortingALI RAZA
 
316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasexabhaysonone0
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in CJabs6
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...DrkhanchanaR
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)jehan1987
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structuresSenthil Murugan
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in Onejehan1987
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTSwapnil Mishra
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
Radix and Merge Sort
Radix and Merge SortRadix and Merge Sort
Radix and Merge SortGelo Maribbay
 

Ähnlich wie 10. Introduction to Datastructure (20)

Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
lecture 01.1.ppt
lecture 01.1.pptlecture 01.1.ppt
lecture 01.1.ppt
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Array sorting
Array sortingArray sorting
Array sorting
 
316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex316_16SCCCS4_2020052505222431.pptdatabasex
316_16SCCCS4_2020052505222431.pptdatabasex
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
DAA Notes.pdf
DAA Notes.pdfDAA Notes.pdf
DAA Notes.pdf
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
 
Complexity
ComplexityComplexity
Complexity
 
ch11.ppt
ch11.pptch11.ppt
ch11.ppt
 
DATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGESTDATA STRUCTURES USING C -ENGGDIGEST
DATA STRUCTURES USING C -ENGGDIGEST
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
Radix and Merge Sort
Radix and Merge SortRadix and Merge Sort
Radix and Merge Sort
 

Mehr von Nilesh Dalvi

Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++Nilesh Dalvi
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsNilesh Dalvi
 
Classes and objects
Classes and objectsClasses and objects
Classes and objectsNilesh Dalvi
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 

Mehr von Nilesh Dalvi (9)

2. Basics of Java
2. Basics of Java2. Basics of Java
2. Basics of Java
 
Templates
TemplatesTemplates
Templates
 
File handling
File handlingFile handling
File handling
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 

Kürzlich hochgeladen

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

Kürzlich hochgeladen (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

10. Introduction to Datastructure

  • 1. Introduction to Algorithms By Nilesh Dalvi Lecturer, Patkar-Varde College.Lecturer, Patkar-Varde College. http://www.slideshare.net/nileshdalvi01 Java and DataJava and Data StructuresStructures
  • 2. Algorithm The algorithm is defined as the a collection of unambiguous instructions occurring in some specific sequence and such an algorithm should produce output for given set of input in finite amount of time. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 3. Algorithm • write an algorithm to count the sum of n numbers Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Algorithm sum (1, n) { //Problem Desc: Algorithm for finding sum of n numbers //Input: 1 to n numbers //Output: Sum of n numbers result := 0; for i:= 1 to n do i:= i + 1 result := result + i; }
  • 4. Algorithm • write an algorithm to check whether the given no is even or odd. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Algorithm EvenOddTest(val) { //Problem Desc: Algorithm for checking whether the given no is even or odd. //Input: 1 to n number //Output: Even or odd number if(val % 2 == 0) write("No is even"); esle write ("No is odd"); }
  • 5. Algorithm • write an algorithm for sorting the given elements Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Algorithm Sort (a, n) { //Problem Desc: Algorithm for sorting the elements. //Input: An array //Output: Sorted array for i:=1 to n do { for j:= i +1 to n-1 do { if(a[i]) > a[j]) then { temp := a[i]; a[i] := a[j]; a[j] := temp; } } write("List is sorted!"); } }
  • 6. Algorithm • write an algorithm for calculating factorial of n numbers Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Algorithm factCalc (n) { //Problem Desc: For calculating factorial of given no //Input: Number //Output: Factorial of given number if n := 1 then return 1; else return n * factCalc(n - 1); }
  • 7. Algorithm • write an algorithm for multiply two matrices Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Algorithm mulMatrix (A, B, n) { //Problem Desc: Multilpy two matrices //Input: Matrix A and Matrix B //Output: Matrix C for i := 1 to n do for j := 1 to n do C[i][j] := 0; for k := 1 to n do C[i][j] := C[i][j] + A[i][k] * B[k][j]; }
  • 8. Fundamentals of analysis of algorithms • The efficiency of an algorithm can be decided by measuring the performance of an algorithm. • We can measure the performance of an algorithm by computing two factors – Amount of time required by an algorithm to execute (time complexity) – Amount of storage required by an algorithm (space complexity) Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 9. Space Complexity • Space complexity can be defined as amount of memory required by an algorithm to run. • To compute space complexity we use two factors : constant space and variable space • Constant space includes instructions, variables and constants • Variable space includes dynamic allocations, function recursion. • Space requirement, s(p) = C + sp • sp is the space dependent upon instance characteristics. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 10. Time Complexity • The time complexity of an algorithm is the amount of computer time required by an algorithm to run complete the task. • The time complexity, T(p), taken by a program p is the sum of the compile time and the run time. • Total Time, T(p) = compile time + run (execution) time Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 11. Asymptotic Notations: • To choose the best algorithm, we need to check efficiency of each algorithm. • Efficiency can be measured by computing space and time complexity. • So, Asymptotic notation is a shorthand way to represent the time complexity. • Using asymptotic notations we can give time complexity as “fastest possible”, “slowest possible” or “average time”. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 12. Big Oh Notation: • Denoted by ‘O’ • Method if representing upper time of representing the upper bound of algorithms running time. • Using big Oh notation we can give longest amount of time taken by the algorithm to complete. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 13. Omega Notation: • Denoted by ‘Ω’ • It is used to represent the lower bound of algorithm running time. • Using omega (Ω) notation we can denote shortest amount of time taken by algorithm. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 14. Theta Notation: • Denoted by ‘Θ’ • By this method the running time is between upper bound and lower bound. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 15. Data Structure • Data may be organized in many different ways. • A data structure is a arrangement of data in a computer memory or on a disk. • The logical or mathematical model of a particular organization of data is called data structure. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 16. Data Structure Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 17. Data Structure Operation Data appearing in data structures are processed by means of operations. Operations are: •Traversing: Accessing each record exactly once so that certain items in the record may be processed. •Searching: Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 18. Data Structure Operation • Inserting: Adding the new record to the structure. • Deleting: Removing a record from the structure. Special operations: • Sorting: Arranging the records in some logical order • Merging: Combining the records in two-different sorted files into a single-sorted file. Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 19. Linear 1. Array: 2. Stack 3. Queue 4. Linked List Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 20. Array • An array is a collection of homogeneous type of data elements. • An array is consisting of a collection of elements . • Operation Performed On Array: 1. Traversing 2. Search 3. Insertion 4. Deletion 5. Sorting 6. Merging Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). 1 2 3 4 5 Representation of array
  • 21. Stack • A Stack is a list of elements in which an element may be inserted or deleted at one end which is known as TOP of the stack. • Operation Performed On Array: 1. Push: add an element in stack 2. Pop: remove an element in stack 3. Peek :Current processed element Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). a b c TOP
  • 22. Queue • A queue is a linear list of element in which insertion can be done at one end which is known as REAR and deletion can be done which is known as FRONT. • Operation: 1. Insertion : add a new element in queue 2. Deletion: Removing an element in queue Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 24. Linked List • A Linked list is a linear collection of data elements . • It has two part one is info and other is link part. • info part gives information and link part is address of next node • Operation: 1. Traversing 2. Searching 3. Insertion 4. Deletion Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 25. Non-Linear 1. Graph 2. Tree 3. Table 4. Set Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 26. Graph • A graph is a collection of sets V and E where V is a finite non-empty set of vertices and E is finite non- empty set of edges. • Vertices – node in graph • Edges – Two adjacent nodes are joined by edges. • Graph G = {V, E} • Operation: 1. Insertion 2. Deletion 3. Searching Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 27. Tree • Tree is a finite set of one or more nodes such that – There is a specially designed node called root. – The remaining nodes are partitioned into n>=0 disjoint sets T1, T2, T3, …., Tn are called the sub-trees of the Root. • Operation: 1. Insertion 2. Deletion 3. Searching Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 28. Tables • This is kind of data structure plays an important role in information retrieval. • Types of tables: – Rectangular – Jagged – Inverted – Hash • Operation: 1. Insertion 2. Deletion 3. Searching Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W). Key Value 0 “Abc” 1 “Pqr”
  • 29. Sets • Heap is a complete binary tree Nilesh Dalvi, Lecturer@Patkar-Varde College, Goregaon(W).
  • 30. Q & A