Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 2 of the program Part 1 ..11 Virgin 11:45 AM 76%- X Comp_285_Programming_As

ID: 3749732 • Letter: P

Question



Part 2 of the program Part 1 ..11 Virgin 11:45 AM 76%- X Comp_285_Programming_Assignm... Copider comparing a new elst's raaking to an existing cliest's ranking of the same set of n movies. A strwight-forward approech would label the movies from 1 to n accoeding to the seW elient's ranking, thee oeder these lahels aceording to the existing cliest's rankings. We could the examine the latter to se how many pairs of indices in the array are "out of order Generically rotoakr being prrn awqwsare of n mmlers aa-.… whwre all a, arr ditinct. We need to define a mmsure that qeantifios howr far this list is from being in ascending oeder To create our measure, we are going rakulate the "edit distance between our two rankings An edit distance is a metric ed in satural langugn proonwing to quantify how dissimilar two Programming Assignment #1: September 19, 2018 11:09pm strings are by counting the number of operations ed to transfoem one string into anos. For our problem, we are going to cound the uer of instanos wee the olkwing situation holl (b) a where iand j are indexes in an array. 1n other words,se iacremM our edit distance if our sew ranking flipped the order in which we coounter two movies. To get a feel for this, €onsider the following one: 2. 4, 1, 3,5 Our colit distancv wuuld be '3' the filming Eqpnd mrin: (2,1), (4.1), ud (4,3). W a RtItaetice is in complete agresaat , tbr coat distance is 0; wxu a srPtxe im cutupkte di- Part 1: Implement the Brute Force Algorithm [15 points Your intial thougle to solve this is peetty straiglt-orwaed You are to inmpeut a beube force algreithm that solves the peolslem. You have been provided a skreton file called BruteForce.ja It his a method mamed seasur EaitDistance which has am artay cald rankinge[ its p eter. The sequetacrof integets stored in rankings[] e iuitinlined outside this clam; do sed chengt t&e anpat &locks inside Sour seaaureEditDiatabce method. The brute tee·lgrithm works in the following way Examine every pair of intors in thesequence and determine if the moos are pped If they are, inceemest the edit distse Your method should terminste by returning the edit distance. We have erested a esber varinble for yoer seasur EditDistance method called editDiataace that you may ue througlout the method (but you doe't have to) Part 2: A Divide and Conquer Algorithm points Sinee yoe've taken on ngeithms class you psse before handing the peogram over to your at Neix. Yon realize that you've just produeed an iterstive algorithm, and that messs there might be a chaace to improre on your rm-time. In fact, you staut to see that this peoblem lesls itself well to a divide-and-coequer approach You decide to Implemest a new alzorithm emploing this desiga paraddigm The basik iea follows the stratezy of MERGESoRT diseussed in class We define an index e and divide the list of rankings into two pieces 1.. '-4-and am-1 We recundvely find the edit distance for these two halve. Then w ncrement the edit a?' The easiest way to find this out is to actually sat the list a" you go. Open With Print

Explanation / Answer

Below is the required code:

If you have any doubt then please let me know by putting your question in comment section.