SlideShare a Scribd company logo
Data Structures
V.PARTHIPAN
AP/CSE ,
SAVEETHA UNIVERSITY
Unit II LINEAR DATA STRUCTURE
 Abstract Data Structure
List ADT
Stack ADT
Queue ADT
Abstract data type
 Mathematical model for a certain class of data
structures that have similar behavior
 Specify memory needed to store data & type of data
that will be stored in that memory location
 Defined only by the operations that may be
performed on it & by mathematical constraints of
operation
 Often implemented as modules; declares procedure
that corresponds to ADT operations
List adt
 List is an ordered set of elements
 General form of the list is A1, A2,A3…., An
 A1 : first element of list
 AN: last element of list
 N: size of list
 If elements position is Ai, successor is Ai+1 &
predecessor Ai-1
List adt
 Various operations on the list
 Insert (x,5): insert element x after position 5
 Delete(x): element x deleted
 Find(x): returns position of x
 Next(i): returns the position of its successor element i+1
 Previous(i): returns the position of its predecessor element i-1
 printlist: contents of the list is displayed
 Makeempty: makes the list empty
List adt
 Implementation
 Array implementation
 Linked List implementation
 Cursor implementation
List adt
 Array Implementation
 Collection of specific no. of data stored in a consecutive memory
locations
 Insertion & deletion are expensive as it requires more data
elements
 Find & printlist operations takes constant time
 Max. size of list considerably wastes the memory wastes the
memory space
List adt
 Linked list Implementation
 Consists of series of nodes
 Singly Linked List
 Doubly Linked List
 Circular Linked List
List adt
 Cursor Implementation
 Useful where linked list concept has to be implemented without
pointers
 Data are stored in a global array of structures. Here array index is
considered as address
 Maintains a list of free cells called cursor space
 Slot 0 is considered as a header and next is equivalent to the pointer
which points to the next slot
List adt
 Cursor Implementation
List adt
 Cursor Implementation
List adt
 Cursor Implementation Declaration
List adt
 Cursor Implementation
List adt
 Cursor Implementation
List adt
 Cursor Implementation
List adt
 Cursor Implementation
List adt
 Cursor Implementation
STACK adt
 Linear data structure which follows Last In First Out
(LIFO)
 Both insertion and deletion occur at only one end of the
list called TOP
 Eg: Pile of coins, stack of tray in cafeteria
STACK adt
 Operations on Stack
 Push
 Pop
STACK adt
 Push
 Process of inserting new element to the top of the stack
 For every push operation the top is incremented by 1
STACK adt
 Pop
 Process of deleting an element from the top of the stack
 For every push operation the top pointer is decremented by 1
STACK adt
 Exceptional conditions
 Overflow
 Attempt to insert an element when the stack is full
 Underflow
 Attempt to delete an element when the stack is empty
STACK adt
 Implementation
 Array
 Pointers
 Array Implementation
 Each stack is associated with top pointer which is -1 for empty
stack
 To push Element X onto the stack, Top pointer is incremented and
set stack[top]=X
 To pop an element, the stack[top] value is returned and top pointer
is decremented
 Pop an empty stack or push on a full stack will exceed the array
bounds
STACK adt
Routine to Push an element into stack
STACK adt
Routine to Pop an element from stack
STACK adt
Routine to return top element of the stack
STACK adt
Linked List Implementation of the stack
• Push operation is performed by inserting an element at the front
of the list
• Pop operation is done by deleting an element at the front of the
list
• Top operation returns the element at the front of the list
STACK adt
Declaration for Linked List Implementation of the stack
STACK adt
Routine to check whether stack is empty
STACK adt
Routine to create an empty stack
STACK adt
Routine to push element onto a stack
STACK adt
Routine to return top element in a stack
STACK adt
Routine to pop element from a stack
STACK adt
Applications of stack
 Evaluating arithmetic expressions
 Balancing the symbols
 Towers of Hannoi
 Function calls
 8 Queen Problem
STACK adt
Types of notations to represent arithmetic Expression
 Infix notation
 Prefix notation
 Postfix notation
Infix notation
 Arithmetic operator appears between the two
operands
 Eg. A+B/C
Postfix notation
 Arithmetic operator appears directly after two
operands
 Also called reverse polish notation
STACK adt
Prefix notation
 Arithmetic operator is placed before the two
operands
 Also called polish notation
 ((A/B)+C)  +/ABC
STACK adt
Towers of Hanoi
 One of the example illustrating the Recursion
technique
 Moving collection of N disks of decreasing size
from one pillar to another pillar
 Movement restricted by following rules
 Only one disk could be moved at a time
 No larger disk could ever reside on a pillar on top of a
smaller disk
 A 3rd pillar can be used as an intermediate to store one
or more disks, while they were being moved from
STACK adt
STACK adt
Towers of Hanoi – Recursive solution
 N – represents the no. of disks
 Steps
 If N=1, move disk from A to C
 If N=2, move the 1st disk from A to B, then move the 2nd disk
from A to C, then move the 1st disk from B to C
 If N=3, repeat the step (2) to move the first 2 disks from A
to B using C as intermediate
then 3rd disk is moved from A to C. then repeat the step (2)
to move 2 disks from B to C using A as intermediate
In general, to move N disks. Apply the recursive technique to
move N-1 disks from A to B using C as an intermediate. Then
move the Nth disk from A to C. Then again apply the
recursive technique to move N-1 disks from B to C using A as
STACK adt
Towers of Hanoi – Recursive solution
STACK adt
STACK adt
Function Calls
 to keep track of the point to which each active
subroutine should return control when it finishes
executing
 active subroutine is one that has been called but is yet
to complete execution after which control should be
handed back to the point of call
Ad

More Related Content

What's hot (13)

Simple Linear Regression with R
Simple Linear Regression with RSimple Linear Regression with R
Simple Linear Regression with R
Jerome Gomes
 
Spark Overview - Oleg Mürk
Spark Overview - Oleg MürkSpark Overview - Oleg Mürk
Spark Overview - Oleg Mürk
Planet OS
 
Topoloical sort
Topoloical sortTopoloical sort
Topoloical sort
sahilnarvekar
 
Topological sort
Topological sortTopological sort
Topological sort
Burhan Ahmed
 
Row Reducing
Row ReducingRow Reducing
Row Reducing
nicholsm
 
Better Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS GridsBetter Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS Grids
Samantha Provenza
 
Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementation
Sri Prasanna
 
WF ED 540, Plan for Class Meeting14, 3 December 2015
WF ED 540, Plan for Class Meeting14, 3 December 2015WF ED 540, Plan for Class Meeting14, 3 December 2015
WF ED 540, Plan for Class Meeting14, 3 December 2015
Penn State University
 
What is Pie chart
What is Pie chartWhat is Pie chart
What is Pie chart
Asad Afridi
 
Optimize distribution center
Optimize distribution centerOptimize distribution center
Optimize distribution center
겨울 정
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
Applications of Artificial Potential Function Methods to Autonomous Space Flight
Applications of Artificial Potential Function Methods to Autonomous Space FlightApplications of Artificial Potential Function Methods to Autonomous Space Flight
Applications of Artificial Potential Function Methods to Autonomous Space Flight
Belinda Marchand
 
Time series forecasting
Time series forecastingTime series forecasting
Time series forecasting
Roman Merkulov
 
Simple Linear Regression with R
Simple Linear Regression with RSimple Linear Regression with R
Simple Linear Regression with R
Jerome Gomes
 
Spark Overview - Oleg Mürk
Spark Overview - Oleg MürkSpark Overview - Oleg Mürk
Spark Overview - Oleg Mürk
Planet OS
 
Row Reducing
Row ReducingRow Reducing
Row Reducing
nicholsm
 
Better Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS GridsBetter Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS Grids
Samantha Provenza
 
Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementation
Sri Prasanna
 
WF ED 540, Plan for Class Meeting14, 3 December 2015
WF ED 540, Plan for Class Meeting14, 3 December 2015WF ED 540, Plan for Class Meeting14, 3 December 2015
WF ED 540, Plan for Class Meeting14, 3 December 2015
Penn State University
 
What is Pie chart
What is Pie chartWhat is Pie chart
What is Pie chart
Asad Afridi
 
Optimize distribution center
Optimize distribution centerOptimize distribution center
Optimize distribution center
겨울 정
 
R and Visualization: A match made in Heaven
R and Visualization: A match made in HeavenR and Visualization: A match made in Heaven
R and Visualization: A match made in Heaven
Edureka!
 
Applications of Artificial Potential Function Methods to Autonomous Space Flight
Applications of Artificial Potential Function Methods to Autonomous Space FlightApplications of Artificial Potential Function Methods to Autonomous Space Flight
Applications of Artificial Potential Function Methods to Autonomous Space Flight
Belinda Marchand
 
Time series forecasting
Time series forecastingTime series forecasting
Time series forecasting
Roman Merkulov
 

Viewers also liked (20)

Double linked list
Double linked listDouble linked list
Double linked list
Sayantan Sur
 
Data Structure Lecture 6
Data Structure Lecture 6Data Structure Lecture 6
Data Structure Lecture 6
Teksify
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 
Data structure circular list
Data structure circular listData structure circular list
Data structure circular list
iCreateWorld
 
10 generics a-4_in_1
10 generics a-4_in_110 generics a-4_in_1
10 generics a-4_in_1
arasforever
 
It6601 mobile computing unit 4 questions
It6601 mobile computing unit 4 questionsIt6601 mobile computing unit 4 questions
It6601 mobile computing unit 4 questions
RMK ENGINEERING COLLEGE, CHENNAI
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
Aakash deep Singhal
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
Muhazzab Chouhadry
 
IT6601 Mobile Computing
IT6601 Mobile  Computing IT6601 Mobile  Computing
IT6601 Mobile Computing
Ams Prabhu
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Data Structure (Circular Linked List)
Data Structure (Circular Linked List)Data Structure (Circular Linked List)
Data Structure (Circular Linked List)
Adam Mukharil Bachtiar
 
IT6601 MOBILE COMPUTING UNIT1
IT6601 MOBILE COMPUTING UNIT1IT6601 MOBILE COMPUTING UNIT1
IT6601 MOBILE COMPUTING UNIT1
RMK ENGINEERING COLLEGE, CHENNAI
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
Kathirvel Ayyaswamy
 
It6601 mobile computing unit 5
It6601 mobile computing unit 5It6601 mobile computing unit 5
It6601 mobile computing unit 5
RMK ENGINEERING COLLEGE, CHENNAI
 
It6601 mobile computing unit 3
It6601 mobile computing unit 3It6601 mobile computing unit 3
It6601 mobile computing unit 3
RMK ENGINEERING COLLEGE, CHENNAI
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
Kathirvel Ayyaswamy
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
Kathirvel Ayyaswamy
 
It6601 mobile computing unit 4
It6601 mobile computing unit 4It6601 mobile computing unit 4
It6601 mobile computing unit 4
RMK ENGINEERING COLLEGE, CHENNAI
 
It6601 mobile computing unit2
It6601 mobile computing unit2It6601 mobile computing unit2
It6601 mobile computing unit2
RMK ENGINEERING COLLEGE, CHENNAI
 
Linked list
Linked listLinked list
Linked list
Trupti Agrawal
 
Ad

Similar to Data structures1 (20)

Linear Datsructure_stacks_Data Structure_PPT.ppt
Linear Datsructure_stacks_Data Structure_PPT.pptLinear Datsructure_stacks_Data Structure_PPT.ppt
Linear Datsructure_stacks_Data Structure_PPT.ppt
rajinooka
 
stack data structure and its applications , advantages, disadvantages etc
stack data structure and its applications , advantages, disadvantages etcstack data structure and its applications , advantages, disadvantages etc
stack data structure and its applications , advantages, disadvantages etc
rajinooka
 
stack data structure , applications, advantages
stack data structure , applications, advantagesstack data structure , applications, advantages
stack data structure , applications, advantages
rajinooka
 
Stack & Queue in Data Structure and Algorithms
Stack & Queue in Data Structure and AlgorithmsStack & Queue in Data Structure and Algorithms
Stack & Queue in Data Structure and Algorithms
Virgo Lay
 
CDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docxCDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docx
msurfudeen6681
 
Stacks and queues using aaray line .pptx
Stacks and queues using aaray line .pptxStacks and queues using aaray line .pptx
Stacks and queues using aaray line .pptx
ramkumar649780
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
SeethaDinesh
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
SeethaDinesh
 
Stack data structure
Stack data structureStack data structure
Stack data structure
rogineojerio020496
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
surya pandian
 
Ds
DsDs
Ds
Acad
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
pinakspatel
 
Data Structure
Data StructureData Structure
Data Structure
HarshGupta663
 
data structures with algorithms vtu 2023 notes.pptx
data structures with algorithms  vtu 2023 notes.pptxdata structures with algorithms  vtu 2023 notes.pptx
data structures with algorithms vtu 2023 notes.pptx
hemanthkumar40680
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
DurgaDeviCbit
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
Apurbo Datta
 
Abscddnddmdkwkkstack implementation.pptx
Abscddnddmdkwkkstack implementation.pptxAbscddnddmdkwkkstack implementation.pptx
Abscddnddmdkwkkstack implementation.pptx
zainshahid3040
 
Linear Datsructure_stacks_Data Structure_PPT.ppt
Linear Datsructure_stacks_Data Structure_PPT.pptLinear Datsructure_stacks_Data Structure_PPT.ppt
Linear Datsructure_stacks_Data Structure_PPT.ppt
rajinooka
 
stack data structure and its applications , advantages, disadvantages etc
stack data structure and its applications , advantages, disadvantages etcstack data structure and its applications , advantages, disadvantages etc
stack data structure and its applications , advantages, disadvantages etc
rajinooka
 
stack data structure , applications, advantages
stack data structure , applications, advantagesstack data structure , applications, advantages
stack data structure , applications, advantages
rajinooka
 
Stack & Queue in Data Structure and Algorithms
Stack & Queue in Data Structure and AlgorithmsStack & Queue in Data Structure and Algorithms
Stack & Queue in Data Structure and Algorithms
Virgo Lay
 
CDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docxCDS artificial intelligence and Machine.docx
CDS artificial intelligence and Machine.docx
msurfudeen6681
 
Stacks and queues using aaray line .pptx
Stacks and queues using aaray line .pptxStacks and queues using aaray line .pptx
Stacks and queues using aaray line .pptx
ramkumar649780
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
surya pandian
 
Ds
DsDs
Ds
Acad
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
pinakspatel
 
data structures with algorithms vtu 2023 notes.pptx
data structures with algorithms  vtu 2023 notes.pptxdata structures with algorithms  vtu 2023 notes.pptx
data structures with algorithms vtu 2023 notes.pptx
hemanthkumar40680
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
Abscddnddmdkwkkstack implementation.pptx
Abscddnddmdkwkkstack implementation.pptxAbscddnddmdkwkkstack implementation.pptx
Abscddnddmdkwkkstack implementation.pptx
zainshahid3040
 
Ad

More from Parthipan Parthi (20)

Inheritance
Inheritance Inheritance
Inheritance
Parthipan Parthi
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
Parthipan Parthi
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
Parthipan Parthi
 
802.11 mac
802.11 mac802.11 mac
802.11 mac
Parthipan Parthi
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
Parthipan Parthi
 
Computer network
Computer networkComputer network
Computer network
Parthipan Parthi
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
Parthipan Parthi
 
Session 6
Session 6Session 6
Session 6
Parthipan Parthi
 
Queuing analysis
Queuing analysisQueuing analysis
Queuing analysis
Parthipan Parthi
 
WAP
WAPWAP
WAP
Parthipan Parthi
 
Alternative metrics
Alternative metricsAlternative metrics
Alternative metrics
Parthipan Parthi
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
Parthipan Parthi
 
Data structures 4
Data structures 4Data structures 4
Data structures 4
Parthipan Parthi
 
Data structures2
Data structures2Data structures2
Data structures2
Parthipan Parthi
 
Data structures 3
Data structures 3Data structures 3
Data structures 3
Parthipan Parthi
 
Input output streams
Input output streamsInput output streams
Input output streams
Parthipan Parthi
 
Io stream
Io streamIo stream
Io stream
Parthipan Parthi
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
Parthipan Parthi
 
REVERSIBLE DATA HIDING WITH GOOD PAYLOAD DISTORTIONPpt 3
REVERSIBLE DATA HIDING WITH GOOD PAYLOAD DISTORTIONPpt 3 REVERSIBLE DATA HIDING WITH GOOD PAYLOAD DISTORTIONPpt 3
REVERSIBLE DATA HIDING WITH GOOD PAYLOAD DISTORTIONPpt 3
Parthipan Parthi
 

Recently uploaded (20)

Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 

Data structures1

  • 2. Unit II LINEAR DATA STRUCTURE  Abstract Data Structure List ADT Stack ADT Queue ADT
  • 3. Abstract data type  Mathematical model for a certain class of data structures that have similar behavior  Specify memory needed to store data & type of data that will be stored in that memory location  Defined only by the operations that may be performed on it & by mathematical constraints of operation  Often implemented as modules; declares procedure that corresponds to ADT operations
  • 4. List adt  List is an ordered set of elements  General form of the list is A1, A2,A3…., An  A1 : first element of list  AN: last element of list  N: size of list  If elements position is Ai, successor is Ai+1 & predecessor Ai-1
  • 5. List adt  Various operations on the list  Insert (x,5): insert element x after position 5  Delete(x): element x deleted  Find(x): returns position of x  Next(i): returns the position of its successor element i+1  Previous(i): returns the position of its predecessor element i-1  printlist: contents of the list is displayed  Makeempty: makes the list empty
  • 6. List adt  Implementation  Array implementation  Linked List implementation  Cursor implementation
  • 7. List adt  Array Implementation  Collection of specific no. of data stored in a consecutive memory locations  Insertion & deletion are expensive as it requires more data elements  Find & printlist operations takes constant time  Max. size of list considerably wastes the memory wastes the memory space
  • 8. List adt  Linked list Implementation  Consists of series of nodes  Singly Linked List  Doubly Linked List  Circular Linked List
  • 9. List adt  Cursor Implementation  Useful where linked list concept has to be implemented without pointers  Data are stored in a global array of structures. Here array index is considered as address  Maintains a list of free cells called cursor space  Slot 0 is considered as a header and next is equivalent to the pointer which points to the next slot
  • 10. List adt  Cursor Implementation
  • 11. List adt  Cursor Implementation
  • 12. List adt  Cursor Implementation Declaration
  • 13. List adt  Cursor Implementation
  • 14. List adt  Cursor Implementation
  • 15. List adt  Cursor Implementation
  • 16. List adt  Cursor Implementation
  • 17. List adt  Cursor Implementation
  • 18. STACK adt  Linear data structure which follows Last In First Out (LIFO)  Both insertion and deletion occur at only one end of the list called TOP  Eg: Pile of coins, stack of tray in cafeteria
  • 19. STACK adt  Operations on Stack  Push  Pop
  • 20. STACK adt  Push  Process of inserting new element to the top of the stack  For every push operation the top is incremented by 1
  • 21. STACK adt  Pop  Process of deleting an element from the top of the stack  For every push operation the top pointer is decremented by 1
  • 22. STACK adt  Exceptional conditions  Overflow  Attempt to insert an element when the stack is full  Underflow  Attempt to delete an element when the stack is empty
  • 23. STACK adt  Implementation  Array  Pointers  Array Implementation  Each stack is associated with top pointer which is -1 for empty stack  To push Element X onto the stack, Top pointer is incremented and set stack[top]=X  To pop an element, the stack[top] value is returned and top pointer is decremented  Pop an empty stack or push on a full stack will exceed the array bounds
  • 24. STACK adt Routine to Push an element into stack
  • 25. STACK adt Routine to Pop an element from stack
  • 26. STACK adt Routine to return top element of the stack
  • 27. STACK adt Linked List Implementation of the stack • Push operation is performed by inserting an element at the front of the list • Pop operation is done by deleting an element at the front of the list • Top operation returns the element at the front of the list
  • 28. STACK adt Declaration for Linked List Implementation of the stack
  • 29. STACK adt Routine to check whether stack is empty
  • 30. STACK adt Routine to create an empty stack
  • 31. STACK adt Routine to push element onto a stack
  • 32. STACK adt Routine to return top element in a stack
  • 33. STACK adt Routine to pop element from a stack
  • 34. STACK adt Applications of stack  Evaluating arithmetic expressions  Balancing the symbols  Towers of Hannoi  Function calls  8 Queen Problem
  • 35. STACK adt Types of notations to represent arithmetic Expression  Infix notation  Prefix notation  Postfix notation Infix notation  Arithmetic operator appears between the two operands  Eg. A+B/C Postfix notation  Arithmetic operator appears directly after two operands  Also called reverse polish notation
  • 36. STACK adt Prefix notation  Arithmetic operator is placed before the two operands  Also called polish notation  ((A/B)+C)  +/ABC
  • 37. STACK adt Towers of Hanoi  One of the example illustrating the Recursion technique  Moving collection of N disks of decreasing size from one pillar to another pillar  Movement restricted by following rules  Only one disk could be moved at a time  No larger disk could ever reside on a pillar on top of a smaller disk  A 3rd pillar can be used as an intermediate to store one or more disks, while they were being moved from
  • 39. STACK adt Towers of Hanoi – Recursive solution  N – represents the no. of disks  Steps  If N=1, move disk from A to C  If N=2, move the 1st disk from A to B, then move the 2nd disk from A to C, then move the 1st disk from B to C  If N=3, repeat the step (2) to move the first 2 disks from A to B using C as intermediate then 3rd disk is moved from A to C. then repeat the step (2) to move 2 disks from B to C using A as intermediate In general, to move N disks. Apply the recursive technique to move N-1 disks from A to B using C as an intermediate. Then move the Nth disk from A to C. Then again apply the recursive technique to move N-1 disks from B to C using A as
  • 40. STACK adt Towers of Hanoi – Recursive solution
  • 42. STACK adt Function Calls  to keep track of the point to which each active subroutine should return control when it finishes executing  active subroutine is one that has been called but is yet to complete execution after which control should be handed back to the point of call