<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Binary Search Trees - CSCI 151: Data Structures</title><link>https://cs.oberlin.edu/~cs151/lab-6/index.html</link><description>Lab 6 Goals Implement a binary search tree (BST) node class to reinforce our understanding how BSTs work Gain more practice using recursion to work with data and solve problems Continue practicing using unit tests to help us debug our code Explore the application of BSTs for a real-world problem Welcome to our sixth 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-6/index.xml" rel="self" type="application/rss+xml"/><item><title>Recursion</title><link>https://cs.oberlin.edu/~cs151/lab-6/w-part-1/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/w-part-1/index.html</guid><description>In this first section of the warmup, you will work with a partner on several recursive functions to refresh your memory of how recursion works.
To start, open the Recursion.java and LinkedNode.java files provided to you. We have given you some functions to fill in, as well as some test code in the main method that you can uncomment when you are ready to use it.
Reversing a String We will start with a method that recursively reverses a String. This is the public static String rev(String s) method in Recursion.java. Calling it with the argument “CS 151 is fun!” should return “!nuf si 151 SC”. To help design your solution, you may want to look into the String substring methods.</description></item><item><title>Traversals</title><link>https://cs.oberlin.edu/~cs151/lab-6/w-part-2/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/w-part-2/index.html</guid><description>One of the traits that comes with a tree is that it does not have a predetermined logical ordering of the nodes, unless one is imposed from the outside.
For example, if we have the binary tree:
A / \ B C we could state that the nodes, printed in order, should be ABC, BAC, CAB, BCA, etc. All would be valid, depending on the criteria that we choose.</description></item><item><title>Comparable Interface</title><link>https://cs.oberlin.edu/~cs151/lab-6/w-part-3/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/w-part-3/index.html</guid><description>Whenever we want to sort a collection of data, we need a way of being able to compare any two pieces of items from that collection. If we are sorting in ascending order, then smaller items should be before larger items, and vice-versa when sorting in descending order.
In some programming languages (e.g., Python), we can use the &lt; operator to determine if one item is smaller than another. In Java, this operator only works for numbers and not for Strings or other types of objects.</description></item><item><title>Starting MyBinarySearchTreeNode</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-1/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-1/index.html</guid><description>Data Structure Overview In the first parts of this lab, we will be creating our own implementation of the binary search tree (BST) data structure to better understand its implementation and behavior.
Java does not provide an interface or abstract class that represents a BST. Thus, we will build the BST data structure entirely from scratch following the descriptions we used in lecture. We will be using generics for the implementation so that the tree can store any type of data as elements.</description></item><item><title>Inserting Items</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-2/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-2/index.html</guid><description>The first operation we want to be able to perform with a BST is to insert a new item into the BST so that we can create a sorted collection of data. We will implement this in a method:
public MyBinarySearchTreeNode&lt;T&gt; insert(T item) that takes as a parameter the item of type T to add to the tree and returns the newly created MyBinarySearchTreeNode that now stores item. Recall from lecture and our reading that the insert method works recursively:</description></item><item><title>Traversal Methods</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-3/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-3/index.html</guid><description>Now that we can create a binary search tree by inserting nodes, the next step is to implement methods that can traverse the BST. Feel free to refer back to the Warmup 2 for a reminder of how the different traversals work on a given BST.
Traversal Methods For our traversals, instead of printing out each item, we will instead save each item to a List when we “visit” a node. Thus, your traversal methods will take as a single parameter a List and you will add a node’s item when we visit the node in the traversal. None of the three methods will need to return anything since the List argument is modified by the methods (and those changes remain outside of the method calls).</description></item><item><title>Finding Nodes</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-4/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-4/index.html</guid><description>Now that we have the ability to create a binary search tree (using the insert method) and we can use the traversal methods to verify that the nodes are created in the correct order, we can now implement functionality to find a MyBinarySearchTreeNode&lt;T&gt; for a given item of type T.
Find Method Create a public method called find that takes as a single parameter an instance of the Object class called obj. This method should recursively search through the BST until it finds the MyBinarySearchTreeNode&lt;T&gt; child that contains an item whose compareTo is 0 for the Object obj passed into the find method. If no such node is found, the method should return null.</description></item><item><title>Removing Items</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-5/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-5/index.html</guid><description>As a final step in implementing the binary search tree data structure, we will implement a method for removing items from the tree. After this, we will have a fully functioning BST that we could use for different applications.
Find Successor Method Before we can implement a method for removing an item from the tree, we first need to create a helper method that finds the node that is the successor of the current node in the BST. In your MyBinarySearchTreeNode&lt;T&gt; class, create a private method called findSuccessor that takes no parameters. The method should return the MyBinarySearchTreeNode&lt;T&gt; that contains the item that is the next biggest item in the BST. Recall from lecture that the pseudocode for this method is:</description></item><item><title>Book Search Engine</title><link>https://cs.oberlin.edu/~cs151/lab-6/l-part-6/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/l-part-6/index.html</guid><description>Application Overview In this part of the lab, we will use our MyBinarySearchTreeNode&lt;T&gt; implementation of the binary search tree data structure to support a search engine for looking up books in the GoodReads data provided in the GoodReadsData.txt file in your GitHub repository.
A GUI for our search engine has been provided for you in the BookSearchFrame class. If you run the main method in this class, you will see something like the following image:</description></item><item><title>Wrap Up</title><link>https://cs.oberlin.edu/~cs151/lab-6/wrap-up/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-6/wrap-up/index.html</guid><description>Congratulations! You have now implemented our fifth data structure (the binary search tree) and created an application using it to complete your sixth 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.
A reminder to make sure you have consulted the Honor Code policy in the course syllabus for information about how to sign the Honor Code and about acceptable collaboration in CSCI 151. Your instructor is also happy to answer any questions about the Honor Code – just let us know.</description></item></channel></rss>