SlideShare a Scribd company logo
1 of 25
CS261
DATA STRUCTURES & ALGORITHMS
(WEEK-1)
LECTURE-1 & 2
INTRODUCTION TO DATA STRUCTURES & ALGORITHMS
Lecturer
Azka Aziz
Azka.a@scocs.edu.pk
2
 Assignment = 10% (Research review report)
 Quizzes = 20%
 Mid-Term = 30%
 Final Exam = 40%
 Week 1: Introduction to data structures, algorithm ,Pseudo code, Al-Khawarzmi’s Principle
Relation of algorithm with Data Structures Multiplication of numbers Multiplication Problem
with Iterative.
 Week 2: Array Data structure ,Multidimensional arrays, Dynamic Arrays, Link List
 Week 3: Double Link list , Insertion , Deletion, Insert after, Insert Before
 Week 4: More on Asymptotic Analysis Insertion Sort Merge Sort, Selection sort, Bubble Sort
 Week 5: Substitution Method Master Theorem Tree Method
 Week 6: Select Algorithm (Kth Smallest and Kth Largest Element) Quick Sort Difference From
Merge Sort
 Week 7: Sorting Lower Bounds and O(n) Sorting Radix Sort Counting Sort
 Week 8: Binary Search Tree using Array Binary Search Tree using linked
list
 Week 9: AVL Trees RB Tree using Linked List
 Week 10: Hashing Hash Functions Hash Tables
 Week 11: Stack using Link List, using Arrays
 Week 12: Queues using Link List, using Arrays
 Week 13: Graph Basics Graphs Representation Graph Types Basic Graphs
Algorithm
 Week 14: DFS BFS Strongly Connected Components Topological
Order
 Week 15: Minimum Spanning Tree
 Week 16: Shortest Path
 CLO1 Understand the fundamentals data structures such as lists,
queues, trees, etc.
 CLO2 Analyze time and space complexities of data structures and
algorithms
 CLO3 Select appropriate algorithms to use in specific applications
Data Structure = Data + Structure
“A specialize format to store data in a particular
organization”. Any data structure is designed to enable certain
operations in an efficient manner e.g. Queue is a data structure
that facilitates data items to be stored in a manner that supports
first come first serve order.
Similarly there are many data structures already designed to meet
certain objectives including Array, Stack, Tree, Graph etc.
“An algorithm is any well-defined computational procedure that takes
some values, or set of values, as input and produces some value, or set of
values, as output”
 Algorithm is basic element of programming
 A mathematical entity independent of programming languages,
operating system & compiler
 Algorithms provide a scientific way of handling general programming
techniques
 Given any input values, an algorithm will definitely terminate after
executing a finite number of steps
“A data container whose contents can vary”
Say a variable ‘radius’ is defined as integer using any
programming language in a program then its value can
be changed as the result of assignment within the
lifetime of that variable when that variable is in scope
“A data type is a classification of data that tells the compiler or
interpreter how the variables (declared with that data type) will
be used”
Every data type allows a certain type of data values (and
forbids other types) e.g. typically a data type ‘int’ allows
numerical values without decimal points with a certain range
while not allowing string data
All variables defined with same data type will have same
range and permitted data
“An abstract data type (ADT) is a set of elements
with a collection of well defined set of operations”
Said operations can take the same ADT instances
as well as other ADT instances as operands
Operation results may not be instances of same
ADT
Java / C++ allows ADTs by means of classes
Data Structure = Data + Structure
“A specialize format to store data in a particular
organization”. Any data structure is designed to enable certain
operations in an efficient manner e.g. Queue is a data structure
that facilitates data items to be stored in a manner that supports
first come first serve order.
Similarly there are many data structures already designed to
meet certain objectives including Array, Stack, Tree, Graph etc.
“An implementation of an ADT using a
programming language is called a data structure”
Data structure includes data items stored
Data structure also includes implementation of
all operations within the data structure
A data structure allows different operations in an
efficient way but it certainly has its cost
Time Vs. Space complexity
Trying to achieve efficiency in one operation may
make other operations less efficient
Generality may not be achieved
While enabling certain operations, simplicity may be
compromised
While designing a data structure, following questions
should be asked:
Does this data structure support the required
operations efficiently?
Will it be easier to implement in our desired
programming language?
Will be easier to debug?
What are the possibilities for its usage?
What operands should it support?
 What is a Static Data structure?
In Static data structure the size of the structure is fixed. The
content of the data structure can be modified but without
changing the memory space allocated to it. Example Array
 In Dynamic data structure the size of the structure in not
fixed and can be modified during the operations performed
on it. Dynamic data structures are designed to facilitate
change of data structures in the run time. Example: Link List
 Linear Data Structure:
Data structure where data elements are arranged sequentially
or linearly where each and every element is attached to its
previous and next adjacent is called a linear data structure. In
linear data structure, single level is involved. Therefore, we
can traverse all the elements in single run only. Linear data
structures are easy to implement because computer memory
is arranged in a linear way. Its examples
are array, stack, queue, linked list, etc.
Non-linear Data Structure:
Data structures where data
elements are not arranged sequentially or linearly are
called non-linear data structures. In a non-linear
data structure, single level is not involved. Therefore,
we can’t traverse all the elements in single run only.
Non-linear data structures are not easy to implement
in comparison to linear data structure. It utilizes
computer memory efficiently in comparison to a
linear data structure. Its examples
are trees and graphs.
 Physical Data Structure:
The Array and Link List are the two physical data structures. We can have
more physical data structures by taking the combination of these two data
structures i.e. array and linked list.
 Logical Data Structure:
Physical data structures are actually meant for storing the data in the
memory. Then on the stored data or values, we may be performing some
operations like inserting more values or deleting existing values or
searching for the values, and many more operations. Now, the question is,
how you want to utilize those values? How you will be performing
insertion and deletion? What is the discipline that you are going to follow?
That discipline is defined by logical data structures i.e. stack, queues, trees,
graphs, and hash table.
 Al-Khwarizmi left a golden rule for the world to create science with. The al-Khwarizmi
principle states that all complex problems of science must be and can be solved by means of
the following five simple steps:
1. Break down each problem into a number of elemental or ‘atomic’ steps. An elemental or
atomic step is one, which cannot be simplified any further.
2. Second, arrange all the elements or steps of the problem in an order or sequence, such that
each element can be taken up and solved one at a time, without affecting other parts of the
problem.
3. Next, find a way to solve each of the elements separately. Because each element has been
simplified to the maximum, it is very likely that the solution of an elemental step will itself be
extremely simple or elemental making it available with relative ease.
4. Then proceed to solve each element of the problem, either one at a time or several at a time,
but in the correct order. Thus, when all steps are solved, the original problem itself has also
been solved.
 Pseudocode is the expressive form of the algorithm or a way to describe
an algorithm.
 It is a combination of natural language and high-level programming
practices which represent the fundamental concept behind a general
implementation of a data structure or algorithm.
 Pseudocode incorporated the natural language when the details are
insignificant with the standard programming language constructs to
obtain more clarity. However, we can not execute pseudocode on a
computer, but it models the actual programming code along with a
similar level of detail.
Pseudocode is also written using some specific words and
characters, which are shown below:
1. To begin the comment double forward slash are used “//“.
2. Matching braces “{ and }” are used to present blocks where a compound
statement (set of simple statements) can be illustrated as a block and
terminated by a semicolon”;“. The body of a procedure constructs a block
as well.
3. All the identifiers start with a letter and the datatype of the variables are
not declared explicitly.
4. An assignment statement is used for the assigning values to the variables.
5. To produce the boolean values (i.e., true and false) the logical operators
and, or and not and the relational operators <, ≤, =, =, ≥ and > are
provided.
6. Input and output are presented by read and write instructions.
7. “if and then” expressions are used to express a conditional statement.
 An algorithm is a definite, clear sequence-wise procedure to solve a
problem. It involves the high-level language builds which cannot be
understood by a non-technical person. On the other hand, pseudocode is
a more plain and human understandable form of algorithm where
natural language is also combined with the high-level programming
language constructs.
 Pseudocode is easy to understand and interpret as compared to an
algorithm.
 The algorithm uses high-level constructs meaning the snippet of code
but the pseudocode involves natural language with high-level
programming builds.
 Pseudocode is easily constructed and debugged relative to the
algorithm.

More Related Content

Similar to Data Structure.pptx

Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureRai University
 
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
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureRai University
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureRai University
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS Adams Sidibe
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01shaziabibi5
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
computer notes - Circular list
computer notes - Circular listcomputer notes - Circular list
computer notes - Circular listecomputernotes
 
Data Analysis – Technical learnings
Data Analysis – Technical learningsData Analysis – Technical learnings
Data Analysis – Technical learningsInvenkLearn
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Tutort Academy
 

Similar to Data Structure.pptx (20)

Data structure
Data structureData structure
Data structure
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
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
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Data structures cs301 power point slides lecture 01
Data structures   cs301 power point slides lecture 01Data structures   cs301 power point slides lecture 01
Data structures cs301 power point slides lecture 01
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
CSE 443 (1).pptx
CSE 443 (1).pptxCSE 443 (1).pptx
CSE 443 (1).pptx
 
computer notes - Circular list
computer notes - Circular listcomputer notes - Circular list
computer notes - Circular list
 
Database system
Database system Database system
Database system
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Data Analysis – Technical learnings
Data Analysis – Technical learningsData Analysis – Technical learnings
Data Analysis – Technical learnings
 
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 models
Data modelsData models
Data models
 
Data models
Data modelsData models
Data models
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
 
Intro ds
Intro dsIntro ds
Intro ds
 

More from SajalFayyaz

Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.pptSajalFayyaz
 
data structure 9.pptx
data structure 9.pptxdata structure 9.pptx
data structure 9.pptxSajalFayyaz
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Data structure 6.pptx
Data structure 6.pptxData structure 6.pptx
Data structure 6.pptxSajalFayyaz
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 

More from SajalFayyaz (10)

Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.ppt
 
data structure 9.pptx
data structure 9.pptxdata structure 9.pptx
data structure 9.pptx
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Data structure 6.pptx
Data structure 6.pptxData structure 6.pptx
Data structure 6.pptx
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 

Recently uploaded

INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationHelp Desk Migration
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfsteffenkarlsson2
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionWave PLM
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersEmilyJiang23
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 

Recently uploaded (20)

INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
AI Hackathon.pptx
AI                        Hackathon.pptxAI                        Hackathon.pptx
AI Hackathon.pptx
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 

Data Structure.pptx

  • 1. CS261 DATA STRUCTURES & ALGORITHMS (WEEK-1) LECTURE-1 & 2 INTRODUCTION TO DATA STRUCTURES & ALGORITHMS Lecturer Azka Aziz Azka.a@scocs.edu.pk
  • 2. 2  Assignment = 10% (Research review report)  Quizzes = 20%  Mid-Term = 30%  Final Exam = 40%
  • 3.  Week 1: Introduction to data structures, algorithm ,Pseudo code, Al-Khawarzmi’s Principle Relation of algorithm with Data Structures Multiplication of numbers Multiplication Problem with Iterative.  Week 2: Array Data structure ,Multidimensional arrays, Dynamic Arrays, Link List  Week 3: Double Link list , Insertion , Deletion, Insert after, Insert Before  Week 4: More on Asymptotic Analysis Insertion Sort Merge Sort, Selection sort, Bubble Sort  Week 5: Substitution Method Master Theorem Tree Method  Week 6: Select Algorithm (Kth Smallest and Kth Largest Element) Quick Sort Difference From Merge Sort
  • 4.  Week 7: Sorting Lower Bounds and O(n) Sorting Radix Sort Counting Sort  Week 8: Binary Search Tree using Array Binary Search Tree using linked list  Week 9: AVL Trees RB Tree using Linked List  Week 10: Hashing Hash Functions Hash Tables  Week 11: Stack using Link List, using Arrays  Week 12: Queues using Link List, using Arrays  Week 13: Graph Basics Graphs Representation Graph Types Basic Graphs Algorithm
  • 5.  Week 14: DFS BFS Strongly Connected Components Topological Order  Week 15: Minimum Spanning Tree  Week 16: Shortest Path
  • 6.  CLO1 Understand the fundamentals data structures such as lists, queues, trees, etc.  CLO2 Analyze time and space complexities of data structures and algorithms  CLO3 Select appropriate algorithms to use in specific applications
  • 7. Data Structure = Data + Structure “A specialize format to store data in a particular organization”. Any data structure is designed to enable certain operations in an efficient manner e.g. Queue is a data structure that facilitates data items to be stored in a manner that supports first come first serve order. Similarly there are many data structures already designed to meet certain objectives including Array, Stack, Tree, Graph etc.
  • 8. “An algorithm is any well-defined computational procedure that takes some values, or set of values, as input and produces some value, or set of values, as output”  Algorithm is basic element of programming  A mathematical entity independent of programming languages, operating system & compiler  Algorithms provide a scientific way of handling general programming techniques  Given any input values, an algorithm will definitely terminate after executing a finite number of steps
  • 9. “A data container whose contents can vary” Say a variable ‘radius’ is defined as integer using any programming language in a program then its value can be changed as the result of assignment within the lifetime of that variable when that variable is in scope
  • 10. “A data type is a classification of data that tells the compiler or interpreter how the variables (declared with that data type) will be used” Every data type allows a certain type of data values (and forbids other types) e.g. typically a data type ‘int’ allows numerical values without decimal points with a certain range while not allowing string data All variables defined with same data type will have same range and permitted data
  • 11. “An abstract data type (ADT) is a set of elements with a collection of well defined set of operations” Said operations can take the same ADT instances as well as other ADT instances as operands Operation results may not be instances of same ADT Java / C++ allows ADTs by means of classes
  • 12. Data Structure = Data + Structure “A specialize format to store data in a particular organization”. Any data structure is designed to enable certain operations in an efficient manner e.g. Queue is a data structure that facilitates data items to be stored in a manner that supports first come first serve order. Similarly there are many data structures already designed to meet certain objectives including Array, Stack, Tree, Graph etc.
  • 13. “An implementation of an ADT using a programming language is called a data structure” Data structure includes data items stored Data structure also includes implementation of all operations within the data structure
  • 14. A data structure allows different operations in an efficient way but it certainly has its cost Time Vs. Space complexity Trying to achieve efficiency in one operation may make other operations less efficient Generality may not be achieved While enabling certain operations, simplicity may be compromised
  • 15. While designing a data structure, following questions should be asked: Does this data structure support the required operations efficiently? Will it be easier to implement in our desired programming language? Will be easier to debug? What are the possibilities for its usage? What operands should it support?
  • 16.
  • 17.  What is a Static Data structure? In Static data structure the size of the structure is fixed. The content of the data structure can be modified but without changing the memory space allocated to it. Example Array
  • 18.  In Dynamic data structure the size of the structure in not fixed and can be modified during the operations performed on it. Dynamic data structures are designed to facilitate change of data structures in the run time. Example: Link List
  • 19.  Linear Data Structure: Data structure where data elements are arranged sequentially or linearly where each and every element is attached to its previous and next adjacent is called a linear data structure. In linear data structure, single level is involved. Therefore, we can traverse all the elements in single run only. Linear data structures are easy to implement because computer memory is arranged in a linear way. Its examples are array, stack, queue, linked list, etc.
  • 20. Non-linear Data Structure: Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures. In a non-linear data structure, single level is not involved. Therefore, we can’t traverse all the elements in single run only. Non-linear data structures are not easy to implement in comparison to linear data structure. It utilizes computer memory efficiently in comparison to a linear data structure. Its examples are trees and graphs.
  • 21.  Physical Data Structure: The Array and Link List are the two physical data structures. We can have more physical data structures by taking the combination of these two data structures i.e. array and linked list.  Logical Data Structure: Physical data structures are actually meant for storing the data in the memory. Then on the stored data or values, we may be performing some operations like inserting more values or deleting existing values or searching for the values, and many more operations. Now, the question is, how you want to utilize those values? How you will be performing insertion and deletion? What is the discipline that you are going to follow? That discipline is defined by logical data structures i.e. stack, queues, trees, graphs, and hash table.
  • 22.  Al-Khwarizmi left a golden rule for the world to create science with. The al-Khwarizmi principle states that all complex problems of science must be and can be solved by means of the following five simple steps: 1. Break down each problem into a number of elemental or ‘atomic’ steps. An elemental or atomic step is one, which cannot be simplified any further. 2. Second, arrange all the elements or steps of the problem in an order or sequence, such that each element can be taken up and solved one at a time, without affecting other parts of the problem. 3. Next, find a way to solve each of the elements separately. Because each element has been simplified to the maximum, it is very likely that the solution of an elemental step will itself be extremely simple or elemental making it available with relative ease. 4. Then proceed to solve each element of the problem, either one at a time or several at a time, but in the correct order. Thus, when all steps are solved, the original problem itself has also been solved.
  • 23.  Pseudocode is the expressive form of the algorithm or a way to describe an algorithm.  It is a combination of natural language and high-level programming practices which represent the fundamental concept behind a general implementation of a data structure or algorithm.  Pseudocode incorporated the natural language when the details are insignificant with the standard programming language constructs to obtain more clarity. However, we can not execute pseudocode on a computer, but it models the actual programming code along with a similar level of detail.
  • 24. Pseudocode is also written using some specific words and characters, which are shown below: 1. To begin the comment double forward slash are used “//“. 2. Matching braces “{ and }” are used to present blocks where a compound statement (set of simple statements) can be illustrated as a block and terminated by a semicolon”;“. The body of a procedure constructs a block as well. 3. All the identifiers start with a letter and the datatype of the variables are not declared explicitly. 4. An assignment statement is used for the assigning values to the variables. 5. To produce the boolean values (i.e., true and false) the logical operators and, or and not and the relational operators <, ≤, =, =, ≥ and > are provided. 6. Input and output are presented by read and write instructions. 7. “if and then” expressions are used to express a conditional statement.
  • 25.  An algorithm is a definite, clear sequence-wise procedure to solve a problem. It involves the high-level language builds which cannot be understood by a non-technical person. On the other hand, pseudocode is a more plain and human understandable form of algorithm where natural language is also combined with the high-level programming language constructs.  Pseudocode is easy to understand and interpret as compared to an algorithm.  The algorithm uses high-level constructs meaning the snippet of code but the pseudocode involves natural language with high-level programming builds.  Pseudocode is easily constructed and debugged relative to the algorithm.