SlideShare a Scribd company logo
Data Structure & Algorithm
Hassan Khan
Data
• Data is a collection of facts and figures or a set of values or values of a
specific format that refers to a single set of item values. The data
items are then classified into sub-items, which is the group of items
that are not known as the simple primary form of the item.
What is Data Structure?
“Data Structure is a branch of Computer Science. The study of data structure allows us to understand the
organization of data and the management of the data flow in order to increase the efficiency of any process or
program. Data Structure is a particular way of storing and organizing data in the memory of the computer so
that these data can easily be retrieved and efficiently utilized in the future when required. The data can be
managed in various ways, like the logical or mathematical model for a specific organization of data is known as
a data structure.”
The scope of a particular data model depends on two factors:
• First, it must be loaded enough into the structure to reflect the definite correlation of the data with a real-
world object.
• Second, the formation should be so straightforward that one can adapt to process the data efficiently
whenever necessary.
• Some examples of Data Structures are Arrays, Linked Lists, Stack, Queue, Trees, etc. Data Structures are
widely used in almost every aspect of Computer Science, i.e., Compiler Design, Operating Systems, Graphics,
Artificial Intelligence, and many more.
Data Structures are the main part of many Computer Science
Algorithms as they allow the programmers to manage the data
in an effective way. It plays a crucial role in improving the
performance of a program or software, as the main objective
of the software is to store and retrieve the user's data as fast
as possible.
Basic Terminologies related to Data Structures
• Data Structures are the building blocks of any software or program. Selecting the suitable data
structure for a program is an extremely challenging task for a programmer.
• The following are some fundamental terminologies used whenever the data structures are
involved:
• Data: We can define data as an elementary value or a collection of values. For example, the
Employee's name and ID are the data related to the Employee.
• Data Items: A Single unit of value is known as Data Item.
• Group Items: Data Items that have subordinate data items are known as Group Items. For
example, an employee's name can have a first, middle, and last name.
• Elementary Items: Data Items that are unable to divide into sub-items are known as Elementary
Items. For example, the ID of an Employee.
• Entity and Attribute: A class of certain objects is represented by an Entity. It consists of different
Attributes. Each Attribute symbolizes the specific property of that Entity.
Understanding the Need for Data Structures
• As applications are becoming more complex and the amount of data
is increasing every day, which may lead to problems with data
searching, processing speed, multiple requests handling, and many
more. Data Structures support different methods to organize,
manage, and store data efficiently. With the help of Data Structures,
we can easily traverse the data items. Data Structures provide
Efficiency, Reusability, and Abstraction.
Why should we learn Data Structures?
• Data Structures and Algorithms are two of the key aspects of
Computer Science.
• Data Structures allow us to organize and store data, whereas
Algorithms allow us to process that data meaningfully.
• Learning Data Structures and Algorithms will help us become better
Programmers.
• We will be able to write code that is more effective and reliable.
• We will also be able to solve problems more quickly and efficiently.
Understanding the Objectives of Data Structures
Data Structures satisfy two complementary objectives:
• Correctness: Data Structures are designed to operate correctly for all kinds
of inputs based on the domain of interest. In order words, correctness
forms the primary objective of Data Structure, which always depends upon
the problems that the Data Structure is meant to solve.
• Efficiency: Data Structures also requires to be efficient. It should process
the data quickly without utilizing many computer resources like memory
space. In a real-time state, the efficiency of a data structure is a key factor
in determining the success and failure of the process.
Understanding some Key Features of Data
Structures
Some of the Significant Features of Data Structures are:
• Robustness: Generally, all computer programmers aim to produce software that yields
correct output for every possible input, along with efficient execution on all hardware
platforms. This type of robust software must manage both valid and invalid inputs.
• Adaptability: Building software applications like Web Browsers, Word Processors, and
Internet Search Engine include huge software systems that require correct and efficient
working or execution for many years. Moreover, software evolves due to emerging
technologies or ever-changing market conditions.
• Reusability: The features like Reusability and Adaptability go hand in hand. It is known
that the programmer needs many resources to build any software, making it a costly
enterprise. However, if the software is developed in a reusable and adaptable way, then
it can be applied in most future applications. Thus, by executing quality data structures, it
is possible to build reusable software, which appears to be cost-effective and timesaving.
Classification of Data Structures
A Data Structure delivers a structured set of variables related to each
other in various ways. It forms the basis of a programming tool that
signifies the relationship between the data elements and allows
programmers to process the data efficiently.
We can classify Data Structures into two categories:
1.Primitive Data Structure
2.Non-Primitive Data Structure
Primitive Data Structures
• Primitive Data Structures are the data structures consisting of the
numbers and the characters that come in-built into programs.
• These data structures can be manipulated or operated directly by
machine-level instructions.
• Basic data types like Integer, Float, Character, and Boolean come
under the Primitive Data Structures.
• These data types are also called Simple data types, as they contain
characters that can't be divided further
Non-Primitive Data Structures
• Non-Primitive Data Structures are those data structures derived from
Primitive Data Structures.
• These data structures can't be manipulated or operated directly by
machine-level instructions.
• The focus of these data structures is on forming a set of data elements that
is either homogeneous (same data type) or heterogeneous (different data
types).
• Based on the structure and arrangement of data, we can divide these data
structures into two sub-categories -
Linear Data Structures
Non-Linear Data Structures
Linear Data Structures
• A data structure that preserves a linear connection among its data elements is known as a Linear Data
Structure. The arrangement of the data is done linearly, where each element consists of the successors and
predecessors except the first and the last data element. However, it is not necessarily true in the case of
memory, as the arrangement may not be sequential.
• Based on memory allocation, the Linear Data Structures are further classified into two types:
1. Static Data Structures: The data structures having a fixed size are known as Static Data Structures. The
memory for these data structures is allocated at the compiler time, and their size cannot be changed by
the user after being compiled; however, the data stored in them can be altered.
The Array is the best example of the Static Data Structure as they have a fixed size, and its data can be
modified later.
2. Dynamic Data Structures: The data structures having a dynamic size are known as Dynamic Data
Structures. The memory of these data structures is allocated at the run time, and their size varies during
the run time of the code. Moreover, the user can change the size as well as the data elements stored in
these data structures at the run time of the code.
• Linked Lists, Stacks, and Queues are common examples of dynamic data structures
Lecture 1. Data Structure & Algorithm.pptx
Linear Data Structures
Static Linear Data Structures
Arrays
An Array is a data structure used to collect multiple data elements of the same data type
into one variable. Instead of storing multiple values of the same data types in separate
variable names, we could store all of them together into one variable. This statement
doesn't imply that we will have to unite all the values of the same data type in any program
into one array of that data type. But there will often be times when some specific variables
of the same data types are all related to one another in a way appropriate for an array.
• An Array is a list of elements where each element has a unique place in the list. The data
elements of the array share the same variable name; however, each carries a different
index number called a subscript. We can access any data element from the list with the
help of its location in the list. Thus, the key feature of the arrays to understand is that the
data is stored in contiguous memory locations, making it possible for the users to
traverse through the data elements of the array using their respective indexes.
Lecture 1. Data Structure & Algorithm.pptx
Arrays can be classified into different types:
• One-Dimensional Array: An Array with only one row of data elements
is known as a One-Dimensional Array. It is stored in ascending storage
location.
• Two-Dimensional Array: An Array consisting of multiple rows and
columns of data elements is called a Two-Dimensional Array. It is also
known as a Matrix.
• Multidimensional Array: We can define Multidimensional Array as an
Array of Arrays. Multidimensional Arrays are not bounded to two
indices or two dimensions as they can include as many indices are per
the need.
Some Applications of Array:
1. We can store a list of data elements belonging to the same data
type.
2. Array acts as an auxiliary storage for other data structures.
3. The array also helps store data elements of a binary tree of the
fixed count.
4. Array also acts as a storage of matrices.
Dynamic Linear Data Structures
Linked Lists
• A Linked List is another example of a linear data structure used to
store a collection of data elements dynamically. Data elements in this
data structure are represented by the Nodes, connected using links or
pointers. Each node contains two fields, the information field consists
of the actual data, and the pointer field consists of the address of the
subsequent nodes in the list. The pointer of the last node of the
linked list consists of a null pointer, as it points to nothing. Unlike the
Arrays, the user can dynamically adjust the size of a Linked List as per
the requirements.
Lecture 1. Data Structure & Algorithm.pptx
Linked Lists can be classified into different types:
• Singly Linked List: A Singly Linked List is the most common type of Linked
List. Each node has data and a pointer field containing an address to the
next node.
• Doubly Linked List: A Doubly Linked List consists of an information field
and two pointer fields. The information field contains the data. The first
pointer field contains an address of the previous node, whereas another
pointer field contains a reference to the next node. Thus, we can go in both
directions (backward as well as forward).
• Circular Linked List: The Circular Linked List is similar to the Singly Linked
List. The only key difference is that the last node contains the address of
the first node, forming a circular loop in the Circular Linked List.
Some Applications of Linked Lists:
1.The Linked Lists help us implement stacks, queues, binary trees,
and graphs of predefined size.
2.We can also implement Operating System's function for dynamic
memory management.
3.Linked Lists also allow polynomial implementation for mathematical
operations.
4.We can use Circular Linked List to implement Operating Systems or
application functions that Round Robin execution of tasks.
5.Circular Linked List is also helpful in a Slide Show where a user
requires to go back to the first slide after the last slide is presented.
6.Doubly Linked List is utilized to implement forward and backward
buttons in a browser to move forward and backward in the opened
pages of a website.
Stacks
• A Stack is a Linear Data Structure that follows the LIFO (Last In,
First Out) principle that allows operations like insertion and deletion
from one end of the Stack, i.e., Top. Stacks can be implemented with
the help of contiguous memory, an Array, and non-contiguous
memory, a Linked List. Real-life examples of Stacks are piles of
books, a deck of cards, piles of money, and many more.
The primary operations in the Stack are as follows:
Push: The operation to insert a new element in the Stack is termed as Push
Operation.
Pop: The operation to remove or delete elements from the Stack is termed
as Pop Operation.
Lecture 1. Data Structure & Algorithm.pptx
Some Applications of Stacks:
1. The Stack is used as a Temporary Storage Structure for recursive operations.
2. Stack is also utilized as Auxiliary Storage Structure for function calls, nested operations, and
deferred/postponed functions.
3. We can manage function calls using Stacks.
4. Stacks are also utilized to evaluate the arithmetic expressions in different programming languages.
5. Stacks are also helpful in converting infix expressions to postfix expressions.
6. Stacks allow us to check the expression's syntax in the programming environment.
7. We can match parenthesis using Stacks.
8. Stacks can be used to reverse a String.
9. Stacks are helpful in solving problems based on backtracking.
10. We can use Stacks in depth-first search in graph and tree traversal.
11. Stacks are also used in Operating System functions.
12. Stacks are also used in UNDO and REDO functions in an edit.
Queues
• A Queue is a linear data structure similar to a Stack with some
limitations on the insertion and deletion of the elements. The
insertion of an element in a Queue is done at one end, and the
removal is done at another or opposite end. Thus, we can conclude
that the Queue data structure follows FIFO (First In, First Out) principle
to manipulate the data elements. Implementation of Queues can be
done using Arrays, Linked Lists, or Stacks. Some real-life examples of
Queues are a line at the ticket counter, an escalator, a car wash, and
many more
Primary operations of the Queue:
Enqueue: The insertion or Addition of some data elements to the
Queue is called Enqueue. The element insertion is always done with
the help of the rear pointer.
• Dequeue: Deleting or removing data elements from the Queue is
termed Dequeue. The deletion of the element is always done with the
help of the front pointer.
Lecture 1. Data Structure & Algorithm.pptx
Some Applications of Queues:
• Queues are generally used in the breadth search operation in Graphs.
• Queues are also used in Job Scheduler Operations of Operating Systems,
like a keyboard buffer queue to store the keys pressed by users and a print
buffer queue to store the documents printed by the printer.
• Queues are responsible for CPU scheduling, Job scheduling, and Disk
Scheduling.
• Priority Queues are utilized in file-downloading operations in a browser.
• Queues are also used to transfer data between peripheral devices and the
CPU.
• Queues are also responsible for handling interrupts generated by the User
Applications for the CPU.
Ad

More Related Content

What's hot (20)

3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
Krish_ver2
 
Diagnostic in poisson regression models
Diagnostic in poisson regression modelsDiagnostic in poisson regression models
Diagnostic in poisson regression models
University of Southampton
 
Slide2
Slide2Slide2
Slide2
Thiti Sununta
 
6.5 central limit
6.5 central limit6.5 central limit
6.5 central limit
leblance
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
vikram mahendra
 
Topological sort
Topological sortTopological sort
Topological sort
Burhan Ahmed
 
Counting sort
Counting sortCounting sort
Counting sort
Imdad Ul Haq
 
RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
MumitAhmed1
 
Lec1
Lec1Lec1
Lec1
Anjneya Varshney
 
Ch02 3
Ch02 3Ch02 3
Ch02 3
Rendy Robert
 
Single linear regression
Single linear regressionSingle linear regression
Single linear regression
Ken Plummer
 
Scheduling algorithm in real time system
Scheduling algorithm in real time systemScheduling algorithm in real time system
Scheduling algorithm in real time system
VishalPandat2
 
Discrete maths questions
Discrete maths questionsDiscrete maths questions
Discrete maths questions
DIT University
 
Sampling distribution
Sampling distributionSampling distribution
Sampling distribution
Danu Saputra
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
Anurag Cheela
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
 
Arima model
Arima modelArima model
Arima model
Jassika
 
G. ripple counter
G. ripple counterG. ripple counter
G. ripple counter
john lexter emberador
 
L1 fuzzy sets & basic operations
L1 fuzzy sets & basic operationsL1 fuzzy sets & basic operations
L1 fuzzy sets & basic operations
Mohammad Umar Rehman
 
Hand Book of Information 2023-24_12052023_Version6 (1).pdf
Hand Book of Information 2023-24_12052023_Version6 (1).pdfHand Book of Information 2023-24_12052023_Version6 (1).pdf
Hand Book of Information 2023-24_12052023_Version6 (1).pdf
prishita2
 
6.5 central limit
6.5 central limit6.5 central limit
6.5 central limit
leblance
 
RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
MumitAhmed1
 
Single linear regression
Single linear regressionSingle linear regression
Single linear regression
Ken Plummer
 
Scheduling algorithm in real time system
Scheduling algorithm in real time systemScheduling algorithm in real time system
Scheduling algorithm in real time system
VishalPandat2
 
Discrete maths questions
Discrete maths questionsDiscrete maths questions
Discrete maths questions
DIT University
 
Sampling distribution
Sampling distributionSampling distribution
Sampling distribution
Danu Saputra
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
Anurag Cheela
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
 
Arima model
Arima modelArima model
Arima model
Jassika
 
Hand Book of Information 2023-24_12052023_Version6 (1).pdf
Hand Book of Information 2023-24_12052023_Version6 (1).pdfHand Book of Information 2023-24_12052023_Version6 (1).pdf
Hand Book of Information 2023-24_12052023_Version6 (1).pdf
prishita2
 

Similar to Lecture 1. Data Structure & Algorithm.pptx (20)

Data Structure Introduction.pdfssssssssssss
Data Structure Introduction.pdfssssssssssssData Structure Introduction.pdfssssssssssss
Data Structure Introduction.pdfssssssssssss
parwarsmko98
 
DSD Unit 1 Abstract Data Type data structures design notes.pptx
DSD Unit 1 Abstract Data Type data structures design notes.pptxDSD Unit 1 Abstract Data Type data structures design notes.pptx
DSD Unit 1 Abstract Data Type data structures design notes.pptx
yuvaraniit
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
Abirami A
 
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
ChaithraCSHirematt
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
Ranjithkumar C
 
Ch1_Intro-95(1).ppt
Ch1_Intro-95(1).pptCh1_Intro-95(1).ppt
Ch1_Intro-95(1).ppt
RAJULKUMARSUTHAR
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
Madishetty Prathibha
 
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
INTRODUCTION TO  DATA STRUCTURE & ABSTRACT DATA TYPE.pptxINTRODUCTION TO  DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
talhaarif554
 
Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)
Ismail Mukiibi
 
Computer applications.pptx
Computer applications.pptxComputer applications.pptx
Computer applications.pptx
Emmanuel235416
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
chatkall46
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
sunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
sunilchute1
 
Unit1 DBMS Introduction
Unit1 DBMS IntroductionUnit1 DBMS Introduction
Unit1 DBMS Introduction
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
Anaya Zafar
 
Unit 2 DATABASE ESSENTIALS.pptx
Unit 2 DATABASE ESSENTIALS.pptxUnit 2 DATABASE ESSENTIALS.pptx
Unit 2 DATABASE ESSENTIALS.pptx
Nirmalavenkatachalam
 
DSA
DSADSA
DSA
MamtaBhattarai3
 
Data concepts
Data conceptsData concepts
Data concepts
Sachidananda M H
 
Computer class of agriculture production 5.pptx
Computer class of agriculture production 5.pptxComputer class of agriculture production 5.pptx
Computer class of agriculture production 5.pptx
muddydevil2003
 
Database.pdf
Database.pdfDatabase.pdf
Database.pdf
l235546
 
Data Structure Introduction.pdfssssssssssss
Data Structure Introduction.pdfssssssssssssData Structure Introduction.pdfssssssssssss
Data Structure Introduction.pdfssssssssssss
parwarsmko98
 
DSD Unit 1 Abstract Data Type data structures design notes.pptx
DSD Unit 1 Abstract Data Type data structures design notes.pptxDSD Unit 1 Abstract Data Type data structures design notes.pptx
DSD Unit 1 Abstract Data Type data structures design notes.pptx
yuvaraniit
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
Abirami A
 
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
RDBMS UNIT-1.pdf PPT covered all basic cocepts of RDBMS and schema and compon...
ChaithraCSHirematt
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
Madishetty Prathibha
 
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
INTRODUCTION TO  DATA STRUCTURE & ABSTRACT DATA TYPE.pptxINTRODUCTION TO  DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
talhaarif554
 
Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)
Ismail Mukiibi
 
Computer applications.pptx
Computer applications.pptxComputer applications.pptx
Computer applications.pptx
Emmanuel235416
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
sunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
sunilchute1
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
Anaya Zafar
 
Computer class of agriculture production 5.pptx
Computer class of agriculture production 5.pptxComputer class of agriculture production 5.pptx
Computer class of agriculture production 5.pptx
muddydevil2003
 
Database.pdf
Database.pdfDatabase.pdf
Database.pdf
l235546
 
Ad

More from ArifKamal36 (16)

48583FrequencyDistributions_Week_1.2.3 (F).pptx
48583FrequencyDistributions_Week_1.2.3 (F).pptx48583FrequencyDistributions_Week_1.2.3 (F).pptx
48583FrequencyDistributions_Week_1.2.3 (F).pptx
ArifKamal36
 
03-arrays-pointers.ppt
03-arrays-pointers.ppt03-arrays-pointers.ppt
03-arrays-pointers.ppt
ArifKamal36
 
html-lists-tables.ppt
html-lists-tables.ppthtml-lists-tables.ppt
html-lists-tables.ppt
ArifKamal36
 
HTMLTables.ppt
HTMLTables.pptHTMLTables.ppt
HTMLTables.ppt
ArifKamal36
 
Basic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptxBasic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptx
ArifKamal36
 
DS1.pptx
DS1.pptxDS1.pptx
DS1.pptx
ArifKamal36
 
topic11LinkedLists.ppt
topic11LinkedLists.ppttopic11LinkedLists.ppt
topic11LinkedLists.ppt
ArifKamal36
 
3.ppt
3.ppt3.ppt
3.ppt
ArifKamal36
 
3.ppt
3.ppt3.ppt
3.ppt
ArifKamal36
 
2.ppt
2.ppt2.ppt
2.ppt
ArifKamal36
 
1.ppt
1.ppt1.ppt
1.ppt
ArifKamal36
 
CH5_Linked List.ppt
CH5_Linked List.pptCH5_Linked List.ppt
CH5_Linked List.ppt
ArifKamal36
 
Games.ppt
Games.pptGames.ppt
Games.ppt
ArifKamal36
 
IAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptxIAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptx
ArifKamal36
 
9916167.ppt
9916167.ppt9916167.ppt
9916167.ppt
ArifKamal36
 
e3-chap-01.ppt
e3-chap-01.ppte3-chap-01.ppt
e3-chap-01.ppt
ArifKamal36
 
48583FrequencyDistributions_Week_1.2.3 (F).pptx
48583FrequencyDistributions_Week_1.2.3 (F).pptx48583FrequencyDistributions_Week_1.2.3 (F).pptx
48583FrequencyDistributions_Week_1.2.3 (F).pptx
ArifKamal36
 
03-arrays-pointers.ppt
03-arrays-pointers.ppt03-arrays-pointers.ppt
03-arrays-pointers.ppt
ArifKamal36
 
html-lists-tables.ppt
html-lists-tables.ppthtml-lists-tables.ppt
html-lists-tables.ppt
ArifKamal36
 
Basic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptxBasic-HTML.9526794.powerpoint.pptx
Basic-HTML.9526794.powerpoint.pptx
ArifKamal36
 
topic11LinkedLists.ppt
topic11LinkedLists.ppttopic11LinkedLists.ppt
topic11LinkedLists.ppt
ArifKamal36
 
CH5_Linked List.ppt
CH5_Linked List.pptCH5_Linked List.ppt
CH5_Linked List.ppt
ArifKamal36
 
IAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptxIAT334-Lec01-Intro.pptx
IAT334-Lec01-Intro.pptx
ArifKamal36
 
Ad

Recently uploaded (20)

Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 

Lecture 1. Data Structure & Algorithm.pptx

  • 1. Data Structure & Algorithm Hassan Khan
  • 2. Data • Data is a collection of facts and figures or a set of values or values of a specific format that refers to a single set of item values. The data items are then classified into sub-items, which is the group of items that are not known as the simple primary form of the item.
  • 3. What is Data Structure? “Data Structure is a branch of Computer Science. The study of data structure allows us to understand the organization of data and the management of the data flow in order to increase the efficiency of any process or program. Data Structure is a particular way of storing and organizing data in the memory of the computer so that these data can easily be retrieved and efficiently utilized in the future when required. The data can be managed in various ways, like the logical or mathematical model for a specific organization of data is known as a data structure.” The scope of a particular data model depends on two factors: • First, it must be loaded enough into the structure to reflect the definite correlation of the data with a real- world object. • Second, the formation should be so straightforward that one can adapt to process the data efficiently whenever necessary. • Some examples of Data Structures are Arrays, Linked Lists, Stack, Queue, Trees, etc. Data Structures are widely used in almost every aspect of Computer Science, i.e., Compiler Design, Operating Systems, Graphics, Artificial Intelligence, and many more.
  • 4. Data Structures are the main part of many Computer Science Algorithms as they allow the programmers to manage the data in an effective way. It plays a crucial role in improving the performance of a program or software, as the main objective of the software is to store and retrieve the user's data as fast as possible.
  • 5. Basic Terminologies related to Data Structures • Data Structures are the building blocks of any software or program. Selecting the suitable data structure for a program is an extremely challenging task for a programmer. • The following are some fundamental terminologies used whenever the data structures are involved: • Data: We can define data as an elementary value or a collection of values. For example, the Employee's name and ID are the data related to the Employee. • Data Items: A Single unit of value is known as Data Item. • Group Items: Data Items that have subordinate data items are known as Group Items. For example, an employee's name can have a first, middle, and last name. • Elementary Items: Data Items that are unable to divide into sub-items are known as Elementary Items. For example, the ID of an Employee. • Entity and Attribute: A class of certain objects is represented by an Entity. It consists of different Attributes. Each Attribute symbolizes the specific property of that Entity.
  • 6. Understanding the Need for Data Structures • As applications are becoming more complex and the amount of data is increasing every day, which may lead to problems with data searching, processing speed, multiple requests handling, and many more. Data Structures support different methods to organize, manage, and store data efficiently. With the help of Data Structures, we can easily traverse the data items. Data Structures provide Efficiency, Reusability, and Abstraction.
  • 7. Why should we learn Data Structures? • Data Structures and Algorithms are two of the key aspects of Computer Science. • Data Structures allow us to organize and store data, whereas Algorithms allow us to process that data meaningfully. • Learning Data Structures and Algorithms will help us become better Programmers. • We will be able to write code that is more effective and reliable. • We will also be able to solve problems more quickly and efficiently.
  • 8. Understanding the Objectives of Data Structures Data Structures satisfy two complementary objectives: • Correctness: Data Structures are designed to operate correctly for all kinds of inputs based on the domain of interest. In order words, correctness forms the primary objective of Data Structure, which always depends upon the problems that the Data Structure is meant to solve. • Efficiency: Data Structures also requires to be efficient. It should process the data quickly without utilizing many computer resources like memory space. In a real-time state, the efficiency of a data structure is a key factor in determining the success and failure of the process.
  • 9. Understanding some Key Features of Data Structures Some of the Significant Features of Data Structures are: • Robustness: Generally, all computer programmers aim to produce software that yields correct output for every possible input, along with efficient execution on all hardware platforms. This type of robust software must manage both valid and invalid inputs. • Adaptability: Building software applications like Web Browsers, Word Processors, and Internet Search Engine include huge software systems that require correct and efficient working or execution for many years. Moreover, software evolves due to emerging technologies or ever-changing market conditions. • Reusability: The features like Reusability and Adaptability go hand in hand. It is known that the programmer needs many resources to build any software, making it a costly enterprise. However, if the software is developed in a reusable and adaptable way, then it can be applied in most future applications. Thus, by executing quality data structures, it is possible to build reusable software, which appears to be cost-effective and timesaving.
  • 10. Classification of Data Structures A Data Structure delivers a structured set of variables related to each other in various ways. It forms the basis of a programming tool that signifies the relationship between the data elements and allows programmers to process the data efficiently. We can classify Data Structures into two categories: 1.Primitive Data Structure 2.Non-Primitive Data Structure
  • 11. Primitive Data Structures • Primitive Data Structures are the data structures consisting of the numbers and the characters that come in-built into programs. • These data structures can be manipulated or operated directly by machine-level instructions. • Basic data types like Integer, Float, Character, and Boolean come under the Primitive Data Structures. • These data types are also called Simple data types, as they contain characters that can't be divided further
  • 12. Non-Primitive Data Structures • Non-Primitive Data Structures are those data structures derived from Primitive Data Structures. • These data structures can't be manipulated or operated directly by machine-level instructions. • The focus of these data structures is on forming a set of data elements that is either homogeneous (same data type) or heterogeneous (different data types). • Based on the structure and arrangement of data, we can divide these data structures into two sub-categories - Linear Data Structures Non-Linear Data Structures
  • 13. Linear Data Structures • A data structure that preserves a linear connection among its data elements is known as a Linear Data Structure. The arrangement of the data is done linearly, where each element consists of the successors and predecessors except the first and the last data element. However, it is not necessarily true in the case of memory, as the arrangement may not be sequential. • Based on memory allocation, the Linear Data Structures are further classified into two types: 1. Static Data Structures: The data structures having a fixed size are known as Static Data Structures. The memory for these data structures is allocated at the compiler time, and their size cannot be changed by the user after being compiled; however, the data stored in them can be altered. The Array is the best example of the Static Data Structure as they have a fixed size, and its data can be modified later. 2. Dynamic Data Structures: The data structures having a dynamic size are known as Dynamic Data Structures. The memory of these data structures is allocated at the run time, and their size varies during the run time of the code. Moreover, the user can change the size as well as the data elements stored in these data structures at the run time of the code. • Linked Lists, Stacks, and Queues are common examples of dynamic data structures
  • 16. Static Linear Data Structures
  • 17. Arrays An Array is a data structure used to collect multiple data elements of the same data type into one variable. Instead of storing multiple values of the same data types in separate variable names, we could store all of them together into one variable. This statement doesn't imply that we will have to unite all the values of the same data type in any program into one array of that data type. But there will often be times when some specific variables of the same data types are all related to one another in a way appropriate for an array. • An Array is a list of elements where each element has a unique place in the list. The data elements of the array share the same variable name; however, each carries a different index number called a subscript. We can access any data element from the list with the help of its location in the list. Thus, the key feature of the arrays to understand is that the data is stored in contiguous memory locations, making it possible for the users to traverse through the data elements of the array using their respective indexes.
  • 19. Arrays can be classified into different types: • One-Dimensional Array: An Array with only one row of data elements is known as a One-Dimensional Array. It is stored in ascending storage location. • Two-Dimensional Array: An Array consisting of multiple rows and columns of data elements is called a Two-Dimensional Array. It is also known as a Matrix. • Multidimensional Array: We can define Multidimensional Array as an Array of Arrays. Multidimensional Arrays are not bounded to two indices or two dimensions as they can include as many indices are per the need.
  • 20. Some Applications of Array: 1. We can store a list of data elements belonging to the same data type. 2. Array acts as an auxiliary storage for other data structures. 3. The array also helps store data elements of a binary tree of the fixed count. 4. Array also acts as a storage of matrices.
  • 21. Dynamic Linear Data Structures
  • 22. Linked Lists • A Linked List is another example of a linear data structure used to store a collection of data elements dynamically. Data elements in this data structure are represented by the Nodes, connected using links or pointers. Each node contains two fields, the information field consists of the actual data, and the pointer field consists of the address of the subsequent nodes in the list. The pointer of the last node of the linked list consists of a null pointer, as it points to nothing. Unlike the Arrays, the user can dynamically adjust the size of a Linked List as per the requirements.
  • 24. Linked Lists can be classified into different types: • Singly Linked List: A Singly Linked List is the most common type of Linked List. Each node has data and a pointer field containing an address to the next node. • Doubly Linked List: A Doubly Linked List consists of an information field and two pointer fields. The information field contains the data. The first pointer field contains an address of the previous node, whereas another pointer field contains a reference to the next node. Thus, we can go in both directions (backward as well as forward). • Circular Linked List: The Circular Linked List is similar to the Singly Linked List. The only key difference is that the last node contains the address of the first node, forming a circular loop in the Circular Linked List.
  • 25. Some Applications of Linked Lists: 1.The Linked Lists help us implement stacks, queues, binary trees, and graphs of predefined size. 2.We can also implement Operating System's function for dynamic memory management. 3.Linked Lists also allow polynomial implementation for mathematical operations. 4.We can use Circular Linked List to implement Operating Systems or application functions that Round Robin execution of tasks. 5.Circular Linked List is also helpful in a Slide Show where a user requires to go back to the first slide after the last slide is presented. 6.Doubly Linked List is utilized to implement forward and backward buttons in a browser to move forward and backward in the opened pages of a website.
  • 26. Stacks • A Stack is a Linear Data Structure that follows the LIFO (Last In, First Out) principle that allows operations like insertion and deletion from one end of the Stack, i.e., Top. Stacks can be implemented with the help of contiguous memory, an Array, and non-contiguous memory, a Linked List. Real-life examples of Stacks are piles of books, a deck of cards, piles of money, and many more. The primary operations in the Stack are as follows: Push: The operation to insert a new element in the Stack is termed as Push Operation. Pop: The operation to remove or delete elements from the Stack is termed as Pop Operation.
  • 28. Some Applications of Stacks: 1. The Stack is used as a Temporary Storage Structure for recursive operations. 2. Stack is also utilized as Auxiliary Storage Structure for function calls, nested operations, and deferred/postponed functions. 3. We can manage function calls using Stacks. 4. Stacks are also utilized to evaluate the arithmetic expressions in different programming languages. 5. Stacks are also helpful in converting infix expressions to postfix expressions. 6. Stacks allow us to check the expression's syntax in the programming environment. 7. We can match parenthesis using Stacks. 8. Stacks can be used to reverse a String. 9. Stacks are helpful in solving problems based on backtracking. 10. We can use Stacks in depth-first search in graph and tree traversal. 11. Stacks are also used in Operating System functions. 12. Stacks are also used in UNDO and REDO functions in an edit.
  • 29. Queues • A Queue is a linear data structure similar to a Stack with some limitations on the insertion and deletion of the elements. The insertion of an element in a Queue is done at one end, and the removal is done at another or opposite end. Thus, we can conclude that the Queue data structure follows FIFO (First In, First Out) principle to manipulate the data elements. Implementation of Queues can be done using Arrays, Linked Lists, or Stacks. Some real-life examples of Queues are a line at the ticket counter, an escalator, a car wash, and many more
  • 30. Primary operations of the Queue: Enqueue: The insertion or Addition of some data elements to the Queue is called Enqueue. The element insertion is always done with the help of the rear pointer. • Dequeue: Deleting or removing data elements from the Queue is termed Dequeue. The deletion of the element is always done with the help of the front pointer.
  • 32. Some Applications of Queues: • Queues are generally used in the breadth search operation in Graphs. • Queues are also used in Job Scheduler Operations of Operating Systems, like a keyboard buffer queue to store the keys pressed by users and a print buffer queue to store the documents printed by the printer. • Queues are responsible for CPU scheduling, Job scheduling, and Disk Scheduling. • Priority Queues are utilized in file-downloading operations in a browser. • Queues are also used to transfer data between peripheral devices and the CPU. • Queues are also responsible for handling interrupts generated by the User Applications for the CPU.
  翻译: