Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Comparison notes between stack and queue

Rating
-
Sold
-
Pages
4
Uploaded on
29-10-2022
Written in
2020/2021

It gives clear comparison on stack and queue data structures.

Institution
Course

Content preview

Stack vs. Queue

First, we will look at what is stack and what is queue individually, and then we will
discuss the differences between stack and queue.

What is a Stack?

A Stack is a linear data structure. In case of an array, random access is possible, i.e., any
element of an array can be accessed at any time, whereas in a stack, the sequential
access is only possible. It is a container that follows the insertion and deletion rule. It
follows the principle LIFO (Last In First Out) in which the insertion and deletion take
place from one side known as a top. In stack, we can insert the elements of a similar
data type, i.e., the different data type elements cannot be inserted in the same stack.
The two operations are performed in LIFO, i.e., push and pop operation.




The following are the operations that can be performed on the stack:

o push(x): It is an operation in which the elements are inserted at the top of the
stack. In the push function, we need to pass an element which we want to insert
in a stack.
o pop(): It is an operation in which the elements are deleted from the top of the
stack. In the pop() function, we do not have to pass any argument.
o peek()/top(): This function returns the value of the topmost element available
in the stack. Like pop(), it returns the value of the topmost element but does
not remove that element from the stack.

Written for

Institution
Course

Document information

Uploaded on
October 29, 2022
Number of pages
4
Written in
2020/2021
Type
Class notes
Professor(s)
Sreekanth
Contains
All classes

Subjects

$6.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
KanchanaMM

Also available in package deal

Get to know the seller

Seller avatar
KanchanaMM TKMCE
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions