The document discusses stacks and queues. Stacks are linear lists where additions and removals occur at one end, called the top. Stacks follow LIFO order. Queues are linear lists where additions occur at one end, called the rear, and removals occur at the other end, called the front, following FIFO order. Common stack and queue operations and implementations using arrays are described. Examples like the Towers of Hanoi problem and rat in a maze demonstrate stack and queue applications.
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
a presentation covering all the topics on Stacks and Queues in Data Structures using C++. Includes self explanatory diagrams, algorithms and program pieces.
Stacks and Queues: Introduction to stacks
applications of stacks
implementation and comparison of stack implementations.
Introduction to queues
applications of queues and implementations
Priority Queues and applications
a presentation covering all the topics on Stacks and Queues in Data Structures using C++. Includes self explanatory diagrams, algorithms and program pieces.
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
https://github.com/ashim888/dataStructureAndAlgorithm
Stack
Concept and Definition
• Primitive Operations
• Stack as an ADT
• Implementing PUSH and POP operation
• Testing for overflow and underflow conditions
Recursion
• Concept and Definition
• Implementation of:
¬ Multiplication of Natural Numbers
¬ Factorial
¬ Fibonacci Sequences
The Tower of Hanoi
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
https://github.com/ashim888/dataStructureAndAlgorithm
Stack
Concept and Definition
• Primitive Operations
• Stack as an ADT
• Implementing PUSH and POP operation
• Testing for overflow and underflow conditions
Recursion
• Concept and Definition
• Implementation of:
¬ Multiplication of Natural Numbers
¬ Factorial
¬ Fibonacci Sequences
The Tower of Hanoi
Queue in C, Queue Real Life of ExampleHitesh Kumar
Queue in C : Working of queue on the basis of first-in-first-out (FIFO) data structure.
Queue Real Life of Example
https://www.sitesbay.com/cpp-datastructure/cpp-queue-program-example
Ticket Counter : First person get ticket first and go out first.
this presentation is made for the students who find data structure as a typical subject. the slide of this presentation is made in such a manner that student will find the subject topics such as stacks,queues,linklist,array, etc.. very easy to understand. in simple maner
this presentation is made by the student of BCA second sem: pooja,shaifali,rani,richa,trishla,pallavi,shivani
The Netherlands investment climate - Main tax featuresLoyens & Loeff
The aim of this booklet is to high-light the crucial features of doing business in the Netherlands together with a snapshot of the main tax features. It also gives sufficient background to facilitate communications with tax counsel in the Netherlands.
The Loyens & Loeff series on Investment Climate consists of four separate booklets, one for each of our home markets: the Netherlands, Belgium, Luxembourg and Switzerland.
An ordered collection of items from which items may be deleted from one end called the front and into which items may be inserted from other end called rear is known as Queue.
It is a linear data structure.
It is called the First In First Out (FIFO) list. Since in queue, the first element will be the first element out.
Stack and Queue.pptx university exam preparationRAtna29
Queues and stacks are dynamic while arrays are static. So when we require dynamic memory we use queue or stack over arrays. Stacks and queues are used over arrays when sequential access is required. To efficiently remove any data from the start (queue) or the end (stack) of a data structure
LINEAR QUEUE with Diagram and C implementation.
Operations of LINEAR QUEUE
Drawback of LINEAR QUEUE
CIRCULAR QUEUE with Diagram and C implementation
Operations of CIRCULAR QUEUE
PRIORITY QUEUE with Diagram and C implementation
Operations of PRIORITY QUEUE
CASE STUDIES
EXAMPLES
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
2. Stacks
Linear list.
One end is called top.
Other end is called bottom.
Additions to and removals from the top end only.
Trupti Agrawal 2
3. Stack Of Cups
top
bottom
E
D
C
B
A
Add a cup to the stack.
top
bottom
F
E
D
C
B
A
• Remove a cup from new stack.
• A stack is a LIFO list.
Trupti Agrawal 3
4. Towers Of Hanoi/Brahma
1 2 3 4
A B C
64 gold disks to be moved from tower A to tower C
each tower operates as a stack
cannot place big disk on top of a smaller one
Trupti Agrawal 4
15. Recursive Solution
A B C
move top n-1 disks from B to C using A
1
Trupti Agrawal 15
16. Recursive Solution
1
A B C
moves(n) = 0 when n = 0
moves(n) = 2*moves(n-1) + 1 = 2n-1 when n > 0
Trupti Agrawal 16
17. Towers Of Hanoi/Brahma
moves(64) = 1.8 * 1019 (approximately)
Performing 109 moves/second, a computer would take about
570 years to complete.
At 1 disk move/min, the monks will take about 3.4 * 1013 years.
Trupti Agrawal 17
30. Rat In A Maze
Move one down and then right.
Trupti Agrawal 30
31. Rat In A Maze
Move one up and then right.
Trupti Agrawal 31
32. Rat In A Maze
Move down to exit and eat cheese.
Path from maze entry to current position operates as a stack.
Trupti Agrawal 32
33. Stacks
Standard operations:
IsEmpty … return true iff stack is empty
IsFull … return true iff stack has no remaining capacity
Top … return top element of stack
Push … add an element to the top of the stack
Pop … delete the top element of the stack
Trupti Agrawal 33
34. Stacks
Use a 1D array to represent a stack.
Stack elements are stored in stack[0] through stack[top].
Trupti Agrawal 34
35. Stacks
a b c d e
0 1 2 3 4 5 6
stack top is at element e
IsEmpty() => check whether top >= 0
O(1) time
IsFull() => check whether top == capacity – 1
O(1) time
Top() => If not empty return stack[top]
O(1) time
Trupti Agrawal 35
36. Derive From arrayList
a b c d e
0 1 2 3 4 5 6
Push(theElement) => if full then either error or
increase capacity and then add at stack[top+1]
Suppose we increase capacity when full
O(capacity) time when full; otherwise O(1)
Pop() => if not empty, delete from stack[top]
O(1) time
Trupti Agrawal 36
37. Push
a b c d e
0 1 2 3 4
top
void push(element item)
{/* add an item to the global stack */
if (top >= MAX_STACK_SIZE - 1)
StackFull();
/* add at stack top */
stack[++top] = item;
}
Trupti Agrawal 37
38. Pop
a b c d e
0 1 2 3 4
top
element pop()
{
if (top == -1)
return StackEmpty();
return stack[top--];
}
Trupti Agrawal 38
40. StackFull()/Dynamic Array
Use a variable called capacity in place of
MAX_STACK_SIZE
Initialize this variable to (say) 1
When stack is full, double the capacity using REALLOC
This is called array doubling
Trupti Agrawal 40
42. Complexity Of Array
Doubling
Let final value of capacity be 2k
Number of pushes is at least 2k-1+ 1
Total time spent on array doubling is S1<=i=k2i
This is O(2k)
So, although the time for an individual push is
O(capacity), the time for all n pushes remains O(n)!
Trupti Agrawal 42
43. Queues
Linear list.
One end is called front.
Other end is called rear.
Additions are done at the rear only.
Removals are made from the front only.
Trupti Agrawal 43
44. Bus Stop Queue
Bus
Stop
front
rear
rear rear rear rear
Trupti Agrawal 44
45. Bus Stop Queue
Bus
Stop
front
rear
rear rear
Trupti Agrawal 45
46. Bus Stop Queue
Bus
Stop
front
rear
rear
Trupti Agrawal 46
47. Bus Stop Queue
Bus
Stop
front
rear
rear
Trupti Agrawal 47
48. Revisit Of Stack Applications
Applications in which the stack cannot be replaced
with a queue.
Parentheses matching.
Towers of Hanoi.
Switchbox routing.
Method invocation and return.
Try-catch-throw implementation.
Application in which the stack may be replaced with a
queue.
Rat in a maze.
Results in finding shortest path to exit.
Trupti Agrawal 48
49. Queue Operations
IsFullQ … return true iff queue is full
IsEmptyQ … return true iff queue is empty
AddQ … add an element at the rear of the queue
DeleteQ … delete and return the front element of the queue
Trupti Agrawal 49
50. Queue in an Array
Use a 1D array to represent a queue.
Suppose queue elements are stored with the front element in
queue[0], the next in queue[1], and so on.
Trupti Agrawal 50
51. Queue in an Array(Linear Queue)
a b c d e
0 1 2 3 4 5 6
DeleteQ() => delete queue[0]
O(queue size) time
AddQ(x) => if there is capacity, add at right end
O(1) time
Trupti Agrawal 51
52. Circular Array(Circular Queue)
Use a 1D array queue.
queue[]
• Circular view of array.
[0]
[1]
[2] [3]
[4]
[5]
Trupti Agrawal 52
53. Circular Array
• Possible configuration with 3 elements.
[0]
[1]
[2] [3]
[4]
[5]
A B
C
Trupti Agrawal 53
54. Circular Array
• Another possible configuration with 3
elements.
[0]
[1]
[2] [3]
[4]
[5]
B A
C
Trupti Agrawal 54
55. Circular Array
• Use integer variables front and rear.
– front is one position counterclockwise from first
element
– rear gives position of last element
[0]
[1]
[2] [3]
[4]
[5]
A B
C
front
rear
[0]
[1]
[2] [3]
[4]
[5]
B A
C
front
rear
Trupti Agrawal 55
56. Add An Element
[0]
[1]
[2] [3]
[4]
[5]
A B
C
front
rear
• Move rear one clockwise.
Trupti Agrawal 56
57. Add An Element
• Move rear one clockwise.
• Then put into queue[rear].
[0]
[1]
[2] [3]
[4]
[5]
A B
C
front
D
rear
Trupti Agrawal 57
58. Delete An Element
[0]
[1]
[2] [3]
[4]
[5]
A B
C
front
rear
• Move front one clockwise.
Trupti Agrawal 58
59. Delete An Element
• Then extract from queue[front].
[0]
[1]
[2] [3]
[4]
[5]
A B
C
front
rear
• Move front one clockwise.
Trupti Agrawal 59
60. Moving rear Clockwise
• rear++;
if (rear = = capacity) rear = 0;
front rear
[0]
[1]
[2] [3]
[4]
[5]
A B
C
• rear = (rear + 1) % capacity;
Trupti Agrawal 60
61. Empty That Queue
[0]
[1]
[2] [3]
[4]
[5]
B A
C
front
rear
Trupti Agrawal 61
62. Empty That Queue
[0]
[1]
[2] [3]
[4]
[5]
B
C
front
rear
Trupti Agrawal 62
63. Empty That Queue
[0]
[1]
[2] [3]
[4]
[5]
C
front
rear
Trupti Agrawal 63
64. Empty That Queue
[0]
rear
[1]
[2] [3]
[4]
[5]
front
Trupti Agrawal 64
65. Dequque
In computer science, a double-ended queue (dequeue,
often abbreviated to deque) is an abstract data type that
generalizes a queue, for which elements can be added to
or removed from either the front (head) or back (tail).
It is also often called a head-tail linked list,
Trupti Agrawal 65
66. Dequque [Cont…]
This differs from the queue abstract data type or First-In-
First-Out List (FIFO), where elements can only be added to
one end and removed from the other. This general data
class has some possible sub-types:
An input-restricted deque is one where deletion can be
made from both ends, but insertion can be made at one end
only.
An output-restricted deque is one where insertion can be
made at both ends, but deletion can be made from one end
only
Trupti Agrawal 66
67. Dequque [Cont…]
Both the basic and most common list types in
computing, queues and stacks can be considered
specializations of deques, and can be implemented using
deques.
Trupti Agrawal 67
68. Applications of stacks: Conversion form
infix to postfix and prefix
expressions
There are a number of applications of stacks such as:
To print characters/string in reverse order.
Check the parentheses in the expression.
To evaluate the arithmetic expressions such as, infix, prefix
and postfix.
Trupti Agrawal 68
69. Arithmetic expression:
An expression is defined as a number of operands or data
items combined using several operators. There are
basically three types of notations for an expression:
1) Infix notation
2) Prefix notation
3) Postfix notation
(Main advantage of postfix and prefix notation are no need
to use brackets)
Trupti Agrawal 69
70. Infix notation: It is most common notation in which,
the operator is written or placed in-between the two
operands. For eg. The expression to add two numbers
A and B is written in infix notation as:
A+ B
• A and B : Operands
• + : Operator
In this example, the operator is placed in-between the
operands A and B. The reason why this notation is
called infix.
Trupti Agrawal 70
71. Prefix Notation: It is also called Polish notation,
named after in the honor of the mathematician Jan
Lukasiewicz, refers to the notation in which the
operator is placed before the operand as: +AB
As the operator ‘+’ is placed before the operands A and
B, this notation is called prefix (pre means before).
Trupti Agrawal 71
72. Postfix Notation: In the postfix notation the
operators are written after the operands, so it is
called the postfix notation (post means after), it is
also known as suffix notation or reverse polish
notation. The above postfix if written in postfix
notation looks like follows; AB+
Trupti Agrawal 72
73. Notation Conversions: Let us take an expression A+B*C
which is given in infix notation. To evaluate this expression
for values 2, 3, 5 for A, B, C respectively we must follow
certain rule in order to have right result. For eg. A+B*C =
2+3*5 = 5*5 = 25!!!!!!!!
Is this the right result? No, this is because the multiplication
is to be done before addition, because it has higher
precedence over addition. This means that for an expression
to be calculated we must have the knowledge of precedence
of operators.
Trupti Agrawal 73
74. Operator Precedence
Operator Symbol Precedence
Exponential $ Highest
Multiplication/Division *,/ Next highest
Addition/Substraction +,- Lowest
Trupti Agrawal 74