Question

Write the pseudocode for a “push” member methodusing an array (holding type double) implementation.  You should assume t...

Write the pseudocode for a “push” member methodusing an array (holding type double) implementation.  You should assume the existence of an integer variable (called top) which refers to the index of the first OPEN cell.  DO NOT ASSUME THE EXISTENCE OF ANY OTHER METHODS (i.e. don’t use any other methods).  Read question carefully, use standard definitions and naming conventions for the stack and queue data structures, figure out the requirements, inputs & outputs (as appropriate), as well as any required error checks.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Pseudocode for push method: push( double data, int size)

Input: data value required to push into stack., Stack size is required to check overflow.

Output: return 1 after successful operation, return 0 for unsuccessful operation.

1.if top =size -1

1.1. Print stack overflow

1.2. return 0

2. Otherwise

2.1. top= top + 1

2.2.Stack[ top]. = data

2.3.return 1

  

Add a comment
Know the answer?
Add Answer to:
Write the pseudocode for a “push” member methodusing an array (holding type double) implementation.  You should assume t...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the pseudocode for a non-member method“dequeue” which is utilizing a linked list. The list node has 2 attributes:...

    Write the pseudocode for a non-member method“dequeue” which is utilizing a linked list. The list node has 2 attributes: data and next.  The method would take a “front” and “rear” reference and will return a “character” (the data element from the de-queued node). **Special note: DO NOT ASSUME THE EXISTENCE OF ANY OTHER METHODS (i.e. don’t use any other methods).  Use basic definitions and standard naming conventions for the stack and queue data structures, figure out the requirements, inputs &...

  • C++ Create an array-based implementation of a stack. Each element of the stack should store a...

    C++ Create an array-based implementation of a stack. Each element of the stack should store a string. The stack class should include 3 private member variables (maximum stack size, top of the stack index, and a pointer to the array that holds the stack elements). Public member methods should include a constructor (with an argument of stack maximum size that is used to create a dynamic array), a destructor (that deletes the dynamic array), a push method (argument is a...

  • Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your...

    Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...

  • Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write...

    Please Write Pseudocode or Python code! Thanks! P1. b) is the following: W1. (6 marks) Write the pseudocode for removing and returning only the second element from the Stack. The top element of the Stack will remain the top element after this operation. You may assume that the Stack contains at least two items before this operation. (a) Write the algorithm as a provider implementing a Stack using a contiguous memory implementation. You can refer to the implementation given in...

  • You will write the following files: mystack.h - contains the class definition for the mystack class....

    You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...

  • AQueue.java class AQueue implements Queue { private E queueArray[]; // Array holding queue elements private static...

    AQueue.java class AQueue implements Queue { private E queueArray[]; // Array holding queue elements private static final int DEFAULT_SIZE = 10; private int maxSize; // Maximum size of queue private int front; // Index of front element private int rear; // Index of rear element // Constructors @SuppressWarnings("unchecked") // Generic array allocation AQueue(int size) { //BUG #1: maxSize = size maxSize = size+1; // One extra space is allocated rear = 0; front = 1; queueArray = (E[])new Object[maxSize]; //...

  • In this part, you will complete the code to solve a maze.

    - Complete the code to solve a maze- Discuss related data structures topicsProgramming-----------In this part, you will complete the code to solve a maze.Begin with the "solveMaze.py" starter file.This file contains comment instructions that tell you where to add your code.Each maze resides in a text file (with a .txt extension).The following symbols are used in the mazes:BARRIER = '-' # barrierFINISH = 'F' # finish (goal)OPEN = 'O' # open stepSTART = 'S' # start stepVISITED = '#' #...

  • The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this sof...

    The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this software is knowing the distance between any two cities that it services. Design and implement a Distance class that stores the distances between cities in a two-dimensional array. This class contains the following required data members and methods: Required Data Members: String[] cities; //it is used to store city names int[][] distance; // this 2-D array repreents distance between two...

  • For this project you will implement a simple calculator. Your calculator is going to parse infix...

    For this project you will implement a simple calculator. Your calculator is going to parse infix algebraic expressions, create the corresponding postfix expressions and then evaluate the postfix expressions. The operators it recognizes are: +, -, * and /. The operands are integers. Your program will either evaluate individual expressions or read from an input file that contains a sequence of infix expressions (one expression per line). When reading from an input file, the output will consist of two files:...

  • Assignment You will be developing a speeding ticket fee calculator. This program will ask for a t...

    Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file or to the console depending on the command line arguments. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT