SlideShare une entreprise Scribd logo
1  sur  39
DATA STRUCTURES AND
ALGORITHM ANALYSIS
BY ENGR. SAHEED STA BIZ
saheedtzubair@gmail.com 08032147147
COURSE PLANNING
COURSE CONTENTS ASSESSMENTS BOOKS & MATERIALS
COURSE INTRODUCTION
 This course introduces students to learn about data elements which
provides an efficient way of storing and organizing data in the computer
so that it can be used efficiently.
 Also about some of Data Structures such as arrays, Linked List, Stack,
Queue, etc.
 Data Structures are widely used in almost every aspect of Computer
Science i.e. Operating System, Compiler Design, Artificial intelligence,
Graphics and many more.
Course Contents
 Review of elementary programming concepts: Variables and Data
types, Conditional Statements, Looping Statements,Arrays.
 Fundamental data structures: Stacks,Queues,Linked lists,Hash
tables,Trees,Graphs.
 Fundamental computing algorithms :O(N log N) sorting algorithms
Binary search trees,Representations of graphs,Depth- and Breadth-first traversals.
 Recursion :The concept of recursion,Recursive mathematical functions,Simple
recursive procedures,Divide-and-conquer strategies.
 Algorithmic strategies,Brute-force algorithms,Greedy algorithms,Branch-and-
bound; Pattern matching and string/text algorithms; Numerical approximation algorithms
MODE OF ASSESSMENTS
CONTINUOUS ASSESSMENT Week Weight Remarks
ASSIGNMENTS
1-4 10% Subjective
CLASS TEST 6
10%
Subjective
QUIZ 3-8 10%
Subjective
FINAL EXAM 12 60%
Subjective
 Data: Collection of raw facts.
 Data structure is a specialized format for organizing and storing data in
memory that considers not only the elements stored but also their
to each other.
 • Data structure Is an arrangement of data In computer's memory. It makes
data to be quickly available to the processor for required operations.
 • It is a structure program used to store ordered data, so that various
operations can be performed on it easily.
 It should be designed and implemented in such a way that it reduces the
complexity and increases the efficiency.
INTRODUCTION
INTRODUCTION
 Data structure affects the design of both structural & functional aspects of
a program.
Program=algorithm + Data Structure
 You know that a algorithm is a step by step procedure to solve a
particular function.
Classification of data structure
 Data structure are normally divided into two broad categories:
Primitive Data Structure & NON-PRIMITIVE DATA
STRUCTURE
.
Primitive Data Structure
 Data structures that are directly operated upon the machine-level
instructions are known as primitive or primary data structures.
Integer, Floating-point number, Character constants, string constants,
pointers etc, fall in this category as example of Simple data structure.
 The most commonly used operation
on data structure are broadly
categorized into following types:
 ◦ Create
 ◦ Selection ◦ Updating
 ◦ Destroy or Delete
NON-PRIMITIVE DATA STRUCTURE
 The Data structures that are derived from the primitive data structures are
called Non-primitive or secondary data structure.
 The non-primitive data structures emphasize on structuring of a group of
homogeneous (same type) or heterogeneous ( different type) data items.
 NON-PRIMITIVE DATA STRUCTURE IS DIVIDED INTO:
1. linear data structure
2. Non-linear data structure
NOTE There are more sophisticated data structures.
NON-PRIMITIVE DATA STRUCTURE
 Linear Data structures:
 ◦ Linear Data structures are kind of data structure that has homogeneous elements.
 ◦ The data structure in which elements are in a sequence and form a liner series.
 ◦ Linear data structures are very easy to implement, since the memory of the computer is
also organized in a linear fashion.
 ◦ Some commonly used linear data structures are Stack, Queue and Linked Lists.
 Non-Linear Data structures:
 ◦ A Non-Linear Data structures is a data structure in which data item is connected to
several other data items.
 ◦ Non-Linear data structure may exhibit either a hierarchical relationship or parent child
relationship.
 ◦ The data elements are not arranged in a sequential structure.
 ◦ some commonly non-linear data structures are trees and graphs.
OPERATIONS APPLIED ON DATA STRUCTURES
 The most commonly used operation on data structure are broadly categorized
into following types:
 ◦ Traversal
 ◦ Insertion
 ◦ Selection
 ◦ Searching
 ◦ Sorting
 ◦ Merging
 ◦ Destroy or Delete
Different between A primitive data structure
and non primitive data structure
 A primitive data structure is generally a basic structure that is usually built
into the language, such as an integer, a float.
 A non-primitive data structure is built out of primitive data structures
linked together in meaningful ways, such as a or a linked-list, binary
search tree, AVL Tree, graph etc.
INTRODUCTION TO ALGORITHM
Algorithm is a step-by-step procedure, which defines a set of instructions to be
executed in a certain order to get the desired output.
Algorithms are generally created independent of underlying languages, i.e. an
algorithm can be implemented in more than one programming language
SOME IMPORTANT CATEGORIES OF ALGORITHMS
 From the data structure point of view, following are some important
categories of algorithms −
 Search − Algorithm to search an item in a data structure.
 Sort − Algorithm to sort items in a certain order.
 Insert − Algorithm to insert item in a data structure.
 Update − Algorithm to update an existing item in a data structure.
 Delete − Algorithm to delete an existing item from a data structure.
CHARACTERISTICS OF AN ALGORITHM
 Not all procedures can be called an algorithm. An algorithm should have the following
characteristics −
 Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and
their inputs/outputs should be clear and must lead to only one meaning.
 Input − An algorithm should have 0 or more well-defined inputs.
 Output − An algorithm should have 1 or more well-defined outputs, and should match the
desired output.
 Finiteness − Algorithms must terminate after a finite number of steps.
 Feasibility − Should be feasible with the available resources.
 Independent − An algorithm should have step-by-step directions, which should be independent
of any programming code.
HOW TO WRITE AN ALGORITHM
 There are no well-defined standards for writing algorithms. Rather, it is problem and
resource dependent. Algorithms are never written to support a particular programming
code.
 As we know that all programming languages share basic code constructs like loops (do,
for, while), flow-control (if-else), etc. These common constructs can be used to write an
algorithm.
 We write algorithms in a step-by-step manner, but it is not always the case. Algorithm
writing is a process and is executed after the problem domain is well-defined. That is,
we should know the problem domain, for which we are designing a solution.
HOW TO WRITE AN ALGORITHM
 Example
 Let's try to learn algorithm-writing by using an example.
 Problem − Design an algorithm to add two numbers and display the result.
 Step 1 − START
 Step 2 − declare three integers a, b & c
 Step 3 − define values of a & b
 Step 4 − add values of a & b
 Step 5 − store output of step 4 to c
 Step 6 − print c
 In design and analysis of algorithms, usually the second method is used to describe an algorithm. It
makes it easy for the analyst to analyze the algorithm ignoring all unwanted definitions. He can
observe what operations are being used and how the process is flowing.
 Writing step numbers, is optional.
 We design an algorithm to get a solution of a given problem. A problem can be solved in more
than one ways.
ALGORITHM ANALYSIS
 Efficiency of an algorithm can be analyzed at two different stages, before implementation and after
implementation. They are the following −
 A Priori Analysis − This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured
by assuming that all other factors, for example, processor speed, are constant and have no effect on
the implementation.
 A Posterior Analysis − This is an empirical analysis of an algorithm. The selected algorithm is
implemented using programming language. This is then executed on target computer machine. In
this analysis, actual statistics like running time and space required, are collected.
 We shall learn about a priori algorithm analysis. Algorithm analysis deals with the execution or running
time of various operations involved. The running time of an operation can be defined as the number
of computer instructions executed per operation.
Algorithm Complexity
 Suppose X is an algorithm and n is the size of input data, the time and space used
by the algorithm X are the two main factors, which decide the efficiency of X.
 Time Factor − Time is measured by counting the number of key operations such as
comparisons in the sorting algorithm.
 Space Factor − Space is measured by counting the maximum memory space
required by the algorithm.
 The complexity of an algorithm f(n) gives the running time and/or the storage space
required by the algorithm in terms of n as the size of input data.
SPACE COMPLEXITY
 Space complexity of an algorithm represents the amount of memory space
required by the algorithm in its life cycle. The space required by an algorithm is
equal to the sum of the following two components
 A fixed part that is a space required to store certain data and variables, that are
independent of the size of the problem. For example, simple variables and
constants used, program size, etc.
 A variable part is a space required by variables, whose size depends on the size of
the problem. For example, dynamic memory allocation, recursion stack space, etc.
 Space complexity S(P) of any algorithm P is S(P) = C + SP(I), where C is the fixed
part and S(I) is the variable part of the algorithm, which depends on instance
characteristic I. Following is a simple example that tries to explain the concept
TIME COMPLEXITY
 Algorithm: SUM(A, B)
 Step 1 - START
 Step 2 - C ← A + B + 10
 Step 3 - Stop
 Here we have three variables A, B, and C and one constant. Hence S(P) = 1 + 3.
Now, space depends on data types of given variables and constant types and it
will be multiplied accordingly.
TIME Complexity
 Time complexity of an algorithm represents the amount of time required
by the algorithm to run to completion. Time requirements can be defined
as a numerical function T(n), where T(n) can be measured as the number
of steps, provided each step consumes constant time.
 For example, addition of two n-bit integers takes n steps. Consequently,
the total computational time is T(n) = c ∗ n, where c is the time taken for
the addition of two bits. Here, we observe that T(n) grows linearly as the
input size increases.
Description of various data structure
ARRAY
 An array is defined as a set of finite number of homogeneous elements or same data items.
 It means an array can contain one type of data only, either all integer, all float-point number or all
character.
One dimensional array
 An array with only one row or column is called one-dimensional array.
 It is finite collection of n number of elements of same type such that:
 ◦ can be referred by indexing.
 ◦ The syntax Elements are stored in continuous locations.
 ◦ Elements x to define one-dimensional array is:
 Syntax: Datatype Array_Name [Size];
 Where,
 Datatype : Type of value it can store (Example: int, char, float) Array_Name: To identify the array.
 Size : The maximum number of elements that the array can hold
ARRAY
 Simply, declaration of array is as follows: int arr[10]
 Where int specifies the data type or type of elements arrays
stores.
 “arr” is the name of array & the number specified inside
the square brackets is the number of elements an array can
store, this is also called sized or length of array.
 The elements of linear array are stored in consecutive
memory locations. It is shown below
ARRAY
 ◦ The elements of array will always be stored in the consecutive
(continues) memory location.
 ◦ The number of elements that can be stored in an array, that is the size
of array or its length is given by the following equation:
 (Upperbound-lowerbound)+1
 ◦ For the above array it would be (9-0)+1=10,where 0 is the lower bound
of array and 9 is the upper bound of array.
 ◦ Array can always be read or written through loop.
 For(i=0;i<=9;i++)
 {scanf(“%d”,&arr[i]); printf(“%d”,arr[i]);
TYPES OF ARRAY
 Single Dimension Array: Array with one subscript
 Two Dimension Array: Array with two subscripts (Rows and Column)
 Multi Dimension Array: Array with Multiple subscripts
Basic operations of Arrays
 Some common operation performed on array are:
 ◦ Traversing
 ◦ Searching
 ◦ Insertion
 ◦ Deletion
 ◦ Sorting
 ◦ Merging
TRAVERSING
Traversing:It is used to access each data item
exactly once so that it can be processed. E.g.
We have linear array A as below:
0 1 2 3 4
10 20 30 40 50
Here we will start from beginning and will go till
last element and during this process we will
access value of each element exactly once as
below:
A [1] = 10 A [2] = 20
A [3] = 30
A [4] = 40
A [5] = 50
INSERTION
 Insertion: It is used to add a new data item in the given collection of data
items.
 E.g. We have linear array A as below:
 12 3 4 5
 10 20 50 30 15
 New element to be inserted is 100 and location for insertion is 3. So shift
the elements from 5th location to 3rd location downwards by 1 place.
And then insert 100 at 3rd location. It is shown below:
INSERTION
DELETION OF ARRAYS
 Deletion of arrays: It is used to delete an existing data item from the
given collection of data items
SEARCHING ARRAY
 Searching: It is used to find out the location of the data item if it exists in the
given collection of data items.
 E.g. We have linear array A as below:
 12 3 4 5
 15 50 35 20 25
 Suppose item to be searched is 20. We will start from beginning and will compare
20 with each element. This process will continue until element is found or array is
finished. Here:
 1) Compare 20 with 15 20 # 15, go to next element. 2) Compare 20 with 50 20
# 50, go to next element.
 Compare 20 with 35 20 #35, go to next element.
 Compare 20 with 20
 20 = 20, so 20 is found and its location is 4.
Linear Search
BINARY SEARCH

algorithm can be used with
only sorted list of
elements.
 Binary Search first divides
a large array into two
smaller sub -arrays and
then recursively operate
the sub -arrays.
 Binary Search basically
reduces the search space to
half at each step
. BINARY SEARCH
.
Binary Search
SEARCHING
THANK YOU

Contenu connexe

Tendances

Elementary data structure
Elementary data structureElementary data structure
Elementary data structureBiswajit Mandal
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
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
 
Applications of data structures
Applications of data structuresApplications of data structures
Applications of data structuresWipro
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2Kumar
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESAniruddha Paul
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureVrushali Dhanokar
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure Prof Ansari
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#Shahzad
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using javaNarayan Sau
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueGhaffar Khan
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introductionSugandh Wafai
 
Chapter 2.2 data structures
Chapter 2.2 data structuresChapter 2.2 data structures
Chapter 2.2 data structuressshhzap
 

Tendances (20)

Elementary data structure
Elementary data structureElementary data structure
Elementary data structure
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
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
 
Applications of data structures
Applications of data structuresApplications of data structures
Applications of data structures
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Introduction to data structure and algorithms
Introduction to data structure and algorithmsIntroduction to data structure and algorithms
Introduction to data structure and algorithms
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
DATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTESDATA STRUCTURE AND ALGORITHM FULL NOTES
DATA STRUCTURE AND ALGORITHM FULL NOTES
 
Big o notation
Big o notationBig o notation
Big o notation
 
Algorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structureAlgorithm analysis in fundamentals of data structure
Algorithm analysis in fundamentals of data structure
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
Data structures
Data structuresData structures
Data structures
 
Chapter 2.2 data structures
Chapter 2.2 data structuresChapter 2.2 data structures
Chapter 2.2 data structures
 
Algorithms.
Algorithms. Algorithms.
Algorithms.
 

Similaire à Lecture 1 and 2

Similaire à Lecture 1 and 2 (20)

8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Data Structure Notes unit 1.docx
Data Structure Notes unit 1.docxData Structure Notes unit 1.docx
Data Structure Notes unit 1.docx
 
part 1 - intorduction data structure 2021 mte.ppt
part 1 -  intorduction data structure  2021 mte.pptpart 1 -  intorduction data structure  2021 mte.ppt
part 1 - intorduction data structure 2021 mte.ppt
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - Introduction
 

Dernier

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 

Dernier (20)

Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 

Lecture 1 and 2

  • 1. DATA STRUCTURES AND ALGORITHM ANALYSIS BY ENGR. SAHEED STA BIZ saheedtzubair@gmail.com 08032147147
  • 2. COURSE PLANNING COURSE CONTENTS ASSESSMENTS BOOKS & MATERIALS
  • 3. COURSE INTRODUCTION  This course introduces students to learn about data elements which provides an efficient way of storing and organizing data in the computer so that it can be used efficiently.  Also about some of Data Structures such as arrays, Linked List, Stack, Queue, etc.  Data Structures are widely used in almost every aspect of Computer Science i.e. Operating System, Compiler Design, Artificial intelligence, Graphics and many more.
  • 4. Course Contents  Review of elementary programming concepts: Variables and Data types, Conditional Statements, Looping Statements,Arrays.  Fundamental data structures: Stacks,Queues,Linked lists,Hash tables,Trees,Graphs.  Fundamental computing algorithms :O(N log N) sorting algorithms Binary search trees,Representations of graphs,Depth- and Breadth-first traversals.  Recursion :The concept of recursion,Recursive mathematical functions,Simple recursive procedures,Divide-and-conquer strategies.  Algorithmic strategies,Brute-force algorithms,Greedy algorithms,Branch-and- bound; Pattern matching and string/text algorithms; Numerical approximation algorithms
  • 5. MODE OF ASSESSMENTS CONTINUOUS ASSESSMENT Week Weight Remarks ASSIGNMENTS 1-4 10% Subjective CLASS TEST 6 10% Subjective QUIZ 3-8 10% Subjective FINAL EXAM 12 60% Subjective
  • 6.  Data: Collection of raw facts.  Data structure is a specialized format for organizing and storing data in memory that considers not only the elements stored but also their to each other.  • Data structure Is an arrangement of data In computer's memory. It makes data to be quickly available to the processor for required operations.  • It is a structure program used to store ordered data, so that various operations can be performed on it easily.  It should be designed and implemented in such a way that it reduces the complexity and increases the efficiency. INTRODUCTION
  • 7. INTRODUCTION  Data structure affects the design of both structural & functional aspects of a program. Program=algorithm + Data Structure  You know that a algorithm is a step by step procedure to solve a particular function.
  • 8. Classification of data structure  Data structure are normally divided into two broad categories: Primitive Data Structure & NON-PRIMITIVE DATA STRUCTURE .
  • 9. Primitive Data Structure  Data structures that are directly operated upon the machine-level instructions are known as primitive or primary data structures. Integer, Floating-point number, Character constants, string constants, pointers etc, fall in this category as example of Simple data structure.  The most commonly used operation on data structure are broadly categorized into following types:  ◦ Create  ◦ Selection ◦ Updating  ◦ Destroy or Delete
  • 10. NON-PRIMITIVE DATA STRUCTURE  The Data structures that are derived from the primitive data structures are called Non-primitive or secondary data structure.  The non-primitive data structures emphasize on structuring of a group of homogeneous (same type) or heterogeneous ( different type) data items.  NON-PRIMITIVE DATA STRUCTURE IS DIVIDED INTO: 1. linear data structure 2. Non-linear data structure NOTE There are more sophisticated data structures.
  • 11. NON-PRIMITIVE DATA STRUCTURE  Linear Data structures:  ◦ Linear Data structures are kind of data structure that has homogeneous elements.  ◦ The data structure in which elements are in a sequence and form a liner series.  ◦ Linear data structures are very easy to implement, since the memory of the computer is also organized in a linear fashion.  ◦ Some commonly used linear data structures are Stack, Queue and Linked Lists.  Non-Linear Data structures:  ◦ A Non-Linear Data structures is a data structure in which data item is connected to several other data items.  ◦ Non-Linear data structure may exhibit either a hierarchical relationship or parent child relationship.  ◦ The data elements are not arranged in a sequential structure.  ◦ some commonly non-linear data structures are trees and graphs.
  • 12. OPERATIONS APPLIED ON DATA STRUCTURES  The most commonly used operation on data structure are broadly categorized into following types:  ◦ Traversal  ◦ Insertion  ◦ Selection  ◦ Searching  ◦ Sorting  ◦ Merging  ◦ Destroy or Delete
  • 13. Different between A primitive data structure and non primitive data structure  A primitive data structure is generally a basic structure that is usually built into the language, such as an integer, a float.  A non-primitive data structure is built out of primitive data structures linked together in meaningful ways, such as a or a linked-list, binary search tree, AVL Tree, graph etc.
  • 14. INTRODUCTION TO ALGORITHM Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language
  • 15. SOME IMPORTANT CATEGORIES OF ALGORITHMS  From the data structure point of view, following are some important categories of algorithms −  Search − Algorithm to search an item in a data structure.  Sort − Algorithm to sort items in a certain order.  Insert − Algorithm to insert item in a data structure.  Update − Algorithm to update an existing item in a data structure.  Delete − Algorithm to delete an existing item from a data structure.
  • 16. CHARACTERISTICS OF AN ALGORITHM  Not all procedures can be called an algorithm. An algorithm should have the following characteristics −  Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and their inputs/outputs should be clear and must lead to only one meaning.  Input − An algorithm should have 0 or more well-defined inputs.  Output − An algorithm should have 1 or more well-defined outputs, and should match the desired output.  Finiteness − Algorithms must terminate after a finite number of steps.  Feasibility − Should be feasible with the available resources.  Independent − An algorithm should have step-by-step directions, which should be independent of any programming code.
  • 17. HOW TO WRITE AN ALGORITHM  There are no well-defined standards for writing algorithms. Rather, it is problem and resource dependent. Algorithms are never written to support a particular programming code.  As we know that all programming languages share basic code constructs like loops (do, for, while), flow-control (if-else), etc. These common constructs can be used to write an algorithm.  We write algorithms in a step-by-step manner, but it is not always the case. Algorithm writing is a process and is executed after the problem domain is well-defined. That is, we should know the problem domain, for which we are designing a solution.
  • 18. HOW TO WRITE AN ALGORITHM  Example  Let's try to learn algorithm-writing by using an example.  Problem − Design an algorithm to add two numbers and display the result.  Step 1 − START  Step 2 − declare three integers a, b & c  Step 3 − define values of a & b  Step 4 − add values of a & b  Step 5 − store output of step 4 to c  Step 6 − print c  In design and analysis of algorithms, usually the second method is used to describe an algorithm. It makes it easy for the analyst to analyze the algorithm ignoring all unwanted definitions. He can observe what operations are being used and how the process is flowing.  Writing step numbers, is optional.  We design an algorithm to get a solution of a given problem. A problem can be solved in more than one ways.
  • 19. ALGORITHM ANALYSIS  Efficiency of an algorithm can be analyzed at two different stages, before implementation and after implementation. They are the following −  A Priori Analysis − This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured by assuming that all other factors, for example, processor speed, are constant and have no effect on the implementation.  A Posterior Analysis − This is an empirical analysis of an algorithm. The selected algorithm is implemented using programming language. This is then executed on target computer machine. In this analysis, actual statistics like running time and space required, are collected.  We shall learn about a priori algorithm analysis. Algorithm analysis deals with the execution or running time of various operations involved. The running time of an operation can be defined as the number of computer instructions executed per operation.
  • 20. Algorithm Complexity  Suppose X is an algorithm and n is the size of input data, the time and space used by the algorithm X are the two main factors, which decide the efficiency of X.  Time Factor − Time is measured by counting the number of key operations such as comparisons in the sorting algorithm.  Space Factor − Space is measured by counting the maximum memory space required by the algorithm.  The complexity of an algorithm f(n) gives the running time and/or the storage space required by the algorithm in terms of n as the size of input data.
  • 21. SPACE COMPLEXITY  Space complexity of an algorithm represents the amount of memory space required by the algorithm in its life cycle. The space required by an algorithm is equal to the sum of the following two components  A fixed part that is a space required to store certain data and variables, that are independent of the size of the problem. For example, simple variables and constants used, program size, etc.  A variable part is a space required by variables, whose size depends on the size of the problem. For example, dynamic memory allocation, recursion stack space, etc.  Space complexity S(P) of any algorithm P is S(P) = C + SP(I), where C is the fixed part and S(I) is the variable part of the algorithm, which depends on instance characteristic I. Following is a simple example that tries to explain the concept
  • 22. TIME COMPLEXITY  Algorithm: SUM(A, B)  Step 1 - START  Step 2 - C ← A + B + 10  Step 3 - Stop  Here we have three variables A, B, and C and one constant. Hence S(P) = 1 + 3. Now, space depends on data types of given variables and constant types and it will be multiplied accordingly.
  • 23. TIME Complexity  Time complexity of an algorithm represents the amount of time required by the algorithm to run to completion. Time requirements can be defined as a numerical function T(n), where T(n) can be measured as the number of steps, provided each step consumes constant time.  For example, addition of two n-bit integers takes n steps. Consequently, the total computational time is T(n) = c ∗ n, where c is the time taken for the addition of two bits. Here, we observe that T(n) grows linearly as the input size increases.
  • 24. Description of various data structure ARRAY  An array is defined as a set of finite number of homogeneous elements or same data items.  It means an array can contain one type of data only, either all integer, all float-point number or all character. One dimensional array  An array with only one row or column is called one-dimensional array.  It is finite collection of n number of elements of same type such that:  ◦ can be referred by indexing.  ◦ The syntax Elements are stored in continuous locations.  ◦ Elements x to define one-dimensional array is:  Syntax: Datatype Array_Name [Size];  Where,  Datatype : Type of value it can store (Example: int, char, float) Array_Name: To identify the array.  Size : The maximum number of elements that the array can hold
  • 25. ARRAY  Simply, declaration of array is as follows: int arr[10]  Where int specifies the data type or type of elements arrays stores.  “arr” is the name of array & the number specified inside the square brackets is the number of elements an array can store, this is also called sized or length of array.  The elements of linear array are stored in consecutive memory locations. It is shown below
  • 26. ARRAY  ◦ The elements of array will always be stored in the consecutive (continues) memory location.  ◦ The number of elements that can be stored in an array, that is the size of array or its length is given by the following equation:  (Upperbound-lowerbound)+1  ◦ For the above array it would be (9-0)+1=10,where 0 is the lower bound of array and 9 is the upper bound of array.  ◦ Array can always be read or written through loop.  For(i=0;i<=9;i++)  {scanf(“%d”,&arr[i]); printf(“%d”,arr[i]);
  • 27. TYPES OF ARRAY  Single Dimension Array: Array with one subscript  Two Dimension Array: Array with two subscripts (Rows and Column)  Multi Dimension Array: Array with Multiple subscripts
  • 28. Basic operations of Arrays  Some common operation performed on array are:  ◦ Traversing  ◦ Searching  ◦ Insertion  ◦ Deletion  ◦ Sorting  ◦ Merging
  • 29. TRAVERSING Traversing:It is used to access each data item exactly once so that it can be processed. E.g. We have linear array A as below: 0 1 2 3 4 10 20 30 40 50 Here we will start from beginning and will go till last element and during this process we will access value of each element exactly once as below: A [1] = 10 A [2] = 20 A [3] = 30 A [4] = 40 A [5] = 50
  • 30. INSERTION  Insertion: It is used to add a new data item in the given collection of data items.  E.g. We have linear array A as below:  12 3 4 5  10 20 50 30 15  New element to be inserted is 100 and location for insertion is 3. So shift the elements from 5th location to 3rd location downwards by 1 place. And then insert 100 at 3rd location. It is shown below:
  • 32. DELETION OF ARRAYS  Deletion of arrays: It is used to delete an existing data item from the given collection of data items
  • 33. SEARCHING ARRAY  Searching: It is used to find out the location of the data item if it exists in the given collection of data items.  E.g. We have linear array A as below:  12 3 4 5  15 50 35 20 25  Suppose item to be searched is 20. We will start from beginning and will compare 20 with each element. This process will continue until element is found or array is finished. Here:  1) Compare 20 with 15 20 # 15, go to next element. 2) Compare 20 with 50 20 # 50, go to next element.  Compare 20 with 35 20 #35, go to next element.  Compare 20 with 20  20 = 20, so 20 is found and its location is 4.
  • 35. BINARY SEARCH  algorithm can be used with only sorted list of elements.  Binary Search first divides a large array into two smaller sub -arrays and then recursively operate the sub -arrays.  Binary Search basically reduces the search space to half at each step