Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Source material: Object-Oriented Data Structures Using Java, 3rd Edition by Nell

ID: 3697350 • Letter: S

Question

Source material: Object-Oriented Data Structures Using Java, 3rd Edition by Nell Dale.

What is the answer to exercise 7 in chapter 3 (Page 232)??

"Create a generic link-based bag class that features all the functionality of the Bag class specified in exercise 29 of chapter 2. Create a driver application that demonstrates that your implementation works correctly."

From exercise 29 of chapter 2 for quick reference:

"A StringBag ADT is similar to a StringLog ADT. Clients can insert strings into it, clear it, use it's toString, and check to see if it is full. However, for a bag rather than checking to see if it contains a given string, the client can only remove a random string (as if the client is blindly reaching into a bag of candy and taking one piece). The remove method randomly selects a string from the bag, "deletes" it from the bag, and returns it to the client. The number of copies of a string that are put into the bag IS important- if three "lollipop" strings are inserted, then three "lollipop" strings can be removed. We can assume that remove is not called if the bag is empty, therefore a bag should include an isEmpty method that returns whether or not the bag is empty, for the clients use."

Explanation / Answer

To manage the complexity of problems and the problem-solving process, computer scientists use abstractions to allow them to focus on the “big picture” without getting lost in the details. By creating models of the problem domain, we are able to utilize a better and more efficient problem-solving process. These models allow us to describe the data that our algorithms will manipulate in a much more consistent way with respect to the problem itself.

Earlier, we referred to procedural abstraction as a process that hides the details of a particular function to allow the user or client to view it at a very high level. We now turn our attention to a similar idea, that ofdata abstraction. An abstract data type, sometimes abbreviated ADT, is a logical description of how we view the data and the operations that are allowed without regard to how they will be implemented. This means that we are concerned only with what the data is representing and not with how it will eventually be constructed. By providing this level of abstraction, we are creating an encapsulationaround the data. The idea is that by encapsulating the details of the implementation, we are hiding them from the user’s view. This is called information hiding.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote