Close
Register
Close Window

Software Design and Data Structures

Chapter 4 Linked Chains, Bags Continued

Show Source |    | About   «  4.1. Linked Chains (Pointers)   ::   Contents   ::   4.3. Lab 4 Grocery Bags  »

4.2. Linked Bags

4.2.1. Objectives

Upon completion of this module, students will be able to:

  • Name the function and purpose of basic Java data structures

  • State key characteristics of Bags in Java

  • Build and populate Bags in Java

4.2.1.1. Suggested Reading:

Suggested Reading: Chapter 3: Bag Implementation That Links Data from Data Structures and Abstractions with Java, 4th edition by Frank M. Carrano and Timothy Henry

4.2.2. Interactive: Introduction to Linked Bags [4:10]


Video Slides LinkedBagIntro.pdf

4.2.3. Interactive: LinkedBag add() and toArray() [12:45]


Video Slides LinkedBagAddToArray.pdf

4.2.4. Checkpoint 1

4.2.5. Interactive: ExLinkedBagJUnit Demonstration [7:14]

Try It Yourself

In Eclipse, use the Project > Download Assignment… menu command to download the exercise project named “ex08.05-LinkedBagsWithJUnit”. Use this example to follow along with the following video. Feel free to experiment.

4.2.6. Interactive: LinkedBag getFrequencyOf() and contains() [14:00]

Try It Yourself

In Eclipse, use the Project > Download Assignment… menu command to download the lab project named “ex08.05-LinkedBagsWithJUnit”

Refer to 01.02: Lab: LightBot for Beginners if you need to review the instructions for downloading Eclipse projects.


Video Slides LinkedFreqContains.pdf

4.2.7. Checkpoint 2

4.2.8. Interactive: LinkedBag Removing an item [13:44]


Video Slides LinkedRemove.pdf

Tradeoffs of using a linked chain implementation for a bag

Pros and Cons of Linked Bags

Pros

Cons

Bag can grow in size easily

Requires more space than a same-sized array

Adding an entry to the bag is fast

Removing a specified entry requires time to locate the entry

4.2.9. Checkpoint 3

4.2.10. Wrapping up Bags

As you’ve seen, Bags are a simple but foundational data structure in Java. We will continue with other data structures and their unique characteristics, including opportunities to practice building them, in later modules.

Recall that the objectives for this module were to:

  • Name the function and purpose of basic Java data structures

  • State key characteristics of Bags in Java

  • Build and populate Bags in Java

4.2.11. Programming Practice: LinkedBags

   «  4.1. Linked Chains (Pointers)   ::   Contents   ::   4.3. Lab 4 Grocery Bags  »

nsf
Close Window