SlideShare a Scribd company logo
1 of 2
Download to read offline
Objectives: In this lab, students will practice: 1. Stack with single link-list 2. Circular Link-list
Introduction Implement a stack using singly linked list To implement a stack using singly linked
list concept, all the singly linked list operations are performed based on Stack operations
LIFO(last in first out) and with the help of that knowledge we are going to implement a stack
using single linked list. Using singly linked lists, we implement stack by storing the information
in the form of nodes and we need to follow the stack rules and implement using singly linked list
nodes. So we need to follow a simple rule in the implementation of a stack which is last in first
out and all the operations can be performed with the help of a top variable .Let us learn how to
perform Pop, Push, Peek, Display operations in the following article. Page 2 of 5 A stack can be
easily implemented using the linked list. In stack Implementation, a stack contains a top pointer.
which is "head" of the stack where pushing and popping items happens at the head of the list.
First node have null in link field and second node link have first node address in link field and so
on and last node address in "top" pointer. The main advantage of using linked list over an arrays
is that it is possible to implement a stack that can shrink or grow as much as needed. In using
array will put a restriction to the maximum capacity of the array which can lead to stack
overflow. Here each new node will be dynamically allocate. so overflow is not possible. Stack
Operations: 1. push() : Insert a new element into stack i.e just inserting a new element at the
beginning of the linked list. Page 3 of 5 2. pop() : Return top element of the Stack i.e simply
deleting the first element from the linked list. 3. peek(): Return the top element. 4. display():
Print all elements in Stack. Circular linked list Introduction: Circular Linked List is a variation of
Linked list in which the first element points to the last element and the last element points to the
first element. Both Singly Linked List and Doubly Linked List can be made into a circular linked
list. Singly Linked List as Circular In singly linked list, the next pointer of the last node points to
the first node. Doubly Linked List as Circular In doubly linked list, the next pointer of the last
node points to the first node and the previous pointer of the first node points to the last node
making the circular in both directions. Question 1 1. Implement a template-based stack using a
singly linked list. The required member methods are: int size(): returns the count of total element
stored in the stack. bool isEmpty(): returns true if the stack is empty else false. bool top(T&):
returns, but does not delete, the topmost element from the stack via the parameter passed by
reference. It returns false via a return statement if there is no element in the stack, else it returns
true and assigns the top most element to the parameter passed by reference. void pop(): deletes
the top most element from the stack. If there is no element, return some error. push(T const & e):
pushes the element " e " on top of the stack. Question 2 Remove all triple adjacent characters
from a string using Stack Question 3 Delete middle element of a stack Given a stack with push(),
pop(), empty() operations, delete the middle of it without using any additional data structure.
Input : Stack [] = [ 1 , 2 , 3 , 4 , 5 ] Output : Stack[] = [ 1 , 2 , 4 , 5 ] Input : Stack [] = [ 1 , 2 , 3 ,
4 , 5 , 6 ] Output : Stack[ ] = [ 1 , 2 , 4 , 5 , 6 ] Question 4 Reverse a circular linked list. Given a
circular linked list of size n . The problem is to reverse the given circular linked list. Page 5 of 5
Objectives- In this lab- students will practice- 1- Stack with single.pdf

More Related Content

Similar to Objectives- In this lab- students will practice- 1- Stack with single.pdf

Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queueRai University
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stackecomputernotes
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueRai University
 
Data Structures(Part 1)
Data Structures(Part 1)Data Structures(Part 1)
Data Structures(Part 1)SURBHI SAROHA
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)Durga Devi
 
STACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUESTACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUEDev Chauhan
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked ListThenmozhiK5
 
Chapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdfChapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdfAxmedcarb
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm KristinaBorooah
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queueSrajan Shukla
 
stack 1.pdf
stack 1.pdfstack 1.pdf
stack 1.pdfhafsa40
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfadvancethchnologies
 

Similar to Objectives- In this lab- students will practice- 1- Stack with single.pdf (20)

Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
computer notes - Stack
computer notes - Stackcomputer notes - Stack
computer notes - Stack
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
Data Structures(Part 1)
Data Structures(Part 1)Data Structures(Part 1)
Data Structures(Part 1)
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
STACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUESTACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUE
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 
stack coding.pptx
stack coding.pptxstack coding.pptx
stack coding.pptx
 
DSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdfDSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdf
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Data Structures_Linked List
Data Structures_Linked ListData Structures_Linked List
Data Structures_Linked List
 
Linked list
Linked listLinked list
Linked list
 
Chapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdfChapter 3 Linkedlist Data Structure .pdf
Chapter 3 Linkedlist Data Structure .pdf
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Linked List
Linked ListLinked List
Linked List
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
stack 1.pdf
stack 1.pdfstack 1.pdf
stack 1.pdf
 
Objective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdfObjective The purpose of this exercise is to create a Linke.pdf
Objective The purpose of this exercise is to create a Linke.pdf
 

More from Augstore

Note- Always keep track of your work- Wowza Corporation manufactures p.pdf
Note- Always keep track of your work- Wowza Corporation manufactures p.pdfNote- Always keep track of your work- Wowza Corporation manufactures p.pdf
Note- Always keep track of your work- Wowza Corporation manufactures p.pdfAugstore
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfAugstore
 
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdf
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdfNote- 1- There was no retirement of stock during the yoar- A- There wa.pdf
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdfAugstore
 
Note the image showing a series of batholiths on the landscape- How di.pdf
Note the image showing a series of batholiths on the landscape- How di.pdfNote the image showing a series of batholiths on the landscape- How di.pdf
Note the image showing a series of batholiths on the landscape- How di.pdfAugstore
 
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdf
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdfnote 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdf
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdfAugstore
 
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdf
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdfNot yet answered Points out of 1-00 Flag question It seems kind of wei.pdf
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdfAugstore
 
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdf
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdfNot yet answered Points out of 1-00 Flag question Stephanie likes to p.pdf
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdfAugstore
 
Not able to run quiz question -- Define an array of objects with qu.pdf
Not able to run quiz question    -- Define an array of objects with qu.pdfNot able to run quiz question    -- Define an array of objects with qu.pdf
Not able to run quiz question -- Define an array of objects with qu.pdfAugstore
 
Not for Profit class The non-profit is planned parenthood Discuss ho.pdf
Not for Profit class The non-profit is planned parenthood   Discuss ho.pdfNot for Profit class The non-profit is planned parenthood   Discuss ho.pdf
Not for Profit class The non-profit is planned parenthood Discuss ho.pdfAugstore
 
Not long ago- the Federal Communications Commission (FCC) implemented.pdf
Not long ago- the Federal Communications Commission (FCC) implemented.pdfNot long ago- the Federal Communications Commission (FCC) implemented.pdf
Not long ago- the Federal Communications Commission (FCC) implemented.pdfAugstore
 
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdf
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdfNonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdf
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdfAugstore
 
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdf
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdfNon-foliated metamorphic rocks generally are- composed of a few visibl.pdf
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdfAugstore
 
Non-financial reporting With the growth in non-financial reporting ove.pdf
Non-financial reporting With the growth in non-financial reporting ove.pdfNon-financial reporting With the growth in non-financial reporting ove.pdf
Non-financial reporting With the growth in non-financial reporting ove.pdfAugstore
 
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdf
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdfNominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdf
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdfAugstore
 
Non-marine (live in water that is not seawater) diatoms are algae that.pdf
Non-marine (live in water that is not seawater) diatoms are algae that.pdfNon-marine (live in water that is not seawater) diatoms are algae that.pdf
Non-marine (live in water that is not seawater) diatoms are algae that.pdfAugstore
 
No outstanding checks and no deposits in transit were noted in August- (1).pdf
No outstanding checks and no deposits in transit were noted in August- (1).pdfNo outstanding checks and no deposits in transit were noted in August- (1).pdf
No outstanding checks and no deposits in transit were noted in August- (1).pdfAugstore
 
Nittany Company uses a periodic inventory system- At the end of the an.pdf
Nittany Company uses a periodic inventory system- At the end of the an.pdfNittany Company uses a periodic inventory system- At the end of the an.pdf
Nittany Company uses a periodic inventory system- At the end of the an.pdfAugstore
 
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdf
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdfNIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdf
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdfAugstore
 
News Revlew 4- Continuous Process Improvement Program Upon successful.pdf
News Revlew 4- Continuous Process Improvement Program Upon successful.pdfNews Revlew 4- Continuous Process Improvement Program Upon successful.pdf
News Revlew 4- Continuous Process Improvement Program Upon successful.pdfAugstore
 
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdf
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdfNick is a male who displays a rare mitochondrial disease- Nick's wife-.pdf
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdfAugstore
 

More from Augstore (20)

Note- Always keep track of your work- Wowza Corporation manufactures p.pdf
Note- Always keep track of your work- Wowza Corporation manufactures p.pdfNote- Always keep track of your work- Wowza Corporation manufactures p.pdf
Note- Always keep track of your work- Wowza Corporation manufactures p.pdf
 
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdfNote- Can someone help me with the public boolean isEmpty()- public bo.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
 
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdf
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdfNote- 1- There was no retirement of stock during the yoar- A- There wa.pdf
Note- 1- There was no retirement of stock during the yoar- A- There wa.pdf
 
Note the image showing a series of batholiths on the landscape- How di.pdf
Note the image showing a series of batholiths on the landscape- How di.pdfNote the image showing a series of batholiths on the landscape- How di.pdf
Note the image showing a series of batholiths on the landscape- How di.pdf
 
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdf
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdfnote 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdf
note 2^R stand for w reversed (c) L3-{ww-wR-w is odd with 010 as the m.pdf
 
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdf
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdfNot yet answered Points out of 1-00 Flag question It seems kind of wei.pdf
Not yet answered Points out of 1-00 Flag question It seems kind of wei.pdf
 
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdf
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdfNot yet answered Points out of 1-00 Flag question Stephanie likes to p.pdf
Not yet answered Points out of 1-00 Flag question Stephanie likes to p.pdf
 
Not able to run quiz question -- Define an array of objects with qu.pdf
Not able to run quiz question    -- Define an array of objects with qu.pdfNot able to run quiz question    -- Define an array of objects with qu.pdf
Not able to run quiz question -- Define an array of objects with qu.pdf
 
Not for Profit class The non-profit is planned parenthood Discuss ho.pdf
Not for Profit class The non-profit is planned parenthood   Discuss ho.pdfNot for Profit class The non-profit is planned parenthood   Discuss ho.pdf
Not for Profit class The non-profit is planned parenthood Discuss ho.pdf
 
Not long ago- the Federal Communications Commission (FCC) implemented.pdf
Not long ago- the Federal Communications Commission (FCC) implemented.pdfNot long ago- the Federal Communications Commission (FCC) implemented.pdf
Not long ago- the Federal Communications Commission (FCC) implemented.pdf
 
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdf
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdfNonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdf
Nonchalant Actron (NA) has a current dividend (D0) of $1-80- Dividends.pdf
 
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdf
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdfNon-foliated metamorphic rocks generally are- composed of a few visibl.pdf
Non-foliated metamorphic rocks generally are- composed of a few visibl.pdf
 
Non-financial reporting With the growth in non-financial reporting ove.pdf
Non-financial reporting With the growth in non-financial reporting ove.pdfNon-financial reporting With the growth in non-financial reporting ove.pdf
Non-financial reporting With the growth in non-financial reporting ove.pdf
 
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdf
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdfNominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdf
Nominal GDP of Utopia was the highest in Real GDP of Utopia in 2016 is.pdf
 
Non-marine (live in water that is not seawater) diatoms are algae that.pdf
Non-marine (live in water that is not seawater) diatoms are algae that.pdfNon-marine (live in water that is not seawater) diatoms are algae that.pdf
Non-marine (live in water that is not seawater) diatoms are algae that.pdf
 
No outstanding checks and no deposits in transit were noted in August- (1).pdf
No outstanding checks and no deposits in transit were noted in August- (1).pdfNo outstanding checks and no deposits in transit were noted in August- (1).pdf
No outstanding checks and no deposits in transit were noted in August- (1).pdf
 
Nittany Company uses a periodic inventory system- At the end of the an.pdf
Nittany Company uses a periodic inventory system- At the end of the an.pdfNittany Company uses a periodic inventory system- At the end of the an.pdf
Nittany Company uses a periodic inventory system- At the end of the an.pdf
 
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdf
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdfNIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdf
NIKE- INC- Condensed Balance Sheet May 31 (-$ in millions) Assets Curr.pdf
 
News Revlew 4- Continuous Process Improvement Program Upon successful.pdf
News Revlew 4- Continuous Process Improvement Program Upon successful.pdfNews Revlew 4- Continuous Process Improvement Program Upon successful.pdf
News Revlew 4- Continuous Process Improvement Program Upon successful.pdf
 
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdf
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdfNick is a male who displays a rare mitochondrial disease- Nick's wife-.pdf
Nick is a male who displays a rare mitochondrial disease- Nick's wife-.pdf
 

Recently uploaded

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Objectives- In this lab- students will practice- 1- Stack with single.pdf

  • 1. Objectives: In this lab, students will practice: 1. Stack with single link-list 2. Circular Link-list Introduction Implement a stack using singly linked list To implement a stack using singly linked list concept, all the singly linked list operations are performed based on Stack operations LIFO(last in first out) and with the help of that knowledge we are going to implement a stack using single linked list. Using singly linked lists, we implement stack by storing the information in the form of nodes and we need to follow the stack rules and implement using singly linked list nodes. So we need to follow a simple rule in the implementation of a stack which is last in first out and all the operations can be performed with the help of a top variable .Let us learn how to perform Pop, Push, Peek, Display operations in the following article. Page 2 of 5 A stack can be easily implemented using the linked list. In stack Implementation, a stack contains a top pointer. which is "head" of the stack where pushing and popping items happens at the head of the list. First node have null in link field and second node link have first node address in link field and so on and last node address in "top" pointer. The main advantage of using linked list over an arrays is that it is possible to implement a stack that can shrink or grow as much as needed. In using array will put a restriction to the maximum capacity of the array which can lead to stack overflow. Here each new node will be dynamically allocate. so overflow is not possible. Stack Operations: 1. push() : Insert a new element into stack i.e just inserting a new element at the beginning of the linked list. Page 3 of 5 2. pop() : Return top element of the Stack i.e simply deleting the first element from the linked list. 3. peek(): Return the top element. 4. display(): Print all elements in Stack. Circular linked list Introduction: Circular Linked List is a variation of Linked list in which the first element points to the last element and the last element points to the first element. Both Singly Linked List and Doubly Linked List can be made into a circular linked list. Singly Linked List as Circular In singly linked list, the next pointer of the last node points to the first node. Doubly Linked List as Circular In doubly linked list, the next pointer of the last node points to the first node and the previous pointer of the first node points to the last node making the circular in both directions. Question 1 1. Implement a template-based stack using a singly linked list. The required member methods are: int size(): returns the count of total element stored in the stack. bool isEmpty(): returns true if the stack is empty else false. bool top(T&): returns, but does not delete, the topmost element from the stack via the parameter passed by reference. It returns false via a return statement if there is no element in the stack, else it returns true and assigns the top most element to the parameter passed by reference. void pop(): deletes the top most element from the stack. If there is no element, return some error. push(T const & e): pushes the element " e " on top of the stack. Question 2 Remove all triple adjacent characters from a string using Stack Question 3 Delete middle element of a stack Given a stack with push(), pop(), empty() operations, delete the middle of it without using any additional data structure. Input : Stack [] = [ 1 , 2 , 3 , 4 , 5 ] Output : Stack[] = [ 1 , 2 , 4 , 5 ] Input : Stack [] = [ 1 , 2 , 3 , 4 , 5 , 6 ] Output : Stack[ ] = [ 1 , 2 , 4 , 5 , 6 ] Question 4 Reverse a circular linked list. Given a circular linked list of size n . The problem is to reverse the given circular linked list. Page 5 of 5