Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN Java Implement a stack using an array, not an array list. Make your stack size 5 when you test it, but do not hardcode

IN Java

Implement a stack using an array, not an array list.

Make your stack size 5 when you test it, but do not hardcode this!

Implement the following methods in your stack class.

  • stack() creates an empty stacks, stack s is new and empty.
  • push(item) adds a new item to the stack s, stacks is modified.
  • pop() removes and returns an item, stack s is modified.
  • isEmpty() returns a boolean and tests for an empty stacks, stack s is not modified.
  • isFull() returns a boolean and tests for an full stacks, stack s is not modified.
  • size() returns the int size of the stacks, stack s is not modified
  • print() prints the stacks from front to rear, stack s is not modified.
  • top() prints the front element, stack s is not modified.

Write your own Driver file to show that you have implemented all the methods of the stack. A psuedocode example is listed below to guide you. Use print statements as well to show the popped elements, to show the stack after some pushes, to print the size of the stack.

  • push(redShirt)
  • push(greenShirt)
  • push(yellowPants)
  • push(purpleSock)
  • push(pinkSocks)
  • printStack()
  • size()
  • push(blueShirt)
  • size()
  • pop()
  • pop()
  • size()
  • pop()
  • printStack()
  • top()
  • pop()
  • pop()
  • printStack()
  • size()
  • isEmpty()
  • printStack()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago

Question

7. Define cultural space.

Answered: 1 week ago