SlideShare a Scribd company logo
DMI-ST. JOHN THE BAPTIST UNIVERSITY
LILONGWE, MALAWI
Module Code: 351CS34
Subject Name: DATA STRUCTURE AND ALGORITHM
Unit I Detail Notes
School of Computer Science
Module Teacher: Fanny Chatola
Syllabus
Introduction to Algorithm and Data Structures:
Algorithms- Problem Solving, Introduction to Algorithms, Characteristics of algorithms, Algorithm design tools:
Pseudo code and flowchart, Analysis of Algorithms, Complexity of algorithms - Space complexity, Time
complexity, Asymptotic notation - Big-O, Theta and Omega, standard measures of efficiency. Data Structures-
Data structure, Abstract Data Types (ADT), Concept of linear and Non-linear, static and dynamic, persistent
and ephemeral data structures, and relationship among data, data structure, and algorithm, From Problem to
Program. Algorithmic Strategies- Introduction to algorithm design strategies - Divide and Conquer, and Greedy
strategy. Recurrence relation - Recurrence Relation, Linear Recurrence Relations, With constant Coefficients,
Homogeneous Solutions. Solving recurrence relations.
TABLE OF CONTENTS
No table of contents entries found.
Problem Solving:
 For finding solution to problems
 It is used in many disciplines
Ex: Problems
1. Sorting
2. Searching
3. String problem
4. Graph problems
5. Combinational problems
6. Geometric problems
7. Numerical problems
Introduction to algorithms:
An algorithm is a step by step instruction for solving problems.
Ex: Euclid’s algorithm for calculate gcd(m,n)
 Gcd means greatest common divisor of two non negative integers
Instructions:
Step 1: if n=0, return the value of m as the answer and stop; otherwise proceed to step2.
Step 2: Divide m by n and assign the value of the remainder to r.
Step 3: Assign the value of n to m and the value of r to n go to step 1.
Algorithm:
While n≠0 do
r ← m mod n
m ← n
n ← r
return m
Characteristic of Algorithm:
1. Time efficiency – how fast the algorithm runs.
2. Space efficiency – how much extra memory used
3. Simplicity – simpler than the other algorithms
4. Generality –the algorithm solves and the range of inputs it accepts and used
more general terms.
Algorithm design tools:
1. Pseudo code
2. Flow chart
Pseudo Code:
• It is a mixture of a natural language and programming language Flow chart:
• Pictorial representation of an algorithm Analysis of an Algorithm:
• To analysis quality and efficiency of algorithm complexity
1.Time Complexity
2.Space Complexity
Time Complexity:
• It indicates how fast the algorithm runs.
Space Complexity:
• It indicates how much extra memory that algorithm needs.
Asymptotic Notation:
• To compare and rank such orders of growth of an algorithm is called Asymptotic notation
• It is classified into three types
1. Big oh notation – O
2. Big omega notation – Ω
3. Big theta notation – Ɵ Big oh notation:
• It is used to define the worst case running time of an algorithm.
Def: T(n) = Of(n), if there are positive constants T(n) ≤ Cf(n)
Big omega notation:
• It is used to define the best case running time of an algorithm
Def: T(n) = Ωf(n), if there are positive constants T(n) ≥ Cf(n)
Big Theta notation:
• It is used to define the average case running time of algorithms.
C1f(n) C2f(n)
N
No
Cf(n)
T(n)
N
No
T(n)
C(f(n)
No N
T(n)
Def: T(n) =Ɵf(n), if there are positive constants T(n)=Of(n) and T(n)=Ωf(n)
Data Structures:
• Data structures are a particular way of organizing data in a computer.
• It is used to storing and retrieving data from a computer.
Abstract Data Type:
• Abstract Data Type is an extension of modular design.
• It is a set of operation such as union, intersection, complement, find and etc.
• It use to written once in program and can be called by any part of the program.
Example:
Store (V, X)
X- is the value of unspecified
V- is the fields value
Application of Data Structures:
• Operating Systems
• Compiler design
• Statistical and numerical analysis
• Database management systems
• Expert systems
• Network analysis
Classification of Data Structures:
• It is classified into two types
1. Primitive Data Structure
2. Non Primitive Data Structure
Primitive Data Structures:
• It can be directly operated by the machine instruction Ex: Integer, float, char, pointer and etc.
Non Primitive Data Structures:
• It structuring of a group of homogeneous and heterogeneous data items.
o Homogeneous – uniform character o
Heterogeneous – un uniform character
• It is classified into two types
1. Linear Data Structure
2. Non Linear Data
Structure Linear Data Structure:
• It contains a linear arrangement of elements in the memory. Ex: stack, array, linked list and queue
Non Linear Data Structure:
• It contains a hierarchical arrangement of elements Ex: trees, graph Static:
• Static means prefixed while declaring a value. Ex: static int x=10;
Dyanamic:
• Dynamic means change the variable size or value.
• Ex: int a;
Persistent and ephemeral data structures:
Persistent Data Structure:(Functional)
• It is a data structure that always preserves the previous version of itself when it is modified
• The data structure is fully persistent if every version can be both accessed and modified.
Ephemeral Data Structures: (Non Functional)
• Structures that are not persistent are called Ephemeral Data Structure.
Ex: Persistent queue, merge operation
Algorithmic Strategies:
• There are a number of general and powerful computational strategies that are repeatedly used.
1. Divide and Conquer
2. Dynamic programming
3. Greedy strategy
4. Back tracking
5. Branch and Bound Technique Divide and Conquer:
• This technique is used to dividing a problem into two smaller sub problems.
• The sub problems are solved separately.
• The solutions obtained for the sub problems are combined to get a solution to the original problem.
a
b c
d e f
Greedy Strategy:
• The greedy approach suggests constructing solution through a sequence of steps, each expanding a
partially constructed solution obtained. So far, until a complete solution to the problem is reached.
o Feasible – satisfy the problem’s conditions o Locally optimal – to be the best
local choice among all feasible choice o Irrevocable – once made it cannot be
changed.
Ex: Change – Making Problem.
Recurrence Relation:
• It defines a sequence or multidimensional array of value once one or more initial terms are given.
Ex: Fibonacci numbers
Fn=F𝑛−1+𝐹n-2
0,1,1,2,3,5,8,……….
Linear Recurrence Relation:
• A Linear recurrence relation is an equation that relates a term in sequence or multidimensional array.
• The word linear refers to the fact that previous terms are arranged. Ex: Xn=C1Xn-1+C2xn-
2+……..+CkXn-k Homogeneous Linear Recurrence Relation:
• All the terms have the same exponent.
ak=Aak-1 + Bak-2
Linear ak=1
Homogeneous = same exponent Solving
Recurrence Relation:
• There are few techniques for converting recursive definition to closed formulas is called solving a
recurrence relation. Ex:
𝑎𝑛= 𝑎𝑛−1+n with initial terms 𝑎0=4
Problems
Sub Problem 1 Sub Problem 2
Solution to Sub
Problems 1
Solution to the
Original Problem
Solution to Sub
Problems 2
Sequence of 4, 5, 7, 10, 14, 19……..
 𝑎1-𝑎0=1 and 𝑎2 -𝑎1=2 so on.
 𝑎𝑛−𝑎𝑛−1 = n
 Changing n each time
 𝑎1-𝑎0 = 1
 𝑎2 -𝑎1 = 2
 𝑎3 -𝑎2 = 3  : :
 𝑎𝑛-𝑎𝑛−1 = n
 Sum = 1+2+3+……..+n.  Simplified = n(n+1)/2
 (𝑎1-𝑎0 ) + (𝑎2-𝑎1 ) + (𝑎3-𝑎0 ) + ………+(𝑎𝑛−1-𝑎𝑛−2 ) + (𝑎𝑛-𝑎𝑛−1 ).  𝑎𝑛 = n(n+1)/2+4
Ad

Recommended

Introduction to data structures and its types
Introduction to data structures and its types
sonalishinge2015
 
Ch 1 intriductions
Ch 1 intriductions
irshad17
 
ADS Introduction
ADS Introduction
NagendraK18
 
jn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 
Iare ds ppt_3
Iare ds ppt_3
AlugatiRajitha
 
DATA STRUCTURE
DATA STRUCTURE
RobinRohit2
 
DATA STRUCTURE.pdf
DATA STRUCTURE.pdf
ibrahim386946
 
DSA.pptx based on basic dsa concepts for engineers
DSA.pptx based on basic dsa concepts for engineers
SaketKumar846792
 
Unit 1 dsa
Unit 1 dsa
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
Adelina Ahadova
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
Aniruddha Paul
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
introduction to data structures and types
introduction to data structures and types
ankita946617
 
Data structures notes for college students btech.pptx
Data structures notes for college students btech.pptx
KarthikVijay59
 
3rd-Sem_CSE_Data-Structures and Applications.docx
3rd-Sem_CSE_Data-Structures and Applications.docx
harshavardhan543715
 
project on data structures and algorithm
project on data structures and algorithm
AnujKumar566766
 
Array Data StructureData StructureData Structure.pptx
Array Data StructureData StructureData Structure.pptx
menukam354
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
Prof. Dr. K. Adisesha
 
Data Structures unit I Introduction - data types
Data Structures unit I Introduction - data types
AmirthaVarshini80
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim2
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
Intro C# Book
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Lec2-Array.pptx
Lec2-Array.pptx
FaheemMahmood2
 
Data structures
Data structures
Edward Blurock
 
8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
RavishankarBhaganaga
 
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
NGUYNTHNHQUC2
 
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
prathamsingh33
 
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
FIONACHATOLA
 
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
FIONACHATOLA
 

More Related Content

Similar to in computer data structures and algorithms (20)

Unit 1 dsa
Unit 1 dsa
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
Adelina Ahadova
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
Aniruddha Paul
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
introduction to data structures and types
introduction to data structures and types
ankita946617
 
Data structures notes for college students btech.pptx
Data structures notes for college students btech.pptx
KarthikVijay59
 
3rd-Sem_CSE_Data-Structures and Applications.docx
3rd-Sem_CSE_Data-Structures and Applications.docx
harshavardhan543715
 
project on data structures and algorithm
project on data structures and algorithm
AnujKumar566766
 
Array Data StructureData StructureData Structure.pptx
Array Data StructureData StructureData Structure.pptx
menukam354
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
Prof. Dr. K. Adisesha
 
Data Structures unit I Introduction - data types
Data Structures unit I Introduction - data types
AmirthaVarshini80
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim2
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
Intro C# Book
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Lec2-Array.pptx
Lec2-Array.pptx
FaheemMahmood2
 
Data structures
Data structures
Edward Blurock
 
8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
RavishankarBhaganaga
 
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
NGUYNTHNHQUC2
 
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
prathamsingh33
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
Adelina Ahadova
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
Aniruddha Paul
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
introduction to data structures and types
introduction to data structures and types
ankita946617
 
Data structures notes for college students btech.pptx
Data structures notes for college students btech.pptx
KarthikVijay59
 
3rd-Sem_CSE_Data-Structures and Applications.docx
3rd-Sem_CSE_Data-Structures and Applications.docx
harshavardhan543715
 
project on data structures and algorithm
project on data structures and algorithm
AnujKumar566766
 
Array Data StructureData StructureData Structure.pptx
Array Data StructureData StructureData Structure.pptx
menukam354
 
Data Structures unit I Introduction - data types
Data Structures unit I Introduction - data types
AmirthaVarshini80
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
Intro C# Book
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
1-Algorithm Analysijhjhjhjhjhjhjhjhjhjs.pdf
NGUYNTHNHQUC2
 
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
Unit 1 OF DS FOR AI DS BTRCH OF DS FOR AI DS BTRCH .pdf
prathamsingh33
 

More from FIONACHATOLA (18)

ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
FIONACHATOLA
 
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
FIONACHATOLA
 
business intelligence and analytics notes
business intelligence and analytics notes
FIONACHATOLA
 
VOICE OVER INTERNET PROTOCOL(VOIP) notes
VOICE OVER INTERNET PROTOCOL(VOIP) notes
FIONACHATOLA
 
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
FIONACHATOLA
 
Unit I Data structure and algorithms notes
Unit I Data structure and algorithms notes
FIONACHATOLA
 
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
FIONACHATOLA
 
computer Hardware and trouble shooting Basics
computer Hardware and trouble shooting Basics
FIONACHATOLA
 
Introduction to Email, internet protocols
Introduction to Email, internet protocols
FIONACHATOLA
 
Introduction to Internet Protocol ADDRESS.pptx
Introduction to Internet Protocol ADDRESS.pptx
FIONACHATOLA
 
introduction to OSI MODEL-WPS Office.pptx
introduction to OSI MODEL-WPS Office.pptx
FIONACHATOLA
 
computer system organization and architecture
computer system organization and architecture
FIONACHATOLA
 
computer fundamentals -e- notes for IT & CS
computer fundamentals -e- notes for IT & CS
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
ARTIFICIAL INTELLIGENCE CONSTRAINT SATISFACTION PROBLEMS (CSPS) AND MINI-MAX....
FIONACHATOLA
 
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
ARTIFICAIL INTELLIGENCE AO ALGORITHMS NOTES
FIONACHATOLA
 
business intelligence and analytics notes
business intelligence and analytics notes
FIONACHATOLA
 
VOICE OVER INTERNET PROTOCOL(VOIP) notes
VOICE OVER INTERNET PROTOCOL(VOIP) notes
FIONACHATOLA
 
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
PC HARWARE AND TROUBLE SHOOTING INTRODUCTION
FIONACHATOLA
 
Unit I Data structure and algorithms notes
Unit I Data structure and algorithms notes
FIONACHATOLA
 
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
UG_B.Sc._Information Technology_129 14_Office Automation Lab.pdf
FIONACHATOLA
 
computer Hardware and trouble shooting Basics
computer Hardware and trouble shooting Basics
FIONACHATOLA
 
Introduction to Email, internet protocols
Introduction to Email, internet protocols
FIONACHATOLA
 
Introduction to Internet Protocol ADDRESS.pptx
Introduction to Internet Protocol ADDRESS.pptx
FIONACHATOLA
 
introduction to OSI MODEL-WPS Office.pptx
introduction to OSI MODEL-WPS Office.pptx
FIONACHATOLA
 
computer system organization and architecture
computer system organization and architecture
FIONACHATOLA
 
computer fundamentals -e- notes for IT & CS
computer fundamentals -e- notes for IT & CS
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
theory of computation notes for school of engineering
theory of computation notes for school of engineering
FIONACHATOLA
 
Ad

Recently uploaded (20)

MOLD -GENERAL CHARACTERISTICS AND CLASSIFICATION
MOLD -GENERAL CHARACTERISTICS AND CLASSIFICATION
aparnamp966
 
Gas Exchange in Insects and structures 01
Gas Exchange in Insects and structures 01
PhoebeAkinyi1
 
Properties of Gases siwhdhadpaldndn.pptx
Properties of Gases siwhdhadpaldndn.pptx
CatherineJadeBurce
 
History of Nursing and Nursing As A Profession UNIT-3.pptx
History of Nursing and Nursing As A Profession UNIT-3.pptx
madhusrinivas68
 
lysosomes "suicide bags of cell" and hydrolytic enzymes
lysosomes "suicide bags of cell" and hydrolytic enzymes
kchaturvedi070
 
The Gender Binary & LGBTI People: Religious Myth and Medical Malpractice
The Gender Binary & LGBTI People: Religious Myth and Medical Malpractice
Veronica Drantz, PhD
 
What is Skeleton system.pptx by aahil sir
What is Skeleton system.pptx by aahil sir
bhatbashir421
 
EV REGENERATIVE ACCELERATION INNOVATION SUMMARY PITCH June 13, 2025.pdf
EV REGENERATIVE ACCELERATION INNOVATION SUMMARY PITCH June 13, 2025.pdf
Thane Heins NOBEL PRIZE WINNING ENERGY RESEARCHER
 
Sujay Rao Mandavilli public profile June 2025.pdf
Sujay Rao Mandavilli public profile June 2025.pdf
Sujay Rao Mandavilli
 
GBSN_Unit 3 - Medical and surgical Asepsis
GBSN_Unit 3 - Medical and surgical Asepsis
Areesha Ahmad
 
Paired Sketching of Distributed User Interfaces:Workflow, Protocol, Software ...
Paired Sketching of Distributed User Interfaces:Workflow, Protocol, Software ...
Jean Vanderdonckt
 
Investigatory_project Topic:-effect of electrolysis in solar desalination .pdf
Investigatory_project Topic:-effect of electrolysis in solar desalination .pdf
shubham997ku
 
Solution Chemistry Basics, molarity Molality
Solution Chemistry Basics, molarity Molality
nuralam819365
 
MEDICINAL CHEMISTRY PROSPECTIVES IN DESIGN OF EGFR INHIBITORS.pptx
MEDICINAL CHEMISTRY PROSPECTIVES IN DESIGN OF EGFR INHIBITORS.pptx
40RevathiP
 
Chromosomal Aberration (Mutation) and Classification.
Chromosomal Aberration (Mutation) and Classification.
Dr-Haseeb Zubair Tagar
 
The scientific heritage No 162 (162) (2025)
The scientific heritage No 162 (162) (2025)
The scientific heritage
 
Flexible Denture -Removable partial denture.pptx
Flexible Denture -Removable partial denture.pptx
Nekemiya
 
Science 8 Quarter 4 first quiz digestive system.docx
Science 8 Quarter 4 first quiz digestive system.docx
junefermunez
 
THE CIRCULATORY SYSTEM GRADE 9 SCIENCE.pptx
THE CIRCULATORY SYSTEM GRADE 9 SCIENCE.pptx
roselyncatacutan
 
plant and animal nutrition..........pptx
plant and animal nutrition..........pptx
mayflorgalleno
 
MOLD -GENERAL CHARACTERISTICS AND CLASSIFICATION
MOLD -GENERAL CHARACTERISTICS AND CLASSIFICATION
aparnamp966
 
Gas Exchange in Insects and structures 01
Gas Exchange in Insects and structures 01
PhoebeAkinyi1
 
Properties of Gases siwhdhadpaldndn.pptx
Properties of Gases siwhdhadpaldndn.pptx
CatherineJadeBurce
 
History of Nursing and Nursing As A Profession UNIT-3.pptx
History of Nursing and Nursing As A Profession UNIT-3.pptx
madhusrinivas68
 
lysosomes "suicide bags of cell" and hydrolytic enzymes
lysosomes "suicide bags of cell" and hydrolytic enzymes
kchaturvedi070
 
The Gender Binary & LGBTI People: Religious Myth and Medical Malpractice
The Gender Binary & LGBTI People: Religious Myth and Medical Malpractice
Veronica Drantz, PhD
 
What is Skeleton system.pptx by aahil sir
What is Skeleton system.pptx by aahil sir
bhatbashir421
 
Sujay Rao Mandavilli public profile June 2025.pdf
Sujay Rao Mandavilli public profile June 2025.pdf
Sujay Rao Mandavilli
 
GBSN_Unit 3 - Medical and surgical Asepsis
GBSN_Unit 3 - Medical and surgical Asepsis
Areesha Ahmad
 
Paired Sketching of Distributed User Interfaces:Workflow, Protocol, Software ...
Paired Sketching of Distributed User Interfaces:Workflow, Protocol, Software ...
Jean Vanderdonckt
 
Investigatory_project Topic:-effect of electrolysis in solar desalination .pdf
Investigatory_project Topic:-effect of electrolysis in solar desalination .pdf
shubham997ku
 
Solution Chemistry Basics, molarity Molality
Solution Chemistry Basics, molarity Molality
nuralam819365
 
MEDICINAL CHEMISTRY PROSPECTIVES IN DESIGN OF EGFR INHIBITORS.pptx
MEDICINAL CHEMISTRY PROSPECTIVES IN DESIGN OF EGFR INHIBITORS.pptx
40RevathiP
 
Chromosomal Aberration (Mutation) and Classification.
Chromosomal Aberration (Mutation) and Classification.
Dr-Haseeb Zubair Tagar
 
The scientific heritage No 162 (162) (2025)
The scientific heritage No 162 (162) (2025)
The scientific heritage
 
Flexible Denture -Removable partial denture.pptx
Flexible Denture -Removable partial denture.pptx
Nekemiya
 
Science 8 Quarter 4 first quiz digestive system.docx
Science 8 Quarter 4 first quiz digestive system.docx
junefermunez
 
THE CIRCULATORY SYSTEM GRADE 9 SCIENCE.pptx
THE CIRCULATORY SYSTEM GRADE 9 SCIENCE.pptx
roselyncatacutan
 
plant and animal nutrition..........pptx
plant and animal nutrition..........pptx
mayflorgalleno
 
Ad

in computer data structures and algorithms

  • 1. DMI-ST. JOHN THE BAPTIST UNIVERSITY LILONGWE, MALAWI Module Code: 351CS34 Subject Name: DATA STRUCTURE AND ALGORITHM Unit I Detail Notes School of Computer Science Module Teacher: Fanny Chatola
  • 2. Syllabus Introduction to Algorithm and Data Structures: Algorithms- Problem Solving, Introduction to Algorithms, Characteristics of algorithms, Algorithm design tools: Pseudo code and flowchart, Analysis of Algorithms, Complexity of algorithms - Space complexity, Time complexity, Asymptotic notation - Big-O, Theta and Omega, standard measures of efficiency. Data Structures- Data structure, Abstract Data Types (ADT), Concept of linear and Non-linear, static and dynamic, persistent and ephemeral data structures, and relationship among data, data structure, and algorithm, From Problem to Program. Algorithmic Strategies- Introduction to algorithm design strategies - Divide and Conquer, and Greedy strategy. Recurrence relation - Recurrence Relation, Linear Recurrence Relations, With constant Coefficients, Homogeneous Solutions. Solving recurrence relations.
  • 3. TABLE OF CONTENTS No table of contents entries found.
  • 4. Problem Solving:  For finding solution to problems  It is used in many disciplines Ex: Problems 1. Sorting 2. Searching 3. String problem 4. Graph problems 5. Combinational problems 6. Geometric problems 7. Numerical problems Introduction to algorithms: An algorithm is a step by step instruction for solving problems. Ex: Euclid’s algorithm for calculate gcd(m,n)  Gcd means greatest common divisor of two non negative integers Instructions: Step 1: if n=0, return the value of m as the answer and stop; otherwise proceed to step2. Step 2: Divide m by n and assign the value of the remainder to r. Step 3: Assign the value of n to m and the value of r to n go to step 1. Algorithm: While n≠0 do
  • 5. r ← m mod n m ← n n ← r return m Characteristic of Algorithm: 1. Time efficiency – how fast the algorithm runs. 2. Space efficiency – how much extra memory used 3. Simplicity – simpler than the other algorithms 4. Generality –the algorithm solves and the range of inputs it accepts and used more general terms. Algorithm design tools: 1. Pseudo code 2. Flow chart Pseudo Code: • It is a mixture of a natural language and programming language Flow chart: • Pictorial representation of an algorithm Analysis of an Algorithm: • To analysis quality and efficiency of algorithm complexity 1.Time Complexity 2.Space Complexity Time Complexity: • It indicates how fast the algorithm runs. Space Complexity: • It indicates how much extra memory that algorithm needs. Asymptotic Notation: • To compare and rank such orders of growth of an algorithm is called Asymptotic notation • It is classified into three types 1. Big oh notation – O 2. Big omega notation – Ω 3. Big theta notation – Ɵ Big oh notation: • It is used to define the worst case running time of an algorithm.
  • 6. Def: T(n) = Of(n), if there are positive constants T(n) ≤ Cf(n) Big omega notation: • It is used to define the best case running time of an algorithm Def: T(n) = Ωf(n), if there are positive constants T(n) ≥ Cf(n) Big Theta notation: • It is used to define the average case running time of algorithms. C1f(n) C2f(n) N No Cf(n) T(n) N No T(n) C(f(n) No N T(n)
  • 7. Def: T(n) =Ɵf(n), if there are positive constants T(n)=Of(n) and T(n)=Ωf(n) Data Structures: • Data structures are a particular way of organizing data in a computer. • It is used to storing and retrieving data from a computer. Abstract Data Type: • Abstract Data Type is an extension of modular design. • It is a set of operation such as union, intersection, complement, find and etc. • It use to written once in program and can be called by any part of the program. Example: Store (V, X) X- is the value of unspecified V- is the fields value Application of Data Structures: • Operating Systems • Compiler design • Statistical and numerical analysis • Database management systems • Expert systems • Network analysis Classification of Data Structures: • It is classified into two types 1. Primitive Data Structure 2. Non Primitive Data Structure Primitive Data Structures: • It can be directly operated by the machine instruction Ex: Integer, float, char, pointer and etc. Non Primitive Data Structures: • It structuring of a group of homogeneous and heterogeneous data items. o Homogeneous – uniform character o Heterogeneous – un uniform character • It is classified into two types 1. Linear Data Structure 2. Non Linear Data Structure Linear Data Structure:
  • 8. • It contains a linear arrangement of elements in the memory. Ex: stack, array, linked list and queue Non Linear Data Structure: • It contains a hierarchical arrangement of elements Ex: trees, graph Static: • Static means prefixed while declaring a value. Ex: static int x=10; Dyanamic: • Dynamic means change the variable size or value. • Ex: int a; Persistent and ephemeral data structures: Persistent Data Structure:(Functional) • It is a data structure that always preserves the previous version of itself when it is modified • The data structure is fully persistent if every version can be both accessed and modified. Ephemeral Data Structures: (Non Functional) • Structures that are not persistent are called Ephemeral Data Structure. Ex: Persistent queue, merge operation Algorithmic Strategies: • There are a number of general and powerful computational strategies that are repeatedly used. 1. Divide and Conquer 2. Dynamic programming 3. Greedy strategy 4. Back tracking 5. Branch and Bound Technique Divide and Conquer: • This technique is used to dividing a problem into two smaller sub problems. • The sub problems are solved separately. • The solutions obtained for the sub problems are combined to get a solution to the original problem. a b c d e f
  • 9. Greedy Strategy: • The greedy approach suggests constructing solution through a sequence of steps, each expanding a partially constructed solution obtained. So far, until a complete solution to the problem is reached. o Feasible – satisfy the problem’s conditions o Locally optimal – to be the best local choice among all feasible choice o Irrevocable – once made it cannot be changed. Ex: Change – Making Problem. Recurrence Relation: • It defines a sequence or multidimensional array of value once one or more initial terms are given. Ex: Fibonacci numbers Fn=F𝑛−1+𝐹n-2 0,1,1,2,3,5,8,………. Linear Recurrence Relation: • A Linear recurrence relation is an equation that relates a term in sequence or multidimensional array. • The word linear refers to the fact that previous terms are arranged. Ex: Xn=C1Xn-1+C2xn- 2+……..+CkXn-k Homogeneous Linear Recurrence Relation: • All the terms have the same exponent. ak=Aak-1 + Bak-2 Linear ak=1 Homogeneous = same exponent Solving Recurrence Relation: • There are few techniques for converting recursive definition to closed formulas is called solving a recurrence relation. Ex: 𝑎𝑛= 𝑎𝑛−1+n with initial terms 𝑎0=4 Problems Sub Problem 1 Sub Problem 2 Solution to Sub Problems 1 Solution to the Original Problem Solution to Sub Problems 2
  • 10. Sequence of 4, 5, 7, 10, 14, 19……..  𝑎1-𝑎0=1 and 𝑎2 -𝑎1=2 so on.  𝑎𝑛−𝑎𝑛−1 = n  Changing n each time  𝑎1-𝑎0 = 1  𝑎2 -𝑎1 = 2  𝑎3 -𝑎2 = 3  : :  𝑎𝑛-𝑎𝑛−1 = n  Sum = 1+2+3+……..+n.  Simplified = n(n+1)/2  (𝑎1-𝑎0 ) + (𝑎2-𝑎1 ) + (𝑎3-𝑎0 ) + ………+(𝑎𝑛−1-𝑎𝑛−2 ) + (𝑎𝑛-𝑎𝑛−1 ).  𝑎𝑛 = n(n+1)/2+4