Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS ASSIGNMENT IS DONE IN MIPS. There are two sparse vectors of ten elements. One is Harry[] and another is Sally[]. Being sparse vectors, the

THIS ASSIGNMENT IS DONE IN MIPS. There are two sparse vectors of ten elements. One is Harry[] and another is Sally[]. Being sparse vectors, the first element is the year Harry or sally was in a city and the second element is a number representing a city they were in and so on fourth. So one example vector may look like so, HarryTimeline[] = {1992, 2, 1999, 3, 2002, 4, 2004, 9, 2013, 2}; (2,3,4,9,2 all being numbers that represent citities and the years they were in them are the elements before them.) The goal of this assignment is to compare the earliest time Harry and Sally were possibly in a city together and put that city in register 2. If they were not in a city together then the number register 2 should recieve -99. Thanks for any help! Below is just what the homework says.

image text in transcribed

Summary: This assignment explores the use of basic conditional execution, nested iteration, and memory accesses to analyze time/space data such as information collected by GPS-enabled applications. In particular, you will write a program that analyzes two timelines, each of which gives a history of major cities in which a person has lived in chronological order. Your program will determine the earliest point in which both people were living in the same city at the same time and report the city they had in common. Data in each timeline TL is stored as a sparse vector of ten elements in the following format: TL [1"2] = Year the person moved, for 1-0, 1,, 4 TL[i*2+1] ID of City to which the person moved, for 1-0, 1, , 4 Each year is an integer in the range 1986 to 2015, inclusive, and each city ID is an integer between 0 and 9, inclusive City: LondonBostonPAtlantaMiami TokyoMetzSeoul TorontoAustiin City ID:0 9 Assume each person has moved at most once in any given year. Also, assume that the total number of moves in each timeline is exactly five. For example, the timelines shown in Figure 1 are represented as Harry/Timeline[] {1992, 2, 1999, 3, 2002, 4, 2004, 9, 2013, 2); SallyTimeline[] = {1998, 4, 2000, 2, 2003, 4, 2005, 2, 2011, 4); For this example, your program should compute 4 as the correct answer (the common city they both lived in the earliest was Miami, city ID 4) When Harry Met Sally 86 87 88 89 90 91 92 93 94 95 96 97 98 99 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 H: Paris Miami Austin Paris Miami Paris Miami Paris Figure 1: Timelines showing when Harry and Sally lived in certain cites. The earliest year in which they both lived in the same city is 2003 (when Sally moved to Miami (ID: 4) where Harry is already living) Note that this sparse vector representation is much more storage efficient than storing the city ID for each time point in the range 1986-2015

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago