Question: In Java ADT: - A stack that does not allow duplicates - The ADT allows only a single copy of an object in the stack.
In Java

ADT: - A stack that does not allow duplicates - The ADT allows only a single copy of an object in the stack. Stack is unchagned if a duplicate object is being added to it. - support the usual peeko, pop(), push(newElement) mehtods - Also, the following operations: - find(x) that finds the location of an element x in the stack. The first element in the stack has location number one. The second pushed element has location number two and so on. - peek1() returns the first pushed element CDT/Data structure: - Use circular linked list Specification: - write the proper preconditions and postconditions of each method Exception handling: - The stack has a limit. The stack throws a user exception whenever a client push an item to a full stack. - Also, throws a user exception whenever peek or pop operations being called on an empty stack Design Decision: - Seperate the the ADT specfication from its implmentation using Java Ineterface - Make the ADT generic Testing: - write in a main() function suffient test code to test all the methods that the ADT support - check corner cases; i.e. pushing to full stack, peeking into an empty stack, pushing a duplicate item, Time effeincey: - peek10 has to run in a constant time O(1) Naming Convention: - Class names are written in UpperCamelCase. - lowerCamelCase. - Constant names use CONSTANT_CASE: all uppercase letters, with each word separated from the next by a single underscore
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
