<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Queues and Stacks - CSCI 151: Data Structures</title><link>https://cs.oberlin.edu/~cs151/lab-5/index.html</link><description>Lab 5 Goals Implement queue and stack data structures to reinforce our understanding how they work Use array lists as the backing of our queue and stack to explore how one data structure can be used to create another Explore the application of queues and stacks for a real-world problem Learn about the use of Javadocs for documenting Java code Welcome to your fifth CSCI 151 lab! The lab can be started by following this link to create a copy of the assignment for you on GitHub: Accept Assignment</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 07 Aug 2021 09:07:24 -0400</lastBuildDate><atom:link href="https://cs.oberlin.edu/~cs151/lab-5/index.xml" rel="self" type="application/rss+xml"/><item><title>Reading the Documentation</title><link>https://cs.oberlin.edu/~cs151/lab-5/w-part-1/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/w-part-1/index.html</guid><description>One great thing about Java is that it has excellent documentation. For example, open the documentation for ArrayList
At the top, we see the following:
This tells us that ArrayList&lt;E&gt; extends AbstractList&lt;E&gt;, which extends AbstractCollection&lt;E&gt;, which extends Object. (Every class in java extends java.lang.Object, unless it explicitly extends some other class.) It also tells us which interfaces ArrayList implements.
Underneath this, there’s a description of the ArrayList class, followed by a list of its constructors, and then a list of its methods. Clicking on any method will take you to a longer description. For example, if you click on add(int index, E element), you’ll see this:</description></item><item><title>Creating Your Own JavaDocs</title><link>https://cs.oberlin.edu/~cs151/lab-5/w-part-2/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/w-part-2/index.html</guid><description>One important component of a good program is its documentation. One of the downsides of documentation is that it is often separate from the source code that it describes, leading to the possibility that they can become out of sync, and therefore useless.
Java has a nice built-in way of dealing with this problem. It allows the incorporation of certain tags into source code, which will then become processed by a separate program to create human-readable documentation. By combining the files used for the docs with those used for the code, it reduces the chance that they’ll be out of sync.</description></item><item><title>Working with Stacks and Queues</title><link>https://cs.oberlin.edu/~cs151/lab-5/w-part-3/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/w-part-3/index.html</guid><description>In this lab, you will first be implementing and then working with Stacks and Queues. It will be helpful to first refresh your memory of how they work. We have provided you with two java files that provide examples of working with Stacks and Queues, GuessWhatIDo.java and GuessWhatIDo2.java
Note that Java does not provide a built in Queue class, but rather has LinkedList implement the Queue interface, so in these examples we are using a LinkedList as our Queue implementation.</description></item><item><title>Implementing MyQueue</title><link>https://cs.oberlin.edu/~cs151/lab-5/l-part-1/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/l-part-1/index.html</guid><description>Data Structure Overview In the first part of this lab, we will be creating our own implementation of the queue data structure to better understand how to implement the FIFO property. Java already provides an interface called Queue that defines all the methods that a queue should have, as well as an AbstractQueue abstract class that implements some of the basic functionality of the Queue interface (that could be shared by other types of queues that are not backed by an array list like the one we will create below). We’ll again be using generics for the implementation so that the queue can store any type of data as elements.</description></item><item><title>Implementing MyStack</title><link>https://cs.oberlin.edu/~cs151/lab-5/l-part-2/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/l-part-2/index.html</guid><description>Data Structure Overview In the second part of this lab, we will be creating our own implementation of the stack data structure to better understand how to implement the LIFO property (in contrast with our FIFO queue data structure in Part 1). Interestingly, Java does not have a built in interface for stacks, but it does have a class called Stack that implements all of the methods that a stack should have. Instead, we have provided you in your GitHub repository with an interface called StackADT that uses the same method naming scheme as Java’s built in Stack. As in Part 1, we will create our own stack implementation following this interface by using an array list as our backing data structure. We’ll again be using generics for the implementation so that the stack can store any type of data as elements.</description></item><item><title>Maze Application Background</title><link>https://cs.oberlin.edu/~cs151/lab-5/l-part-3/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/l-part-3/index.html</guid><description>In the remainder of the lab, we will be exploring how stacks and queues can be useful for solving search problems such as searching for a solution to a maze. This part of the lab will provide useful background about how we can represent a maze in Java, so please read carefully to help you with the remainder of the lab. There is nothing to implement in this part.
Objective The goal of this application is to implement an algorithm that finds a path from a unique starting location in a maze (shown below in green) to a unique exit location (shown in red). If such a path exists, the provided application will visualize not only the maze, but also the found solution path, shown in yellow below. If no path exists (which is possible for some mazes), the application should also be able to detect that no solution is possible.</description></item><item><title>Finding a Maze Solution</title><link>https://cs.oberlin.edu/~cs151/lab-5/l-part-4/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/l-part-4/index.html</guid><description>Class Overview The MazeSolver class is an abstract class that implements most of the functionality needed to find a solution path through a given Maze (or determine that no solution exists). It is an abstract class because later in the lab, we will implement two children classes: one that uses a queue to explore the possible paths through the maze and another that instead uses a stack.
Finding a Solution Path The general algorithm for finding a solution for a maze works by expanding possible path one step at a time from the start location until either (1) we reach the exit location, indicating we found a solution path, or (2) we explore every reachable location from the start location without reaching the exit location, indicating no solution path exists.</description></item><item><title>Breadth First (FIFO) vs. Depth First (LIFO) Search</title><link>https://cs.oberlin.edu/~cs151/lab-5/l-part-5/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/l-part-5/index.html</guid><description>Overview In this final part of the lab, we will create two children classes of MazeSolver that use either a queue or a stack to represent the exploration collection in order to change the order (FIFO vs. LIFO) that we explore paths through the maze to find its solution.
Implementing MazeSolverQueue In Visual Studio Code, create a new file called MazeSolverQueue.java. Within this file, you should create a new class called MazeSolverQueue that extends MazeSolver.</description></item><item><title>Wrap Up</title><link>https://cs.oberlin.edu/~cs151/lab-5/wrap-up/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-5/wrap-up/index.html</guid><description>Congratulations! You have now implemented our third and fourth data structures (the Queue and Stack) and created an application using them to complete your fifth lab of the semester!
Filling Out the README.md The final task for every lab is to edit the README file in the lab assignment repository. Each week, you’ll be asked to answer three questions regarding collaboration, time spent on the lab, and the Honor Code.</description></item></channel></rss>