An ADT of a Set can inherit a List (ArrayList, for instance) since it is a collection of objects BUT it cannot have any duplicates and needs to have an avgSet that will return an average of the numbers.
Added by Julie M.
Step 1
This class will internally use an `ArrayList` to store the elements. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 87 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Akash M.
Exercise 4 (Stack ADT) ****IN JAVA*** In the Lab 7 project, add a class called ArrayIntStack that uses the ArrayIntList class to implement a Stack ADT. Then, add a class called LinkedIntStack that uses the LinkedIntList class to implement a Stack ADT. Compare the two implementations. Test your implementations in the main methods. Also, state the time complexity of your method implementations. Explanation of the Stack ADT A Stack ADT is a linear data structure whose elements are added and removed from the same end. In stacks, elements are processed in a last in, first out (LIFO) manner. This means that the element that was last added will be the first one to be removed. In a Stack, we call the adding operation push, and the removing operation pop. We typically think of stacks as being depicted vertically, so the top of the stack represents the last element added to the stack (or null). See example below: Implementation Details To implement a Stack, simply make a Stack class and then declare either the ArrayIntList or LinkedIntList as an instance variable. The constructor will just create a new list to represent the stack. Each operation, push and pop, will correspond to the operation of the list. So, just call the corresponding method on the list. You should also add the toString method. Figure: Visual depiction of Stack:
The simplest implementations of sets are subclasses of which other class?a.stacksb.listsc.bagsd.queues
James K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD