stacks overview with its applications

36
Saqib Saeed Umair Maqbool Hassan tariq

Upload: saqib-saeed

Post on 18-Nov-2014

3.273 views

Category:

Education


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Stacks overview with its applications

Saqib Saeed Umair Maqbool Hassan tariq

Page 2: Stacks overview with its applications
Page 3: Stacks overview with its applications

Quick IntroductionStacks are linear lists.

All deletions and insertions occur at one end of the stack known as the TOP.

Data going into the stack first, leaves out last.

Stacks are also known as LIFO data structures (Last-In, First-Out).

Page 4: Stacks overview with its applications

Basic Stack Operationspush – Adds an item to the top of a stack.

pop – Removes an item from the top of the stack and returns it to the user.

stack top (top, peek) – Copies the top item of the stack and returns it to the user; the item is not removed, hence the stack is not altered.

Page 5: Stacks overview with its applications

Additional NotesStacks structures are usually implemented

using arrays or linked lists.

For both implementations, the running time is O(n).

We will be examining common Stack Applications.

Page 6: Stacks overview with its applications

Stack Applications Reversing Data: We can use stacks to reverse

data.(example: files, strings)

Very useful for finding palindromes

Converting Decimal to Binary

Infix to postfix conversion

Page 7: Stacks overview with its applications

BacktrackingStacks can be used to backtrack to achieve

certain goals.

Usually, we set up backtrack tokens to indicate a backtrack opportunity.

Backtracking in N-Queen problem.

Page 8: Stacks overview with its applications
Page 9: Stacks overview with its applications
Page 10: Stacks overview with its applications
Page 11: Stacks overview with its applications
Page 12: Stacks overview with its applications
Page 13: Stacks overview with its applications
Page 14: Stacks overview with its applications
Page 15: Stacks overview with its applications
Page 16: Stacks overview with its applications
Page 17: Stacks overview with its applications
Page 18: Stacks overview with its applications
Page 19: Stacks overview with its applications
Page 20: Stacks overview with its applications
Page 21: Stacks overview with its applications
Page 22: Stacks overview with its applications
Page 23: Stacks overview with its applications
Page 24: Stacks overview with its applications
Page 25: Stacks overview with its applications
Page 26: Stacks overview with its applications
Page 27: Stacks overview with its applications
Page 28: Stacks overview with its applications
Page 29: Stacks overview with its applications
Page 30: Stacks overview with its applications
Page 31: Stacks overview with its applications
Page 32: Stacks overview with its applications
Page 33: Stacks overview with its applications
Page 34: Stacks overview with its applications
Page 35: Stacks overview with its applications
Page 36: Stacks overview with its applications