SlideShare a Scribd company logo
1 of 42
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

More Related Content

What's hot

Simple Linear Regression with R
Simple Linear Regression with RSimple Linear Regression with R
Simple Linear Regression with RJerome Gomes
 
Spark Overview - Oleg Mürk
Spark Overview - Oleg MürkSpark Overview - Oleg Mürk
Spark Overview - Oleg MürkPlanet OS
 
Row Reducing
Row ReducingRow Reducing
Row Reducingnicholsm
 
Better Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS GridsBetter Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS GridsSamantha Provenza
 
Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementationSri 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 2015Penn State University
 
What is Pie chart
What is Pie chartWhat is Pie chart
What is Pie chartAsad 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 HeavenEdureka!
 
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 FlightBelinda Marchand
 
Time series forecasting
Time series forecastingTime series forecasting
Time series forecastingRoman Merkulov
 

What's hot (13)

Simple Linear Regression with R
Simple Linear Regression with RSimple Linear Regression with R
Simple Linear Regression with R
 
Spark Overview - Oleg Mürk
Spark Overview - Oleg MürkSpark Overview - Oleg Mürk
Spark Overview - Oleg Mürk
 
Topoloical sort
Topoloical sortTopoloical sort
Topoloical sort
 
Topological sort
Topological sortTopological sort
Topological sort
 
Row Reducing
Row ReducingRow Reducing
Row Reducing
 
Better Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS GridsBetter Layouts with Flexbox + CSS Grids
Better Layouts with Flexbox + CSS Grids
 
Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementation
 
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
 
What is Pie chart
What is Pie chartWhat is Pie chart
What is Pie chart
 
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
 
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
 
Time series forecasting
Time series forecastingTime series forecasting
Time series forecasting
 

Viewers also liked

Viewers also liked (20)

Double linked list
Double linked listDouble linked list
Double linked list
 
Data Structure Lecture 6
Data Structure Lecture 6Data Structure Lecture 6
Data Structure Lecture 6
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Data structure circular list
Data structure circular listData structure circular list
Data structure circular list
 
10 generics a-4_in_1
10 generics a-4_in_110 generics a-4_in_1
10 generics a-4_in_1
 
It6601 mobile computing unit 4 questions
It6601 mobile computing unit 4 questionsIt6601 mobile computing unit 4 questions
It6601 mobile computing unit 4 questions
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
IT6601 Mobile Computing
IT6601 Mobile  Computing IT6601 Mobile  Computing
IT6601 Mobile Computing
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Data Structure (Circular Linked List)
Data Structure (Circular Linked List)Data Structure (Circular Linked List)
Data Structure (Circular Linked List)
 
IT6601 MOBILE COMPUTING UNIT1
IT6601 MOBILE COMPUTING UNIT1IT6601 MOBILE COMPUTING UNIT1
IT6601 MOBILE COMPUTING UNIT1
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
 
It6601 mobile computing unit 5
It6601 mobile computing unit 5It6601 mobile computing unit 5
It6601 mobile computing unit 5
 
It6601 mobile computing unit 3
It6601 mobile computing unit 3It6601 mobile computing unit 3
It6601 mobile computing unit 3
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
 
IT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTINGIT6601 MOBILE COMPUTING
IT6601 MOBILE COMPUTING
 
It6601 mobile computing unit 4
It6601 mobile computing unit 4It6601 mobile computing unit 4
It6601 mobile computing unit 4
 
It6601 mobile computing unit2
It6601 mobile computing unit2It6601 mobile computing unit2
It6601 mobile computing unit2
 
Linked list
Linked listLinked list
Linked list
 

Similar to Data structures1

Similar to Data structures1 (20)

DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Data Structure -List Stack Queue
Data Structure -List Stack QueueData Structure -List Stack Queue
Data Structure -List Stack Queue
 
Ds
DsDs
Ds
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
 
Data Structure
Data StructureData Structure
Data Structure
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
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
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Stack ADT
Stack ADTStack ADT
Stack ADT
 
Lists
ListsLists
Lists
 
Lecture 2c stacks
Lecture 2c stacksLecture 2c stacks
Lecture 2c stacks
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
04 stacks
04 stacks04 stacks
04 stacks
 
Stacks queues-1220971554378778-9
Stacks queues-1220971554378778-9Stacks queues-1220971554378778-9
Stacks queues-1220971554378778-9
 

More from Parthipan Parthi (20)

Inheritance
Inheritance Inheritance
Inheritance
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
 
802.11 mac
802.11 mac802.11 mac
802.11 mac
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
 
Computer network
Computer networkComputer network
Computer network
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
 
Session 6
Session 6Session 6
Session 6
 
Queuing analysis
Queuing analysisQueuing analysis
Queuing analysis
 
WAP
WAPWAP
WAP
 
Alternative metrics
Alternative metricsAlternative metrics
Alternative metrics
 
Ethernet
EthernetEthernet
Ethernet
 
Ieee 802.11 wireless lan
Ieee 802.11 wireless lanIeee 802.11 wireless lan
Ieee 802.11 wireless lan
 
Data structures 4
Data structures 4Data structures 4
Data structures 4
 
Data structures2
Data structures2Data structures2
Data structures2
 
Data structures 3
Data structures 3Data structures 3
Data structures 3
 
Input output streams
Input output streamsInput output streams
Input output streams
 
Io stream
Io streamIo stream
Io stream
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
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
 

Recently uploaded

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

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