EBK STARTING OUT WITH C++
EBK STARTING OUT WITH C++
9th Edition
ISBN: 9780134996066
Author: GADDIS
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
Question
Book Icon
Chapter 19, Problem 22RQE
Program Plan Intro

Stack:

A stack is type of container. It performs “Last In First Out”.

  • In stack, the item which is inserted at last will be retrieved first.
  • A stack can perform two operations. They are:
    • Push – Inserting an element inside a stack.
      • When the first element is pushed into the stack, the element will be at the “top” the stack. When the second element is added, the first element is pushed down and the second element will be at the top position, like this it goes on until the element which pushed at last will be at the top of the stack.
    • Pop – Deleting an element from the stack.
      • The element which is inserted at last will be deleted first.
  • The elements can be inserted and retrieved at any one end of the stack.

Blurred answer
Students have asked these similar questions
First picture: create a complete programming codes about the picture. Use pre-defined for stack. Sencond Picture: Test results or the supposed outcome of the programming. Note: put a comment in every line to describe what is the function of each specific codes, variables, etc.
C# Reverse the stack - This procedure will reverse the order of items in the stack.  This one may NOT break the rules of the stack. HINTS: Make use of more stacks.  Arrays passed as parameters are NOT copies.  Remember, this is a procedure, not a function.  This would occur in the NumberStack class, not the main class. These are the provided variables: private int [] stack;private int size; Create a method that will reverse the stack when put into the main class.
3- Write a program that randomly generates 10 numbers (between 1 and 8), inserts into queue and then finds how many distinct elements exist in the queue. Example 1: Example 2: Queue: 2 40 3 3 2 18 4 18 18 3 Queue: 1 1 4 33 16 16 4 16 4 Output: 5 Output: 4 Notes: • You must use ONLY queue data structure. Don't use other different data structures like string or normal (pure) array or stack or array list. • Don't write any other method in the Qeueu class. All methods must be written in the main program.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning