Question Details
[solution] » I am doing an assignment for class and it requires me to Develop an algo
Description
Answer Download
The Question
I am doing an assignment for class and it requires me to Develop an algorithm using the Java programming language that implements a basic stack data structure.
Here is the scenario: Assume that you are developing a system for a manufacturing assembly line that builds automobiles. There are three stations in the manufacturing line where an inspector will visually inspect the vehicle. You program must keep track of these inspections as they occur. You decided to develop your program using a stack data structure. As your vehicle begins the line you will push the number 0, which indicates that that an inspection has not yet occurred, onto the stack three subsequent times. At each station in the line you will pop one of the items off of the stack. Each time your algorithm pops an item from the stack you must print it out to the console using the system.out.println function. I will post my code below. Does my code represent this scenario and how do i perform the Asymptotic analysis of my algorithm?
My Code:
import jeliot.io.*; public class MyStack { private int maxSize; private long[] stackArray; private int top; public MyStack(int s) { maxSize = s; stackArray = new long[maxSize]; top = -1; } public void push(long j) { stackArray[++top] = j; } public long pop() { return stackArray[top--]; } public long peek() { return stackArray[top]; } public boolean isEmpty() { return (top == -1); } public boolean isFull() { return (top == maxSize - 1); } public static void main(String[] args) { MyStack theStack = new MyStack(5); theStack.push(0); theStack.push(1); theStack.push(2); theStack.push(3); theStack.push(4); while (!theStack.isEmpty()) { long value = theStack.pop(); System.out.print(value); System.out.print(" "); } System.out.println(""); } }
Solution details
Solution #000121875
Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
About this Question
STATUSAnswered
QUALITYApproved
DATE ANSWEREDOct 14, 2020
EXPERTTutor
ANSWER RATING
BEST TUTORS
We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.
You can also use these solutions:
- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
STUCK WITH YOUR PAPER?
Order New Solution. Quick Turnaround
Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.
WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.
