Need Help ?

Home / Expert Answers / Computer Science / the-purpose-of-this-problem-set-is-to-gain-familiarity-with-heaps-and-priority-queues-the-internet-m-q-207

(Solved): The purpose of this problem set is to gain familiarity with heaps and priority queues. The Internet Movie Database lhttp: //www. imdb. com) is an online database of information related to movies, tv ...



The purpose of this problem set is to gain familiarity with heaps and priority queues.

The Internet Movie Database lhttp: //www. imdb. com) is an online database of information related to movies, tv programs, and videos. You can download plain text data files; directions are atIhttp: //wry. imdb. com/interf aces Please read the statement about restrictions on use of the data.

In this exercise we will work with movie ratings. I have used the files ti­tle.basics.tsv and title.ratings.tsv to produce the file ratings.tsv, which contains one line of tab-separated values for each movie that has been rated. The first five lines (of 254,566) of the file are:

56

5.9

Miss Jerry

41

6.1

Soldiers of the Cross

6

3.8

Bohemios

594

6.1

The Story of the Kelly Gang

15

4.5

Robbery Under Arms

The first value on each line is the number of ratings that the movie received, and the second value is the average score. Scores range from 1 (worst) to 10 best. After the second tab comes the title of the movie.

Write a program called MovieRanker that reads in the data in ratings.tsv and responds to queries of the following form. The user inputs two integers, say k and m, with 0 < k < 2 x 106 and 0 < m < 105. Your program should then list, in decreasing order of rating, the m highest rated movies among those that had at least k reviews. Your program should loop, accepting input and producing lists until at least one of the input numbers is 0. After each list, it should report the time in milliseconds that it took to produce the list. A screen shot appears on the next page.

Several files are on Vocareum, in addition to ratings.tsv. The file MaxHeap.java contains an implementation of a priority queue based on a max heap. MovieR­ating.java is a class for storing a record of movie information. Finally, MovieR­anker.java contains starter code with the required input and output statements. Note:

  • Do not solve this problem by sorting the ratings list.
  • Use only data structures that have been covered in class (including notes and videos).


We have an Answer from Expert

View Expert Answer

Expert Answer


maxheap.java

import java.util.ArrayList;
import java.util.Arrays;

/** Max-heap implementation */
public class MaxHeap<E extends Comparable<E>> {
    private A...

We have an Answer from Expert

Buy This Answer $4

Place Order