adts stacks n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
ADTs - Stacks PowerPoint Presentation
Download Presentation
ADTs - Stacks

Loading in 2 Seconds...

play fullscreen
1 / 12

ADTs - Stacks - PowerPoint PPT Presentation


  • 126 Views
  • Uploaded on

ADTs - Stacks. By Adam Thomas, Miekah Broomes , Sankara Daly. Objectives. Define a stack. List and explain the operations of a stack. Discuss practical needs of implementing a stack. What is a stack?.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'ADTs - Stacks' - teague


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
adts stacks

ADTs - Stacks

By Adam Thomas, MiekahBroomes, Sankara Daly

objectives
Objectives
  • Define a stack.
  • List and explain the operations of a stack.
  • Discuss practical needs of implementing a stack.
what is a stack
What is a stack?
  • A stack is a list of data items that can only be accessed at one end, known as the top of the stack.
  • It is an ADT (Abstract Data Type), which is a data package which contains both the data structure and the operations that can be performed on this data structure.
stack operations
Stack Operations
  • Just like any other data structure, there are operations which can be carried out with Stacks.
  • The four basic stack operations are:
    • Stack: Creates an empty stack.
    • Push: Inserts an element at the top of the stack.
    • Pop: Deletes the top element.
    • Empty: Checks the status of the stack.
stack operation
‘Stack’ Operation
  • Before we can do anything with a stack, we must create a stack in the first place.
  • The stack operation creates an empty stack in memory. It is denoted in the following format.

Empty stack

stackName

push and pop operation
‘Push’ and ‘Pop’ Operation
  • The push operation is used to add data into a stack.
  • The pop operation is used to remove data from a stack.
  • N.B. Data is always added to/subtracted from the top of the stack.
animation of push and pop operations
Animation of Push and Pop Operations

Click to begin animation

End of animation.

Push

Pop

Stack

application stacks
Application Stacks
  • There a four basic application stacks: reversing data, pairing data, postponing data usage and backtracking steps.
reversing data
Reversing Data
  • Reversing data items requires that a given set of data items be reordered so that the first and last items are exchanged, with all of the positions between the first and last also being relatively exchanged
pairing data
Pairing Data
  • Paring data is any logic that breaks data into independent pieces for further processing.
  • E.g to translate a source program to machine language
postponing data usage
Postponing Data Usage
  • This is deferring data usage till some later point within the program. E.g manual transformation
backtracking steps
Backtracking Steps
  •  This is a process when you need to access the most recent data element in a series of elements. Think of a labyrinth or maze - how do you find a way from an entrance to an exit? Once you reach a dead end, you must backtrack. But backtrack to where? to the previous choice point. Therefore, at each choice point you store on a stack all possible choices. Then backtracking simply means popping a next choice from the stack.