MGMT 1050 Lecture Notes - Lecture 16: Subroutine
MGMT 1050 Tutorial 16 Notes – Stack Instructions
Introduction
• Any good introductory textbook will also serve as a further reference.
• In addition, there are several good books that describe I/O devices.
• White [WHIT05] provides straight-forward explanations of many I/O devices.
• Mueller [MUEL08] contains comprehensive treatments of memory, disk storage, optical
disks, video hardware, and more.
• One of the most important data storage structures in programming is the stack.
• A stack is used to store data when the most recently used data will also be the first
needed.
• For that reason, stacks are also known as LIFO, for last-in, first-out, structures.
• As an analogy, stacks are frequently described by the way plates are stored and used in
a cafeteria.
• New plates are added to the top of the stack, or pushed, and plates already on the stack
move down to make room for them.
• Plates are removed from the top of the stack, or popped.
• So that the last plates placed on the stack are the first removed.
• Similarly, the last number entered onto a computer memory stack will be the first
number available when the stack is next accessed.
• Any data that must be retrieved in reverse order from the way it was entered is a
candidate for the use of stacks.
• The process of adding to and removing numbers from the stack.
• Stacks are an efficient way of storing intermediate data values during complex
calculations.
• In fact, storage in Hewlett-Packard calculators is organized around a stack of memory.
• As we already noted, stacks are also an excellent method for storing the return
addresses and arguments from subroutine calls.
• Progra routies that are recursive ust call theselves.
find more resources at oneclass.com
find more resources at oneclass.com