SlideShare a Scribd company logo
Introduction and Overview
of Data Structure
• This part will introduce the concept of data structure. But before the discussion of data
structure we will have a look of some elementary concepts and terminology related to data
structure.
• Data
• “A well-known fact that has some implicit meaning and that can be recorded is known as
data”.
In simplest words we can say that data means value or set of values. So raw facts and figures
about any thing may be termed as data. Some of the examples are
Robert
34
New Jersey
07-04-1980
CEO
• In the above example we are having some figures but these figures are not able to represent
the clear message. Means we don’t know what is the meaning of this data.
• Information
• Processed data is known as information.
• Means after processing of data we can get clear message inherited into the data or
meaningful data is called information
• In other words “data +associated attributes” may be termed as information
• The above example can be represented in such a way
Employee Name -- Robert
Age -- 34
City -- New Jersey
Date of Joining -- 07-04-1980
Designation -- CEO
• This example gives the information that Robert, which is a 34 year old, lives in New Jersey. He
is CEO in a company and his date of joining is 07-04-1980
• Relation between data and information
DATA
Procedure
to process
the Data
Information
Data Structure
• Data structure is the structural representation of logical relationship between elements of
data. Or in other words a data structure is a way of organizing data items by considering its
relationship to each other.
• ALGORITHMS + DATA STRUCTURE = PROGRAM
• Data structures are the building blocks of a program. Means the selection of a poor data
structure may design an inefficient program.
LIBRARY
• Classification of fundamental Data Structure-
• Some of the data structures are used frequently almost in all application areas and with the
help of which almost all-complex data structure can be constructed. These data structures
are known as fundamental or classic data structure. Classification of all fundamental data
structures is as follows:
Classification of Data Structure
Fundamental data Structure
Linear Data Structure
Non-Linear Data Structure
Arrays Stacks Queues Linked List Trees Graphs Tables Sets
Data Structure Operations
• Traversing-Accessing each record exactly once.
• Searching-Finding the location of the record with the given key value.
• Inserting-Adding a new record to the structure.
• Deleting-Removing a record from the structure
• Sorting-Arranging the records in some logical order.
• Merging-Combining the records
Arrays
• An array is a finite, ordered collection of homogeneous data elements. Array is finite because
it contains only limited number of elements, and ordered, as all the elements are stored one
by one in contiguous locations of computer memory in a linear ordered manner. All the
elements of an array are of the same data type that is why termed as collection of
homogeneous elements.
• Array may be one-dimensional or multidimensional. In multidimensional array elements are
arrange in the form of row and column. Elements of an array can be accessed through index
(say i) or subscript.
• If we want to store n elements in an array A then the elements will store from A[0] to A[n-1].
Any particular element can be represented as A [i]. The diagrammatic representation would
be as follows-
A[0] A[1] A[2] ………… A[n-1]
Stacks
• “A stack is an ordered collection of homogeneous data element where the insertion and
deletion operations take place at one end only called TOP of the stack”
• In case of arrays and linked list, insertion and deletion operations can take place at any
position. But in case of stack insertion and deletion operations are known as PUSH and POP
and restricted to one end only, known as TOP of the stack. An element in a stack is termed as
ITEM. The maximum number of elements that a stack can accommodate is termed its size.
The last inserted element in stack, will be first removed from the stack. That is why the stack
is known as LAST IN FIRST OUT (LIFO).
Insert Elements(PUSH) Delete last inserted element(POP)
Top of the Stack
Bottom of the Stack
ITEM 1
ITEM 2
ITEM 3
ITEM 4
ITEM 5
Operations on Stack
PUSH
The process of adding a new element to the top of stack is called PUSH. Pushing an element
in the stack involve adding new element In case the array is full and no new element can be
accommodated, it is called the STACK OVERFLOW.
POP
The process of deleting an element from the top of stack is called POP. After every pop
operation the stack is decremented by one. If there is no element in the stack and POP is
performed then this will result into STACK UNDERFLOW.
Implementation of Stack
Stack can be implemented in two ways
Stack implementation using arrays (static implementation)
Stack implementation using pointers (dynamic implementation)
ALGORITHM
TOP-top of stack. Initial value of TOP is 0
ITEM- element to be inserted
MAXSTK- maximum size of stack
PUSH ( STACK ,TOP ,ITEM ,MAXSTK )
This procedure pushes an item onto stack.
If TOP = MAXSTK , then : Print: OVERFLOW, and Return.
Set TOP = TOP+1
Set STACK [TOP] = ITEM
Return.
POP ( STACK ,TOP ,ITEM )
If TOP = 0 , then : Print : Underflow, and Return.
Set ITEM = STACK [TOP]
Set TOP = TOP- 1
Return.
Applications of Stacks
– Page-visited history in a Web browser
– Undo sequence in a text editor
– Backtracking
– Saving local variables when one function calls another, and
this one calls another, and so on.
– Recursion
– Infix to postfix conversion
– Quick sort
– Mobile
Queues
• A Queue is an ordered collection of items from which items may be deleted at one end
(called the front of the queue) and into which items may be inserted at the other end (the
rear of the queue).
• The first element inserted into the queue is the first element to be removed. For this reason
a queue is sometimes called a fifo (first-in first-out) list as opposed to the stack, which is a lifo
(last-in first-out).
QUEUE OPERATIONS
• Initialize the queue
• Insert to the rear of the queue
• Remove (Delete) from the front of the queue
• Is the Queue Empty
• Is the Queue Full
• What is the size of the Queue
• Implementation of Queue
Queue can be implemented in two ways
Queue implementation using arrays (static implementation)
Queue implementation using pointers (dynamic implementation)
Queue Implementation using Circular Array
QINSERT(QUEUE,N,FRONT,REAR,ITEM)
1. [Queue already filled?]
If FRONT=1 and REAR=N or if FRONT=REAR+1 then
Write OVERFLOW and exit.
2. If FRONT=NULL then[Queue is initially empty]
Set FRONT=1 and REAR=1
Else if REAR=N then set REAR=1
Else set REAR=REAR+1
3. Set QUEUE[REAR]=ITEM
4 . Exit
QDELETE(QUEUE,N,FRONT,REAR,ITEM)
1. [Queue already empty]
If FRONT=NULL then Write UNDERFLOW and exit.
2. Set ITEM=QUEUE[FRONT]
3. If FRONT=REAR then [queue has only one element to start]
Set FRONT=REAR=NULL
Else if FRONT=N then Set FRONT=1
else Set FRONT=FRONT+1
4. Exit
Types and Applications of Queue
TYPES
• Deque or Dequeue (Input Restricted/Output Restricted)
• Priority Queue
Applications
• Waiting lines
• Access to shared resources (e.g., printer)
• printer queue, keystroke queue, etc.
• Searching(DFS & BFS)
• Used extensively in operating systems
• Multiprogramming
• Queues of processes, I/O requests, and much more
Linked List
• Array is a data structure where elements are stored in consecutive memory locations. We
have to specify the size of array before its usage. Once memory is allocated it cannot be
extended any more. That is why array is known as static data structure.
• In contrast to this linked list is called dynamic data structure where amount of memory
required can be varied during its use. A linked list consists of nodes.
• A node consists of two fields; one is data (actual content) and link (which point to the next
data).
LINK
Link to the Next Node
Node: An element in a linked list
DATA
Definition
• A linked list or one way list is an ordered collection of finite data elements called nodes where
the linear order is maintained by means of links or pointers.
DATA LINK DATA LINK DATA LINK
Linked List representation
START
22 40 50 NULL
TO CREATE LINK LIST
In C, a linked list is created using structures, pointers and dynamic memory allocation
function .We consider head as an external pointer. This helps in creating and accessing other
nodes in the linked list. Consider the following structure definition and head creation:
Struct node
{
int DATA;
struct node *ptr;
};
typedef struct node NODE;
NODE *start;
Start=(NODE *)malloc(sizeof(NODE));
When the Statement
Start=(NODE *)malloc(sizeof(NODE));
Is executed , a block of memory sufficient to store the NODE is allocated and assigns head as
the starting address of the NODE. This activity can be pictorially shown as follows:-
start DATA ptr
Types of Linked List
• Header Linked List
-Grounded Header Linked List
-Circular Header Linked List
• Two way Linked List
• Two way Circular Header Linked List
Applications of linked List
• Dynamic Memory Allocation
• Polynomials representations and various operations over polynomials
• Non Contiguous Memory Allocation
• Representing Sparse Matrix
• Representation of PCB in Operating system
Inserting After a Given Node
• Suppose we are given the value of LOC where
either LOC is the location of a node A in a linked list
or LOC=NULL, so that ITEM is the first node.
Deletion from a Linked List
Deleting the node Following a Given Node
Let LIST be a linked list in memory. Suppose we are given the
location LOC of a node N in LIST. Furthermore we are given
the location LOCP of the node preceding N or. when N is the
first node, we are given LOCP=NULL.
HEADER LINKED LISTS
A header linked list is a linked list which always
contains a special node, called the header node
at the beginning of the list. The following are two
kinds of widely used header lists:
• A gronded header list is a header list where the
last node contains the null pointer. (The term
grounded comes from the fact that many texts
use the electrical ground symbol to indicate the
null pointer.)
• A circular header list is a header list where the
last node points back to the header node
Stack and queue power point presentation data structure and algorithms Stack-Queue-LL.pptx
TWO WAY LISTS (OR DOUBLY LINKED LIST)
TWO WAY CIRCULAR HEADER LISTS
Linked Implementation of Stack
Stack and queue power point presentation data structure and algorithms Stack-Queue-LL.pptx
Linked Implementation of Queue
LINKQ_INSERT(INFO,FRONT,REAR,AVAIL,ITEM)
• 1. If AVAIL = NULL then write OVERFLOW and Exit.
• 2. Set NEW=AVAIL and AVAIL=LINK[AVAIL]
• 3.Set INFO[NEW]=ITEM and LINK[NEW]=NULL
• 4.If FRONT =NULL then FRONT=REAR=NEW
• Else Set LINK[REAR]=NEW and REAR=NEW
• 5. EXIT
LINKQ_DELETE(INFO,LINK,FRONT,REAR,AVAIL,ITEM)
• 1. If FRONT=NULL the write UNDERFLOW and
Exit.
• 2.Set TEMP=FRONT
• 3.ITEM=INFO[TEMP]
• 4.FRONT=LINK[TEMP]
• 5.LINK[TEMP]=AVAIL and AVAIL=TEMP
• 6. Exit

More Related Content

Similar to Stack and queue power point presentation data structure and algorithms Stack-Queue-LL.pptx (20)

PPT
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
sumitbardhan
 
PPT
Data Structures and algorithms using c .ppt
RaviKumarChavali1
 
PPTX
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
PPT
Stacks queues-1220971554378778-9
Getachew Ganfur
 
PPT
Rana Junaid Rasheed
Rana junaid Rasheed
 
PPT
data structure algorithm example and example
lionelmessi593584
 
DOC
Data Structure
Ibrahim MH
 
PDF
Data structure
Rubal Dahat
 
PPT
Introduction of data structure in short.ppt
mba29007
 
PPTX
Introduction to data structure presentations
jayajadhav7
 
PPTX
Data_structure.pptx
priya415376
 
PPTX
General Data structures
Youssef Elsalhawy
 
PPT
DATA STRUCTURES A BRIEF OVERVIEW OF DATA
LearnItAllAcademy
 
PPSX
Stacks fundamentals
greatqadirgee4u
 
PPTX
chapter three ppt.pptx
selemonGamo
 
PPTX
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
PPT
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
PPTX
Lect-1.pptx
mrizwan38
 
PPTX
Stack and queue
CHANDAN KUMAR
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
sumitbardhan
 
Data Structures and algorithms using c .ppt
RaviKumarChavali1
 
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
Stacks queues-1220971554378778-9
Getachew Ganfur
 
Rana Junaid Rasheed
Rana junaid Rasheed
 
data structure algorithm example and example
lionelmessi593584
 
Data Structure
Ibrahim MH
 
Data structure
Rubal Dahat
 
Introduction of data structure in short.ppt
mba29007
 
Introduction to data structure presentations
jayajadhav7
 
Data_structure.pptx
priya415376
 
General Data structures
Youssef Elsalhawy
 
DATA STRUCTURES A BRIEF OVERVIEW OF DATA
LearnItAllAcademy
 
Stacks fundamentals
greatqadirgee4u
 
chapter three ppt.pptx
selemonGamo
 
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
Lect-1.pptx
mrizwan38
 
Stack and queue
CHANDAN KUMAR
 

Recently uploaded (20)

PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Ad

Stack and queue power point presentation data structure and algorithms Stack-Queue-LL.pptx

  • 1. Introduction and Overview of Data Structure • This part will introduce the concept of data structure. But before the discussion of data structure we will have a look of some elementary concepts and terminology related to data structure. • Data • “A well-known fact that has some implicit meaning and that can be recorded is known as data”. In simplest words we can say that data means value or set of values. So raw facts and figures about any thing may be termed as data. Some of the examples are Robert 34 New Jersey 07-04-1980 CEO • In the above example we are having some figures but these figures are not able to represent the clear message. Means we don’t know what is the meaning of this data.
  • 2. • Information • Processed data is known as information. • Means after processing of data we can get clear message inherited into the data or meaningful data is called information • In other words “data +associated attributes” may be termed as information • The above example can be represented in such a way Employee Name -- Robert Age -- 34 City -- New Jersey Date of Joining -- 07-04-1980 Designation -- CEO • This example gives the information that Robert, which is a 34 year old, lives in New Jersey. He is CEO in a company and his date of joining is 07-04-1980 • Relation between data and information DATA Procedure to process the Data Information
  • 3. Data Structure • Data structure is the structural representation of logical relationship between elements of data. Or in other words a data structure is a way of organizing data items by considering its relationship to each other. • ALGORITHMS + DATA STRUCTURE = PROGRAM • Data structures are the building blocks of a program. Means the selection of a poor data structure may design an inefficient program. LIBRARY • Classification of fundamental Data Structure- • Some of the data structures are used frequently almost in all application areas and with the help of which almost all-complex data structure can be constructed. These data structures are known as fundamental or classic data structure. Classification of all fundamental data structures is as follows:
  • 4. Classification of Data Structure Fundamental data Structure Linear Data Structure Non-Linear Data Structure Arrays Stacks Queues Linked List Trees Graphs Tables Sets
  • 5. Data Structure Operations • Traversing-Accessing each record exactly once. • Searching-Finding the location of the record with the given key value. • Inserting-Adding a new record to the structure. • Deleting-Removing a record from the structure • Sorting-Arranging the records in some logical order. • Merging-Combining the records
  • 6. Arrays • An array is a finite, ordered collection of homogeneous data elements. Array is finite because it contains only limited number of elements, and ordered, as all the elements are stored one by one in contiguous locations of computer memory in a linear ordered manner. All the elements of an array are of the same data type that is why termed as collection of homogeneous elements. • Array may be one-dimensional or multidimensional. In multidimensional array elements are arrange in the form of row and column. Elements of an array can be accessed through index (say i) or subscript. • If we want to store n elements in an array A then the elements will store from A[0] to A[n-1]. Any particular element can be represented as A [i]. The diagrammatic representation would be as follows- A[0] A[1] A[2] ………… A[n-1]
  • 8. • “A stack is an ordered collection of homogeneous data element where the insertion and deletion operations take place at one end only called TOP of the stack” • In case of arrays and linked list, insertion and deletion operations can take place at any position. But in case of stack insertion and deletion operations are known as PUSH and POP and restricted to one end only, known as TOP of the stack. An element in a stack is termed as ITEM. The maximum number of elements that a stack can accommodate is termed its size. The last inserted element in stack, will be first removed from the stack. That is why the stack is known as LAST IN FIRST OUT (LIFO). Insert Elements(PUSH) Delete last inserted element(POP) Top of the Stack Bottom of the Stack ITEM 1 ITEM 2 ITEM 3 ITEM 4 ITEM 5
  • 9. Operations on Stack PUSH The process of adding a new element to the top of stack is called PUSH. Pushing an element in the stack involve adding new element In case the array is full and no new element can be accommodated, it is called the STACK OVERFLOW. POP The process of deleting an element from the top of stack is called POP. After every pop operation the stack is decremented by one. If there is no element in the stack and POP is performed then this will result into STACK UNDERFLOW. Implementation of Stack Stack can be implemented in two ways Stack implementation using arrays (static implementation) Stack implementation using pointers (dynamic implementation)
  • 10. ALGORITHM TOP-top of stack. Initial value of TOP is 0 ITEM- element to be inserted MAXSTK- maximum size of stack PUSH ( STACK ,TOP ,ITEM ,MAXSTK ) This procedure pushes an item onto stack. If TOP = MAXSTK , then : Print: OVERFLOW, and Return. Set TOP = TOP+1 Set STACK [TOP] = ITEM Return. POP ( STACK ,TOP ,ITEM ) If TOP = 0 , then : Print : Underflow, and Return. Set ITEM = STACK [TOP] Set TOP = TOP- 1 Return.
  • 11. Applications of Stacks – Page-visited history in a Web browser – Undo sequence in a text editor – Backtracking – Saving local variables when one function calls another, and this one calls another, and so on. – Recursion – Infix to postfix conversion – Quick sort – Mobile
  • 12. Queues • A Queue is an ordered collection of items from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (the rear of the queue). • The first element inserted into the queue is the first element to be removed. For this reason a queue is sometimes called a fifo (first-in first-out) list as opposed to the stack, which is a lifo (last-in first-out).
  • 13. QUEUE OPERATIONS • Initialize the queue • Insert to the rear of the queue • Remove (Delete) from the front of the queue • Is the Queue Empty • Is the Queue Full • What is the size of the Queue • Implementation of Queue Queue can be implemented in two ways Queue implementation using arrays (static implementation) Queue implementation using pointers (dynamic implementation)
  • 14. Queue Implementation using Circular Array QINSERT(QUEUE,N,FRONT,REAR,ITEM) 1. [Queue already filled?] If FRONT=1 and REAR=N or if FRONT=REAR+1 then Write OVERFLOW and exit. 2. If FRONT=NULL then[Queue is initially empty] Set FRONT=1 and REAR=1 Else if REAR=N then set REAR=1 Else set REAR=REAR+1 3. Set QUEUE[REAR]=ITEM 4 . Exit QDELETE(QUEUE,N,FRONT,REAR,ITEM) 1. [Queue already empty] If FRONT=NULL then Write UNDERFLOW and exit. 2. Set ITEM=QUEUE[FRONT] 3. If FRONT=REAR then [queue has only one element to start] Set FRONT=REAR=NULL Else if FRONT=N then Set FRONT=1 else Set FRONT=FRONT+1 4. Exit
  • 15. Types and Applications of Queue TYPES • Deque or Dequeue (Input Restricted/Output Restricted) • Priority Queue Applications • Waiting lines • Access to shared resources (e.g., printer) • printer queue, keystroke queue, etc. • Searching(DFS & BFS) • Used extensively in operating systems • Multiprogramming • Queues of processes, I/O requests, and much more
  • 16. Linked List • Array is a data structure where elements are stored in consecutive memory locations. We have to specify the size of array before its usage. Once memory is allocated it cannot be extended any more. That is why array is known as static data structure. • In contrast to this linked list is called dynamic data structure where amount of memory required can be varied during its use. A linked list consists of nodes. • A node consists of two fields; one is data (actual content) and link (which point to the next data). LINK Link to the Next Node Node: An element in a linked list DATA
  • 17. Definition • A linked list or one way list is an ordered collection of finite data elements called nodes where the linear order is maintained by means of links or pointers. DATA LINK DATA LINK DATA LINK Linked List representation START 22 40 50 NULL
  • 18. TO CREATE LINK LIST In C, a linked list is created using structures, pointers and dynamic memory allocation function .We consider head as an external pointer. This helps in creating and accessing other nodes in the linked list. Consider the following structure definition and head creation: Struct node { int DATA; struct node *ptr; }; typedef struct node NODE; NODE *start; Start=(NODE *)malloc(sizeof(NODE)); When the Statement Start=(NODE *)malloc(sizeof(NODE)); Is executed , a block of memory sufficient to store the NODE is allocated and assigns head as the starting address of the NODE. This activity can be pictorially shown as follows:- start DATA ptr
  • 19. Types of Linked List • Header Linked List -Grounded Header Linked List -Circular Header Linked List • Two way Linked List • Two way Circular Header Linked List Applications of linked List • Dynamic Memory Allocation • Polynomials representations and various operations over polynomials • Non Contiguous Memory Allocation • Representing Sparse Matrix • Representation of PCB in Operating system
  • 20. Inserting After a Given Node • Suppose we are given the value of LOC where either LOC is the location of a node A in a linked list or LOC=NULL, so that ITEM is the first node.
  • 21. Deletion from a Linked List
  • 22. Deleting the node Following a Given Node Let LIST be a linked list in memory. Suppose we are given the location LOC of a node N in LIST. Furthermore we are given the location LOCP of the node preceding N or. when N is the first node, we are given LOCP=NULL.
  • 23. HEADER LINKED LISTS A header linked list is a linked list which always contains a special node, called the header node at the beginning of the list. The following are two kinds of widely used header lists: • A gronded header list is a header list where the last node contains the null pointer. (The term grounded comes from the fact that many texts use the electrical ground symbol to indicate the null pointer.) • A circular header list is a header list where the last node points back to the header node
  • 25. TWO WAY LISTS (OR DOUBLY LINKED LIST)
  • 26. TWO WAY CIRCULAR HEADER LISTS
  • 29. Linked Implementation of Queue LINKQ_INSERT(INFO,FRONT,REAR,AVAIL,ITEM) • 1. If AVAIL = NULL then write OVERFLOW and Exit. • 2. Set NEW=AVAIL and AVAIL=LINK[AVAIL] • 3.Set INFO[NEW]=ITEM and LINK[NEW]=NULL • 4.If FRONT =NULL then FRONT=REAR=NEW • Else Set LINK[REAR]=NEW and REAR=NEW • 5. EXIT
  • 30. LINKQ_DELETE(INFO,LINK,FRONT,REAR,AVAIL,ITEM) • 1. If FRONT=NULL the write UNDERFLOW and Exit. • 2.Set TEMP=FRONT • 3.ITEM=INFO[TEMP] • 4.FRONT=LINK[TEMP] • 5.LINK[TEMP]=AVAIL and AVAIL=TEMP • 6. Exit