Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

7040 shawnee romulus mi 48174

18/11/2021 Client: muhammad11 Deadline: 2 Day

Computer Science Homework

1. Purpose

The purpose of this assignment is to implement sorting algorithms for the autocomplete application. 2. 2.Description

Write a program to implement autocomplete for a given set of N terms, where a term is a query string and an associated nonnegative weight. That is, given a prefix, find all queries that start with the given prefix, in descending order of weight.

Autocomplete is pervasive in modern applications. As the user types, the program predicts the complete query (typically a word or phrase) that the user intends to type. Autocomplete is most effective when there are a limited number of likely queries. For example, the Internet Movie Database uses it to display the names of movies as the user types; search engines use it to display suggestions as the user enters web search queries; cell phones use it to speed up text input.

CPS 350: Assignment 3 Due 11:55 pm, Wednesday, 3/15/2017 (200 pts)

This is a team project. At most two students are in one team

No late submission will be accepted

Receive 5 bonus points if turn in the complete work without errors at least one day before deadline

Receive an F for this course if any academic dishonesty occurs

1. Purpose The purpose of this assignment is to implement sorting algorithms for the autocomplete

application.

2. Description

Write a program to implement autocomplete for a given set of N terms, where a term

is a query string and an associated nonnegative weight. That is, given a prefix, find all

queries that start with the given prefix, in descending order of weight.

Autocomplete is pervasive in modern applications. As the user types, the program

predicts the complete query (typically a word or phrase) that the user intends to type.

Autocomplete is most effective when there are a limited number of likely queries. For

example, the Internet Movie Database uses it to display the names of movies as the

user types; search engines use it to display suggestions as the user enters web search

queries; cell phones use it to speed up text input.

In these examples, the application predicts how likely it is that the user is typing each

query and presents to the user a list of the top-matching queries, in descending order

of weight. These weights are determined by historical data, such as box office revenue

for movies, frequencies of search queries from other Google users, or the typing

history of a cell phone user. For the purposes of this assignment, you will have access

to a set of all possible queries and associated weights (and these queries and weights

will not change).

The performance of autocomplete functionality is critical in many systems. For

example, consider a search engine which runs an autocomplete application on a server

2

2

farm. According to one study, the application has only about 50ms to return a list of

suggestions for it to be useful to the user. Moreover, in principle, it must perform this

computation for every keystroke typed into the search bar and for every user!

In this assignment, you will implement autocomplete by sorting the terms by query

string (with running time O(N log N) in sorting, or even better, where N is the of

terms); binary searching to find all query strings that start with a given prefix (with

running time O(log N)); and sorting the matching terms by weight (with running time

O(M log M) in sorting, where M is the number of matching terms). Finally display

results for the user. The following shows the top seven queries (city names) that start

with AI M with weights equal to their populations.

2.1. Part 1: autocomplete term (60 pts)

Write an immutable data type Term.java that represents an autocomplete term: a query

string and an associated integer weight. You must implement the following API,

which supports comparing terms by three different orders: lexicographic order by

query string (the natural order); in descending order by weight (an alternate order);

and lexicographic order by query string but using only the first r characters (a family

of alternate orderings). The last order may seem a bit odd, but you will use it in Part

3 to find all query strings that start with a given prefix (of length r).

public class Term implements Comparable {

/* Initializes a term with the given query string and weight. */

public Term(String query, long weight)

/* Compares the two terms in descending order by weight. */

public static Comparator byReverseWeightOrder()

/* Compares the two terms in lexicographic order but using only the first

r characters of each query. */

public static Comparator byPrefixOrder(int r)

/* Compares the two terms in lexicographic order by query. */

public int compareTo(Term that)

3

3

// Returns a string representation of this term in the following format:

// weight (i.e., ??.toString()), followed by a tab, followed by query.

public String toString()

}

Corner cases. The constructor should throw

a java.lang.NullPointerException if query is null and

a java.lang.IllegalArgumentException if weight is negative.

The byPrefixOrder() method should throw

a java.lang.IllegalArgumentException if r is negative.

Performance requirements. The string comparison functions should take time

proportional to the number of characters needed to resolve the comparison.

2.2. Part 2: binary search (30 pts)

When binary searching a sorted array that contains more than one key equal to the

search key, the client may want to know the index of either the first or the last such

key. Accordingly, implement the following API:

public class BinarySearchDeluxe {

/* Returns the index of the first key in a[] that equals the search key,

or -1 if no such key. */

public static int firstIndexOf(Key[] a, Key key, Comparator

comparator)

/* Returns the index of the last key in a[] that equals the search key,

or -1 if no such key. */

public static int lastIndexOf(Key[] a, Key key, Comparator

comparator)

}

Corner cases. Each static method should throw a java.lang.NullPointerException if

any of its arguments is null. You should assume that the argument array is in sorted

order (with respect to the supplied comparator).

Performance requirements. The firstIndexOf() and lastIndexOf() methods should

make at most 1 + ⌈log2 N⌉ compares in the worst case, where N is the length of the

array. In this context, a compare is one call to comparator.compare().

2.3. Part 3: autocomplete (70 pts)

In this part, you will implement a data type that provides autocomplete functionality

for a given set of string and weights, using Term and BinarySearchDeluxe. To do

so, sort the terms in lexicographic order; use binary search to find the all query strings

4

4

that start with a given prefix; and sort the matching terms in descending order by

weight. Organize your program by creating an data type Autocomplete with the

following API:

public class Autocomplete { // implement sorting algorithm in this class

/* Initializes the data structure from the given array of terms. */

public Autocomplete(Term[] terms)

/* Returns all terms that start with the given prefix, in descending

order of weight. */

public Term[] allMatches(String prefix)

}

Corner cases. The constructor should throw a java.lang.NullPointerException if its

argument is null or if any of the entries in its argument array are null. Each method

should throw a java.lang.NullPointerException if its argument is null.

Performance requirements. The constructor should make proportional

to N log N compares (or better) in the worst case, where N is the number of terms.

The allMatches() method should make proportional to log N + M log M compares (or

better) in the worst case, where M is the number of matching terms. In this context,

a compare is one call to any of the compare()or compareTo() methods defined in Term.

2.4. Input format for testing (30 pts)

We provide a number of sample input files for testing. Each file consists of an

integer N followed by N pairs of query strings and nonnegative weights. There is one

pair per line, with the weight and string separated by a tab. A weight can be any

integer between 0 and 2^63 − 1. A query string can be an arbitrary sequence of

Unicode characters, including spaces (but not newlines).

• The file wiktionary.txt contains the 10,000 most common words in Project

Gutenberg, with weights proportional to their frequencies.

• The file cities.txt contains over 90,000 cities, with weights equal to their

populations.

% more wiktionary.txt

10000

5627187200 the

3395006400 of

2994418400 and

2595609600 to

1742063600 in

1176479700 i

1107331800 that

1007824500 was

% more cities.txt

93827

14608512 Shanghai, China

13076300 Buenos Aires, Argentina

12691836 Mumbai, India

12294193 Mexico City, Distrito Federal, Mexico

11624219 Karachi, Pakistan

11174257 İstanbul, Turkey

10927986 Delhi, India

10444527 Manila, Philippines

5

5

879975500 his

...

392323 calves

10381222 Moscow, Russia

...

2 Al Khāniq, Yemen

Below is a sample client that takes the name of an input file and an integer k as

command-line arguments. It reads the data from the file; then it repeatedly reads

autocomplete queries from standard input, and prints out the top k matching terms in

descending order of weight. public static void main(String[] args) {

// read in the terms from a file

String filename = args[0]; // first argument from command line

In in = new In(filename);

int N = in.readInt();

Term[] terms = new Term[N];

for (int i = 0; i < N; i++) {

long weight = in.readLong(); // read the next weight

in.readChar(); // scan past the tab

String query = in.readLine(); // read the next query

terms[i] = new Term(query, weight); // construct the term

}

// read in queries from standard input and print the top k matching terms

int k = Integer.parseInt(args[1]); // 2nd argument from command line

Autocomplete autocomplete = new Autocomplete(terms);

while (StdIn.hasNextLine()) {

String prefix = StdIn.readLine();

Term[] results = autocomplete.allMatches(prefix);

for (int i = 0; i < Math.min(k, results.length); i++)

System.out.println(results[i]);

}

}

Here are a few sample executions: % java Autocomplete wiktionary.txt 5

auto

619695 automobile

424997 automatic

comp

13315900 company

7803980 complete

6038490 companion

5205030 completely

4481770 comply

the

5627187200 the

334039800 they

282026500 their

250991700 them

196120000 there

% java Autocomplete cities.txt 7

M

12691836 Mumbai, India

12294193 Mexico City, Distrito

Federal, Mexico

10444527 Manila, Philippines

10381222 Moscow, Russia

3730206 Melbourne, Victoria,

Australia

3268513 Montréal, Quebec, Canada

3255944 Madrid, Spain

Al M

431052 Al Maḩallah al Kubrá, Egypt

420195 Al Manşūrah, Egypt

290802 Al Mubarraz, Saudi Arabia

258132 Al Mukallā, Yemen

227150 Al Minyā, Egypt

128297 Al Manāqil, Sudan

99357 Al Maţarīyah, Egypt

first argument 2nd argument

defined in In.java, to read data from files and URLs

defined in StdIn.java, to read data from keyboard

6

6

Interactive GUI (optional, but fun and no extra work): Compile AutocompleteGUI.java. The program takes the name of a file and an

integer k as command-line arguments and provides a GUI for the user to enter queries.

It presents the top k matching terms in real time. When the user selects a term, the

GUI opens up the results from a Google search for that term in a browser.

% java AutocompleteGUI cities.txt 7

3. �������������� If your program does not compile, you receive zero points for that program. Additional

deductions:

1. (5 points) Your code does not follow the style guide discussed in class/textbook. 2. (30 points) Your code does not have author name, date, purpose of this program,

comments on the variables and methods, etc.

4. �������

One submission for a team. Zip/submit your entire project,

including Autocomplete.java, BinarySearchDeluxe.java, and Term.java. You may

NOT call any library functions other than those in java.lang and java.util. Finally,

submit a report file (10 points) and answer the following questions:

a) Known bugs limitations of this assignment. b) Describe any serious problems you encountered. c) List any other comments here. Feel free to provide any feedback on how much you

learned from doing the assignment, and whether you enjoyed doing it.

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Premium Solutions
Ideas & Innovations
Engineering Exam Guru
Top Grade Essay
Math Specialist
Solution Provider
Writer Writer Name Offer Chat
Premium Solutions

ONLINE

Premium Solutions

As per my knowledge I can assist you in writing a perfect Planning, Marketing Research, Business Pitches, Business Proposals, Business Feasibility Reports and Content within your given deadline and budget.

$47 Chat With Writer
Ideas & Innovations

ONLINE

Ideas & Innovations

As per my knowledge I can assist you in writing a perfect Planning, Marketing Research, Business Pitches, Business Proposals, Business Feasibility Reports and Content within your given deadline and budget.

$48 Chat With Writer
Engineering Exam Guru

ONLINE

Engineering Exam Guru

I am a professional and experienced writer and I have written research reports, proposals, essays, thesis and dissertations on a variety of topics.

$43 Chat With Writer
Top Grade Essay

ONLINE

Top Grade Essay

I am an elite class writer with more than 6 years of experience as an academic writer. I will provide you the 100 percent original and plagiarism-free content.

$27 Chat With Writer
Math Specialist

ONLINE

Math Specialist

I will be delighted to work on your project. As an experienced writer, I can provide you top quality, well researched, concise and error-free work within your provided deadline at very reasonable prices.

$20 Chat With Writer
Solution Provider

ONLINE

Solution Provider

I have written research reports, assignments, thesis, research proposals, and dissertations for different level students and on different subjects.

$29 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Carescape monitor b450 user manual - The rape of europa video - En 1363 1 fire resistance tests - Discussion - Write a five paragraph essay analyzing the influence frankenstein - Managerial Accounting: PA2 - Fanuc lr mate 200ib manual - Nsw rfs core values - Banc one corporation - asset liablity managemnet- a case study by harvard business school - Process capability ppt download - Discussion - Does carlos from desperate housewives stay blind - English - Constitutional law 14th edition jacqueline kanovitz pdf - Hockley valley brewing co inc case study - Physics lab #5 due today only physics expert contact me - Probability and statistical inference 9th edition pdf hogg - Tools of the trade diablo 2 - Discussion - George mason roller pigeons - Coke's european scare case study - How to tell if a sugar is reducing or nonreducing - Case 13.1 tree trimming project - Prairie view a&m scholarships - Organizational Policies and Practices to Support Healthcare Issues - Discussion Question 1 week 5 - North rocks child care centre - Order 2463651: Collaborative teams - Far Off Merciful: Investigating the Role of Remote Assistants in Transforming Healthcare - Gresham real estate fund - What did noblemen wear in ancient egypt - 9 types of intelligence ppt - Cornerstone parking - rbwh herston road - Halliburton australia pty ltd perth - Bmw currency hedging 2007 case solution - MM_ Service Marketing Report - How to calculate fte for 12 hour shifts - What pricing strategy does kohls use - Looking at movies 5th edition chapter 1 - What is s8 medication - Hku science honours classification - Chalk and wire saint leo - A beggar's brother died riddle - Clinical learning environment review - Why managers are dejobbing their companies - A student pipets 5.00 ml of ethanol - Str 581 week 6 strategic plan and presentation - World population clock poodwaddle non inverting summing amplifier - Warman international ltd v dwyer summary - International Marketing Research - Australian ot competency standards - Visibility of system status - Custom molds inc case study answers - Concrete noun examples in sentences - 1 u 1 v 1 f graph - Freshwater algae identification and use as bioindicators - Develop recommendations that will meet the needs of your new team and align with your organization’s mission, vision, culture statement, and goals. - Bsa nuclear science merit badge - Key components in collaboration and consultations - The virtual evolution stickleback lab answers - Unrelated diversification strategy company examples - Ipswitch ftp server download - All my sons ppt - Normal and nonnormal cash flows - What problems and challenges did home depot experience - Https www youtube com watch v kudhiats36a - Starbucks mission social responsibility and brand strength case study - How much stomach acid can be neutralized by an antacid - Net price equivalent rate of 9 15 18 - Hair jewelry margaret atwood summary - Protestant reformation multiple choice questions - Community Health Case 4 - Cafs hsc past papers - Messenger of peace registration - Zitkala sa impressions of an indian childhood - How sdn and ibn are related - How to find final temperature using specific heat - The yellow wallpaper active reading chart answers - Essay about korean woman history - Campanelli freshface set of 6 home and away towels - Complaints officer job description - Fish kill mystery case study answers - Ethical issues in health professional - St george portfolio loan - Write in 500 words the disaster recovery plan and who is responsible at your place of employment. Consider the critical business functions and your recovery point objectives and recovery time objectives. - Tanita wellness evaluation form - OPS/571T - Conventions of a narrative - Melzer v board of education - Which of the following statements about biodegradable polymers is true - 63.6 kg in lbs - Coca cola dividend payout ratio - Compiler assignment - Mcpherson community residential service - Yugo 45 lyrics - Paper - Tinkercad for 3d printing - Simpson taxonomy of psychomotor domain - Essay 3 - Nutshell studies official solutions