You are here

Search form

Navigation

Searching the IMDb Dataset

Implement a Binary Search Tree (BST) based index for indexing/searching actors or movies in the IMDb dataset with the following characteristics:

Your implementation should allow the user to quickly find information associated with an actor, or a movie, based on the actor's or movie's name (e.g., "Arnold Schwarzenegger"), or a prefix of a name (e.g. "Arnold Schwarz*").

The search should be case insensitive (e.g., "arnold schwarz*" should also work.

The search key is the short or simplified name of a movie or actor.

The information associated with the key should be of type MovieInfo defined below:

The BST index should be implemented as a stand-alone class named BSTIndex, having at least the public methods listed below (you may add as many additional private helper methods as needed). You will need to define a Node class within the BSTIndex class that contains 4 fields: key (of String type), data (of MovieInfo type), and left & right references to the children nodes.

public BSTIndex() : a constructor to initialize the BST. The data element should be an object of type MovieInfo as described above.

public MovieInfo findExact(String key) : returns the data MovieInfo element where the shortName matches the key exactly (although possibly with different capitalization).

public MovieInfo findPrefix (String prefix) : returns the data element MovieInfo where the shortName starts with the prefix (and possibly has different capitalization).

public void insert(MovieInfo data) : insert the given data element into the proper place in the BST structure.

You can use the IndexTester class provided below to test your BSTIndex class. When executed, this class creates an empty BSTIndex object (using the constructor of the BSTIndex class), reads the data from an input movie or actor file, builds a MovieInfo object for each row, and inserts it into the BST index (using the insert() method of insert BSTIndex class). At this point, the BST index is built for all the movie or actor entries in the file. It will then ask for a search string from user and search for the MovieInfo object associated with the name, testing the search functionality of your BSTIndex class (using its findExact or findPrefix methods).

To test your code with the IndexTester class, you will need to provide it the name of a dataset file to index. You can use any of the following IMDB datasets to this end. Note the full data files (i.e., actors.txt and movies.txt) are relatively large. You will likely wish to use the smaller datasets (actors100K.txt and movies100K.txt) for debugging. All of the files are in the same format: one actor or movie per line, with fields: ID, shortName, fullName separated by a tab character ("\t"). Read the IndexTester to remind yourself how to read this data.