Presentation is loading. Please wait.

Presentation is loading. Please wait.

Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,

Similar presentations


Presentation on theme: "Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,"— Presentation transcript:

1 Stacks

2 What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific, it’s a collection of objects that are inserted and removed according to the last in first out principle

3 It kind of like a pez dispenser When you add something to a stack it gets “pushed” onto the stack. And when something is removed it gets “popped” from the stack

4 Functions of a Stack Push- Inserts element e the top of the stack Pop- Removes the top element from the stack and returns it as a value Size- Returns the number of elements in a particular stack isEmpty- Tells whether the stack is empty or not Top- Returns the value top element of the stack

5 REAL LIFE EXAMPLES??? Web browsers use a stack to store the addresses of recently visited pages. New addresses get “pushed”. While pushing back button “pops” the previous page.


Download ppt "Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,"

Similar presentations


Ads by Google