Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 20, Problem 5SA
Program Plan Intro

Array implementation of stack:

  • A stack is a linear data structure.
  • It follows the order last-in-first-out (LIFO) for performing operations.
  • When stack is implementing using an array, create an array with enough memory to hold the stack elements.
  • Use integer index “top” for pointing to the top most element of the stack.
  • If the element is added into the stack, it checks whether it has sufficient memory to hold the number. If the memory is available, then it will increase the value of “top” and new item is added to that position.
  • If the items are removed from the stack, it will check whether stack contains element or not. If elements are available, then the “top” is decremented for deleting element in that position.

Blurred answer
Students have asked these similar questions
How do you maintain track of the items that contain data if an array is only half filled?
How do you keep track of the items with data in an array that is only partially populated?
How do you maintain track of the items that contain data while an array is only partly filled?
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning