• Home
  • University of the People
  • Data Structures (proctored course) CS 3303
  • Data Structures Programming Assignment

Data Structures Programming Assignment

Programming Assignment Unit 3 University of the People CS 3303 - Data Structures Shuchi Dhir, Instructor July 06, 2022 In this assignment I need to develop a system for a manufacturing assembly line that builds automobiles and based on a Java programming language algorithm that implements a basic stack data structure. I will do the stack to push entries on the stack and to pop entries off the stack. I will push three vehicle inspections and pop them one after the other in each of the three inspection stations. I will divide this solution three parts: 1. In part 1 I will establish the ADT structure for the stack which I need to create. It includes finding the data type, elements that indicate an inspection, the stack creation, filling up the stack. emptying items from the stack, and other actions. The screenshot of the code for part 1: package com.fwd; **Stack ADT */ public interface Stack<E> /**clearning the stack for reclaiming the storage used by the stack lements public void clear); /* pushing element into the top of the stack. @ param inspec the element being pushed */ public void push (E inspec; /** removing an element from the top of the stack. @return the element being removed */ public E pop; /** @return the value of the top element of the stack */ public E topValue); /** @return the number of elements in the stack */ public int length(); 2. In part 2 I will build the implementation of the stack. I will do a stack using an array-based list because I know the maximum number of items. The screenshot of the code for part 2: array-based stack implementation entioned above */ lass InspeeStack<E> implements Stack<E> private int mexsize; defines the maximum size of the stack private int top; for the top element private E[] SArrax; creates the array that holds the stack defining the constructors */ thiw(initsize); InsnecStack (int size) xstze size; sarrax E[]) newObject[size];//creates SArrax //reinitialize stack public void clear top-0 pubiic void push (E inRe) asserttop !-mexSize: "stack is already full"; SArrax[top++] = insnaci because we can't pop out an element that doesn't exist. return sorraxi--top]; //defines a method that return the value of the top element public E tonValue ) assert "Stack is empty"; return Sorrax[top-l]; // defines a method that returns the length of the stack public int length retu