Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Data Abstraction & Problem Solving with CFrank M. Carrano; Timothy M. Henry 1 /** @file BagInterface.h */ 2 #ifndef BAG_INTERFACE_ 3 #define BAG_INTERFACE_ 4 5
Data Abstraction & Problem Solving with CFrank M. Carrano; Timothy M. Henry
1.5 The ADT Bag Imagine a paper bag, a reusable cloth bag, or even a plastic bag. People use bags when they shop, pack a lunch, or eat potato chips. A bag contains things. We could consider the bag to be an abstract data type. Let's specify and use the ADT bag. Knowing just its interface, you can use a bag in a program. You do not need to know how the entries in the bag are represented or how the bag operations are implemented. These specifics are hidden behind the bag's wall of abstraction, and your program will not depend on these specifics. As you will see, this important program characteristic is what data abstraction is all about. What distinguishes a bag from other ADTS? A bag doesn't do much more than contain its items. It doesn't order them in a particular way, nor does it prevent duplicate items. While describing the behaviors for the ADT bag that we'll design in this chapter, let's keep in mind that we are specifying an abstraction inspired by an actual physical bag. For example, a paper bag holds things of various dimensions and shapes in no particular order and without regard for duplicates. Our abstract bag will hold unordered and possibly duplicate objects, but let's insist that these objects have the same or related data types.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started