Upcoming SlideShare
×

# Stacks overview with its applications

3,142 views
2,922 views

Published on

Published in: Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
3,142
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
55
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Stacks overview with its applications

1. 1. Saqib Saeed Umair Maqbool Hassan tariq
2. 3. Quick Introduction <ul><li>Stacks are linear lists. </li></ul><ul><li>All deletions and insertions occur at one end of the stack known as the TOP. </li></ul><ul><li>Data going into the stack first, leaves out last. </li></ul><ul><li>Stacks are also known as LIFO data structures ( L ast- I n, F irst- O ut). </li></ul>
3. 4. Basic Stack Operations <ul><li>push – Adds an item to the top of a stack. </li></ul><ul><li>pop – Removes an item from the top of the stack and returns it to the user. </li></ul><ul><li>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. </li></ul>
4. 5. Additional Notes <ul><li>Stacks structures are usually implemented using arrays or linked lists. </li></ul><ul><li>For both implementations, the running time is O(n). </li></ul><ul><li>We will be examining common Stack Applications. </li></ul>
5. 6. Stack Applications <ul><li>Reversing Data: We can use stacks to reverse data. </li></ul><ul><li>(example: files, strings) </li></ul><ul><li>Very useful for finding palindromes </li></ul><ul><li>Converting Decimal to Binary </li></ul><ul><li>Infix to postfix conversion </li></ul>
6. 7. Backtracking <ul><li>Stacks can be used to backtrack to achieve certain goals. </li></ul><ul><li>Usually, we set up backtrack tokens to indicate a backtrack opportunity. </li></ul><ul><li>Backtracking in N-Queen problem. </li></ul>