SlideShare une entreprise Scribd logo
1  sur  25
Data Structures
and Algorithm
INSTRUCTOR:
ELLEN GRACE
PORRAS
FIRST SEMESTER 2022-2023
Introduction
Data Structure
• Data Structure is a way of collecting and organizing data in such a way that we can
perform operations on these data in an effective way. Data Structures is about rendering
data elements in terms of some relationship, for better organization and storage.
• Data Structures are structures programmed to store ordered data, so that various operations
can be performed on it easily. It represents the knowledge of data to be organized in
memory.
• It should be designed and implemented in such a way that it reduces the complexity and
increases the efficiency.
Characteristics of a Data Structure
3
• Correctness − Data structure implementation should implement its interface correctly.
• Time Complexity − Running time or the execution time of operations of data structure
must be as small as possible.
• Space Complexity − Memory usage of a data structure operation should be as little as
possible.
Need for Data Structure
4
As applications are getting complex and data rich, there are three common problems that applications face
now-a-days.
• Data Search − Consider an inventory of 1 million (106) items of a store. If the application is to
search an item, it has to search an item in 1 million (106) items every time slowing down the
search. As data grows, search will become slower.
• Processor Speed − Processor speed although being very high, falls limited if the data grows to
billion records.
• Multiple Requests − as thousands of users can search data simultaneously on a web server, even
the fast server fails while searching the data.
To solve the above-mentioned problems, data structures come to rescue. Data can be organized in a data
structure in such a way that all items may not be required to be searched, and the required data can be
searched almost instantly
What is an Algorithm?
5
• 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.
• In computer programming terms, an algorithm is a set of well-defined instructions to solve a
particular problem. It takes a set of input(s) and produces the desired output.
For example:
An algorithm to add two numbers:
• Take two number inputs
• Add numbers using the + operator
• Display the result
6
Let us consider the problem of preparing an omelette. To prepare an omelette, we follow the steps
given below:
1) Get the frying pan.
2) Get the oil.
a. Do we have oil?
• If yes, put it in the pan.
• If no, do we want to buy oil?
 If yes, then go out and buy.
 If no, we can terminate.
3)Turn on the stove, etc...
What we are doing is, for a given problem (preparing an omelette), we are providing a step-by step
procedure for solving it. The formal definition of an algorithm can be stated as: An algorithm is the
step-by-step unambiguous instructions to solve a given problem.
Qualities of a Good Algorithm
7
• Input and output should be defined precisely.
• Each step in the algorithm should be clear and unambiguous.
• Algorithms should be most effective among many ways to solve a problem.
• An algorithm shouldn't include computer code. Instead, the algorithm should be written in
such a way that it can be used in different programming languages.
8
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
9
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.
Algorithm 1: Add two numbers entered by the user
10
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop
Algorithm 2: Find the largest number among three numbers
11
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
A good algorithm maintains a level of correctness while being efficient.
Meaning, there is little error, and it doesn’t take much time to complete.
Another important component is comprehensibility. We wouldn’t be able
to use algorithms so frequently if they couldn’t be understood.
Algorithmic and computational thinking is so pervasive that it governs the
simplest things in our daily lives. Here are some examples of algorithms
you interact with everyday.
12
Recipes
Just like sorting papers and even tying your shoes, following a recipe is a type of
algorithm. The goal of course being to create a duplicated outcome. In order to
complete a recipe, you must follow a given set of steps. Say you are making bread.
You need flour, yeast and water. After you have your ingredients, you need to combine
them in a certain way that will create a predictable outcome, in this case a loaf of
bread.
13
A simple task and yet it uses algorithmic thinking. When you are sorting
office files or your personal documents you are implementing an
algorithm. In its most basic sense, you are following a set of tasks to
achieve an outcome. The reason why sorting papers is a great example, is
because it shows the variety of tasks and specifications algorithms can
use. For instance, you can sort your files alphabetically, by word count, by
date, and countless others. The goal is to simplify the organizational
process by using small tasks.
14
Sorting Papers
ACTIVITY TIME!
15
Write down at least 3 algorithms
you interact with everyday and
present it in front of the class.
16
Types of Data Structure
17
Basically, data structures are divided into two categories:
• Linear data structure
• Non-linear data structure
Linear data structures
• In linear data structures, the elements are arranged in sequence one after the other. Since
elements are arranged order, they are easy to implement.
• However, when the complexity of the program increases, the linear data structures might
not be the best choice because of operational complexities
18
Popular linear data structures are:
1. Array Data Structure
In an array, elements in memory are arranged in continuous memory. All the elements of an array
are of the same type. And the type of elements that can be stored in the form of arrays is determined
by the programming language.
An array with each element represented by an index
19
2. Stack Data Structure
In stack data structure, elements are stored in the LIFO principle. That is, the last element stored in
a stack will be removed first.
It works just like a pile of plates where the last plate kept on the pile will be removed first.
In a stack, operations can be performed only from one end (top here).
20
3. Queue Data Structure
Unlike stack, the queue data structure works in the FIFO principle where first element stored in the
queue will be removed first.
It works just like a queue of people in the ticket counter where first person on the queue will get the
ticket first.
In a queue, addition and removal are performed from separate ends.
21
4. Linked List Data Structure
In linked list data structure, data elements are connected through a series of nodes. And each node
contains the data items and address to the next node.
A linked list
22
Unlike linear data structures, elements in non-linear data structures are not in any sequence. Instead they
are arranged in a hierarchical manner where one element will be connected to one or more elements.
Non-linear data structures are further divided into graph and tree-based data structures.
1. Graph Data Structure
In graph data structure, each node is called vertex and each vertex is connected to other
vertices through edges.
Graph data structure example
Non-linear data structures
23
2. Trees Data Structure
Like a graph, a tree is also a collection of vertices and edges. However, in tree data
structure, here can only be one edge between two vertices.
Tree data structure example
Non-linear data structures
24
Now that we know about linear and non-linear data structures, let's see the major differences between
them.
Linear Vs Non-linear Data Structures
Linear Data Structures Non-Linear Data Structures
The data items are arranged in sequential
order, one after the other.
The data items are arranged in non-
sequential order (hierarchical manner).
All the items are present on the single
layer.
The data items are present at different
layers.
It can be traversed on a single run. That
is, if we start from the first element, we
can traverse all the elements sequentially
in a single pass.
It requires multiple runs. That is, if we start
from the first element it might not be
possible to traverse all the elements in a
single pass.
The memory utilization is not efficient.
Different structures utilize memory in
different efficient ways depending on the
need.
The time complexity increases with the
data size.
Time complexity remains the same.
Example: Arrays, Stack, Queue Example: Tree, Graph, Map
Thank you
Presenter name: Ellen Grace D. Porras
Email address: egporras@psu.palawan.edu.ph

Contenu connexe

Tendances

Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureBalwant Gorad
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
Classification of datastructure.ppt
Classification of datastructure.pptClassification of datastructure.ppt
Classification of datastructure.pptLakshmiSamivel
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data StructureJeanie Arnoco
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using javaNarayan Sau
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysisjayavignesh86
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Poojith Chowdhary
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design PresentationKawsar Ahmed
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
Array ADT(Abstract Data Type)|Data Structure
Array ADT(Abstract Data Type)|Data StructureArray ADT(Abstract Data Type)|Data Structure
Array ADT(Abstract Data Type)|Data StructureAkash Gaur
 

Tendances (20)

Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Classification of datastructure.ppt
Classification of datastructure.pptClassification of datastructure.ppt
Classification of datastructure.ppt
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysis
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Array ADT(Abstract Data Type)|Data Structure
Array ADT(Abstract Data Type)|Data StructureArray ADT(Abstract Data Type)|Data Structure
Array ADT(Abstract Data Type)|Data Structure
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 

Similaire à DSA Fundamentals: Data Structures and Algorithms

Data Structure Notes unit 1.docx
Data Structure Notes unit 1.docxData Structure Notes unit 1.docx
Data Structure Notes unit 1.docxkp370932
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfDukeCalvin
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structuressonykhan3
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptxclassall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptxclassall
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.pptclassall
 
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.pdfAxmedcarb
 
Introduction to Data Structure & algorithm
Introduction to Data Structure & algorithmIntroduction to Data Structure & algorithm
Introduction to Data Structure & algorithmSunita Bhosale
 
ADS Introduction
ADS IntroductionADS Introduction
ADS IntroductionNagendraK18
 
Unit 1 Introduction Part 3.pptx
Unit 1 Introduction Part 3.pptxUnit 1 Introduction Part 3.pptx
Unit 1 Introduction Part 3.pptxNishaRohit6
 

Similaire à DSA Fundamentals: Data Structures and Algorithms (20)

dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
Data Structure Notes unit 1.docx
Data Structure Notes unit 1.docxData Structure Notes unit 1.docx
Data Structure Notes unit 1.docx
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 
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
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
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
 
Introduction to Data Structure & algorithm
Introduction to Data Structure & algorithmIntroduction to Data Structure & algorithm
Introduction to Data Structure & algorithm
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Unit 1 Introduction Part 3.pptx
Unit 1 Introduction Part 3.pptxUnit 1 Introduction Part 3.pptx
Unit 1 Introduction Part 3.pptx
 
CPP12 - Algorithms
CPP12 - AlgorithmsCPP12 - Algorithms
CPP12 - Algorithms
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 

Plus de EllenGrace9

Plus de EllenGrace9 (8)

3. ERD.pptx
3. ERD.pptx3. ERD.pptx
3. ERD.pptx
 
4. ERD Cardinality.pptx
4. ERD Cardinality.pptx4. ERD Cardinality.pptx
4. ERD Cardinality.pptx
 
3. Venn Diagram.pptx
3. Venn Diagram.pptx3. Venn Diagram.pptx
3. Venn Diagram.pptx
 
Introduction.pptx
Introduction.pptxIntroduction.pptx
Introduction.pptx
 
Sets.pdf
Sets.pdfSets.pdf
Sets.pdf
 
Sets.pptx
Sets.pptxSets.pptx
Sets.pptx
 
implication.pdf
implication.pdfimplication.pdf
implication.pdf
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 

Dernier

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Dernier (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

DSA Fundamentals: Data Structures and Algorithms

  • 1. Data Structures and Algorithm INSTRUCTOR: ELLEN GRACE PORRAS FIRST SEMESTER 2022-2023
  • 2. Introduction Data Structure • Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. • Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. It represents the knowledge of data to be organized in memory. • It should be designed and implemented in such a way that it reduces the complexity and increases the efficiency.
  • 3. Characteristics of a Data Structure 3 • Correctness − Data structure implementation should implement its interface correctly. • Time Complexity − Running time or the execution time of operations of data structure must be as small as possible. • Space Complexity − Memory usage of a data structure operation should be as little as possible.
  • 4. Need for Data Structure 4 As applications are getting complex and data rich, there are three common problems that applications face now-a-days. • Data Search − Consider an inventory of 1 million (106) items of a store. If the application is to search an item, it has to search an item in 1 million (106) items every time slowing down the search. As data grows, search will become slower. • Processor Speed − Processor speed although being very high, falls limited if the data grows to billion records. • Multiple Requests − as thousands of users can search data simultaneously on a web server, even the fast server fails while searching the data. To solve the above-mentioned problems, data structures come to rescue. Data can be organized in a data structure in such a way that all items may not be required to be searched, and the required data can be searched almost instantly
  • 5. What is an Algorithm? 5 • 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. • In computer programming terms, an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input(s) and produces the desired output. For example: An algorithm to add two numbers: • Take two number inputs • Add numbers using the + operator • Display the result
  • 6. 6 Let us consider the problem of preparing an omelette. To prepare an omelette, we follow the steps given below: 1) Get the frying pan. 2) Get the oil. a. Do we have oil? • If yes, put it in the pan. • If no, do we want to buy oil?  If yes, then go out and buy.  If no, we can terminate. 3)Turn on the stove, etc... What we are doing is, for a given problem (preparing an omelette), we are providing a step-by step procedure for solving it. The formal definition of an algorithm can be stated as: An algorithm is the step-by-step unambiguous instructions to solve a given problem.
  • 7. Qualities of a Good Algorithm 7 • Input and output should be defined precisely. • Each step in the algorithm should be clear and unambiguous. • Algorithms should be most effective among many ways to solve a problem. • An algorithm shouldn't include computer code. Instead, the algorithm should be written in such a way that it can be used in different programming languages.
  • 8. 8 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.
  • 9. Characteristics of an Algorithm 9 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.
  • 10. Algorithm 1: Add two numbers entered by the user 10 Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6: Stop
  • 11. Algorithm 2: Find the largest number among three numbers 11 Step 1: Start Step 2: Declare variables a,b and c. Step 3: Read variables a,b and c. Step 4: If a > b If a > c Display a is the largest number. Else Display c is the largest number. Else If b > c Display b is the largest number. Else Display c is the greatest number. Step 5: Stop
  • 12. A good algorithm maintains a level of correctness while being efficient. Meaning, there is little error, and it doesn’t take much time to complete. Another important component is comprehensibility. We wouldn’t be able to use algorithms so frequently if they couldn’t be understood. Algorithmic and computational thinking is so pervasive that it governs the simplest things in our daily lives. Here are some examples of algorithms you interact with everyday. 12
  • 13. Recipes Just like sorting papers and even tying your shoes, following a recipe is a type of algorithm. The goal of course being to create a duplicated outcome. In order to complete a recipe, you must follow a given set of steps. Say you are making bread. You need flour, yeast and water. After you have your ingredients, you need to combine them in a certain way that will create a predictable outcome, in this case a loaf of bread. 13
  • 14. A simple task and yet it uses algorithmic thinking. When you are sorting office files or your personal documents you are implementing an algorithm. In its most basic sense, you are following a set of tasks to achieve an outcome. The reason why sorting papers is a great example, is because it shows the variety of tasks and specifications algorithms can use. For instance, you can sort your files alphabetically, by word count, by date, and countless others. The goal is to simplify the organizational process by using small tasks. 14 Sorting Papers
  • 16. Write down at least 3 algorithms you interact with everyday and present it in front of the class. 16
  • 17. Types of Data Structure 17 Basically, data structures are divided into two categories: • Linear data structure • Non-linear data structure Linear data structures • In linear data structures, the elements are arranged in sequence one after the other. Since elements are arranged order, they are easy to implement. • However, when the complexity of the program increases, the linear data structures might not be the best choice because of operational complexities
  • 18. 18 Popular linear data structures are: 1. Array Data Structure In an array, elements in memory are arranged in continuous memory. All the elements of an array are of the same type. And the type of elements that can be stored in the form of arrays is determined by the programming language. An array with each element represented by an index
  • 19. 19 2. Stack Data Structure In stack data structure, elements are stored in the LIFO principle. That is, the last element stored in a stack will be removed first. It works just like a pile of plates where the last plate kept on the pile will be removed first. In a stack, operations can be performed only from one end (top here).
  • 20. 20 3. Queue Data Structure Unlike stack, the queue data structure works in the FIFO principle where first element stored in the queue will be removed first. It works just like a queue of people in the ticket counter where first person on the queue will get the ticket first. In a queue, addition and removal are performed from separate ends.
  • 21. 21 4. Linked List Data Structure In linked list data structure, data elements are connected through a series of nodes. And each node contains the data items and address to the next node. A linked list
  • 22. 22 Unlike linear data structures, elements in non-linear data structures are not in any sequence. Instead they are arranged in a hierarchical manner where one element will be connected to one or more elements. Non-linear data structures are further divided into graph and tree-based data structures. 1. Graph Data Structure In graph data structure, each node is called vertex and each vertex is connected to other vertices through edges. Graph data structure example Non-linear data structures
  • 23. 23 2. Trees Data Structure Like a graph, a tree is also a collection of vertices and edges. However, in tree data structure, here can only be one edge between two vertices. Tree data structure example Non-linear data structures
  • 24. 24 Now that we know about linear and non-linear data structures, let's see the major differences between them. Linear Vs Non-linear Data Structures Linear Data Structures Non-Linear Data Structures The data items are arranged in sequential order, one after the other. The data items are arranged in non- sequential order (hierarchical manner). All the items are present on the single layer. The data items are present at different layers. It can be traversed on a single run. That is, if we start from the first element, we can traverse all the elements sequentially in a single pass. It requires multiple runs. That is, if we start from the first element it might not be possible to traverse all the elements in a single pass. The memory utilization is not efficient. Different structures utilize memory in different efficient ways depending on the need. The time complexity increases with the data size. Time complexity remains the same. Example: Arrays, Stack, Queue Example: Tree, Graph, Map
  • 25. Thank you Presenter name: Ellen Grace D. Porras Email address: egporras@psu.palawan.edu.ph