Declare linked list that will hold the elements in the stack

Assignment Help Data Structure & Algorithms
Reference no: EM131266003

Create a class called GenericStack that uses a linked list to implement a stack, which is a collection that lets you access entries on a first-in, last-out basis. Then you'll create another class that uses the GenericStack class.

The GenericStack class should implement these methods.

Push(element): Adds an element to the top of the stack.
Pop(): Returns and removes the element at the top of the stack
Peek():Returns but does not remove the element at the top of the stack.
Size(): Returns the number of entries in the stack.

A. Create a GenericStack class

i. Create a new class named GenericStack that specifies a type variable that provides for generics.

ii. Declare a linked list that will hold the elements in the stack. Then, use the linked list to implement the methods listed above.

B.. Create a class that uses GenericStack class

i. Open the GenericStackApp class. Then declare a generic stack at the beginning of the main method that will store-String objects.

ii. Add code to the main method that uses the push method to add at least 3 items to the stack. After each item is added, display its value at the console. Then use the size method to return the number of items in the stack and display that value

iii. Use the peek method to return the first item and display that item and use the size method to return the number of items again and display that value

iv.Use the pop method to return each item, displaying it as its returned and display the number of items one more time.

v. Output will be as follows:

Push: Apples
Push: Oranges
Push: Bananas

The stack contains 3 items

Peek: Bananas

The stack contains 3 items

Pop: Bananas
Pop: Oranges
Pop: Apples

The stack contains 0 items.

Reference no: EM131266003

Questions Cloud

How to calculate charges if user returns the book late : How to calculate charges if user returns the book late? How to determine the book condition/depreciation? Provision of scanning the barcode instead of entering the data manually.
Movement along the same demand curve for product : What happens to the demand curve and the supply curve when any of these determinants change? What would cause a change in demand versus a movement along the same demand curve for this product?
Uses weighted average with a periodic inventory system : During 2012, a company sells 300 units of inventory for $85 each. the company has the following inventory purchase transactions for 2012: DATE TRANSACTION NUMBER OF UNITS UNIT COST TOTAL COST jan. calculate ending inventory and cost of goods sold for..
Balance sheet for its investment in burke corporation : Gilman Company purchased 100,000 of the 250,000 shares of common stock of Burke Corporation on January 1, 2009, at $40 per share as a long-term investment. The records of Burke Corporation showed the following on December 31, 2009:  balance sheet for..
Declare linked list that will hold the elements in the stack : Create a new class named GenericStack that specifies a type variable that provides for generics. Declare a linked list that will hold the elements in the stack. Then, use the linked list to implement the methods listed above.
Discuss four components of corporate social responsibility : Discuss the four components of corporate social responsibility (CSR) and how they relate to a charitable campaign such as (Product) RED.
Decrease short-term interest rates : Suppose that the Federal Reserve is concerned about deflation in the future, so they decrease short-term interest rates. How will this affect long-term rates and the yield curve?
Appraisal value of this acquired land : On May 26, 2012, the Georgia Corp. acquired a piece of land by issuing 60,000 shares of its $9 par value common stock. The list price of the land was $625,000 and on May 26, 2012, Georgia's common stock was actively trading in the marketplace at $10 ..
Describe the effects of paralysis on the skeleton : 1. Following a severe spinal cord injury in the lumbar region, the voluntary muscles of the legs and hips will be paralyzed. Describe the effects of paralysis on theskeleton.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd