.. This file is part of the OpenDSA eTextbook project. See .. http://opendsa.org for more details. .. Copyright (c) 2012-2020 by the OpenDSA Project Contributors, and .. distributed under an MIT open source license. .. avmetadata:: :author: Molly Domino Linked Bags =========== 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 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 `_ .. _LinkedBagIntro: Interactive: Introduction to Linked Bags [4:10] ----------------------------------------------- .. admonition:: Follow Along and Engage Download the slides corresponding to the video. Take notes on them as you watch the video, practice drawing diagrams yourself! .. raw:: html Video Slides 8.2.3-LinkedBagIntro.pdf .. raw:: html
.. _LinkedBagAdd: Interactive: LinkedBag add() and toArray() [12:45] -------------------------------------------------- .. admonition:: Follow Along and Engage Download the slides corresponding to the video. Take notes on them as you watch the video, practice drawing diagrams yourself! .. raw:: html Video Slides 8.2.4.1-LinkedBagAddToArray.pdf .. raw:: html
Checkpoint 1 ------------ .. avembed:: Exercises/MengBridgeCourse/LinkedBagCheckpoint1Summ.html ka :long_name: Checkpoint 1 .. _LinkedBagTest: Interactive: ExLinkedBagJUnit Demonstration [7:14] --------------------------------------------------- .. admonition:: Follow Along, Practice and Explore 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. Refer to `01.02: Lab: LightBot for Beginners `_ if you need to review the instructions for downloading Eclipse projects. .. raw:: html
.. _LinkedBagContains: Interactive: LinkedBag getFrequencyOf() and contains() [14:00] -------------------------------------------------------------- .. admonition:: 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. .. raw:: html Video Slides 8.2.6.1-LinkedFreqContains.pdf .. raw:: html
Checkpoint 2 ------------ .. avembed:: Exercises/MengBridgeCourse/LinkedBagCheckpoint2Summ.html ka :long_name: Checkpoint 2 .. _LinkedBagRemove: Interactive: LinkedBag Removing an item [13:44] ----------------------------------------------- .. admonition:: Follow Along and Engage Download the slides corresponding to the video. Take notes on them as you watch the video, practice drawing diagrams yourself! .. raw:: html LinkedRemove.pdf .. raw:: html
.. admonition:: Tradeoffs of using a linked chain implementation for a bag .. list-table:: Pros and Cons of Linked Bags :header-rows: 1 * - 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 Checkpoint 3 ------------ .. avembed:: Exercises/MengBridgeCourse/LinkedBagCheckpoint3Summ.html ka :long_name: Checkpoint 3 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 Programming Practice: LinkedBags -------------------------------- .. extrtoolembed:: 'Programming Practice: LinkedBags' :workout_id: 1911