• Continue to gain proficiency at top-down design and bottom-up implementation.
• Practice reading data from a file.
• Practice using a list of lists to store data.
• Understand how to adapt linear search and binary search to real-world data.
For this this assignment, we will be working with a real-world dataset from CORGIS (which is an acronym for: The Collection of Really Great, Interesting, Situated Datasets). We will be using a dataset that contains records on over a thousand video games released between 2004 and 2008. This includes a variety of information on consoles, formats, sales, review scores, and average playtime. While this dataset contains many features, but we will be focusing on only a small subset of these features.
The video game data is stored in CSV format and is located at: /data/cs21/videogames/video_games.csv
In this lab we will focus on features 0, 6, and 8 (plus 3, 4, and 9 if you do the optional challenge). In the next lab, which adds sorting, we will incorporate more functionality for the other features.
Using search to explore video game data
You will implement a program called search-games.py, which will allow the user to search through this dataset and learn particular information.
Users may search by console and release year
Games Search Example 1
Searching games by console and release year
Program Requirements
• All numeric data in the file should be type cast to the correct type when stored in the program.
• Compares data in lowercase format (so that user input is case insensitive) but displays results with their original case.
• Repeatedly presents a menu to the user with three choices: to search by game title, to search by console/year, or to quit.
• Ends when the user chooses to quit.
• Ensures that the user provides a valid menu choice and a valid year.
• Uses formatted printing to show search results in a table format that fits in an 80-character wide terminal window.
• Uses linear search to find matches by console/year.
• Uses binary search to find matches by game title.
Tips
We strongly recommend that you create a top-down design with a fully fleshed out main and stubs for all other functions. However, you may not work with a partner on this lab. Also you don’t need to get approval from an instuctor for your design, though we’d be glad to review it with you in lab, office hours, or ninja sessions. You should only begin implementing the other functions after you have a clear plan in place for the structure of main.
Avoid duplicating similar code in multiple places throughout the program. Think about how you could re-use the same function. For example, we are doing two types of searchs (by year/console and by title), but the results of those searches are displayed in exactly the same way. Consider having a function that takes in a list of search results and displays them. Then you could call this function for either type of search.
We want the results of our searches to be nicely displayed in the terminal window. However, some game titles names are quite long. We can use slicing to truncate these strings to a fixed maximum length, allowing us to create an easy to read table format. This section of the online textbook explains how to slice a string. For instance, the following example shows how to slice out the first 10 characters from a string:
The version of linear search that we discussed in class stops as soon as it finds the item it is looking for, and returns the index of that item or -1 if not found. For this problem, your linear search will need to accumulate a list of matching results and return that.
In addition, the basic version of linear search assumes that you are searching a flat list. We will be searching a list of lists, so will need to adapt linear search to use double indexing to get at the data within each sublist.
Because the data is sorted by game title, we can use binary search to very quickly locate a particular game. However, game titles can be somewhat long or may include a subtitle. Additionally, the data may contain multiple copies of the same game, if it was released for different consoles under the same name.
For example, there were apparently 16 "LEGO" games released on 5 different consoles.
First write a binary search function that searches for a partial match to a game title and returns the index of the first match that it finds (or -1 otherwise). Make sure your binary search function uses startswith (see here) rather than == so it doesn’t miss any partial matches (e.g. using "LEGO" to match on "LEGO Star Wars: The Complete Saga").
However, there might be more matches that are just before or just after that initial index you locate. So next you’ll need to search in the vicinity of that location to find all of the other potential matches.
We have conveniently provided you with a function to help with finding nearby matches based on an initial seed. This is called lookForwardBackward() and you can import it from the cs21s21 library. This function takes four parameters and returns a list of matching items that it found looking either forward or backwards. Those parameters are:
• A list with the data to search over
• An integer where the search should start from (this is the index that your "binary search" function will return)
• The partial match (string) that the function should be searching for (e.g. "LEGO" in the above example)
• A search direction. This is an integer which should have the value 1 (to search forward) or -1 (to search backwards)
You will need to import the function at the top of the program (from cs21s21 import lookForwardBackward) and call it twice for each binary search (once to get the forward matches and again to get the backward matches).
A call to the lookForwardBackward() function might look something like this:
backwardMatches = lookForwardBackward(currData, currIndex, title, -1)
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme