Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

THIS ASSIGNMENT IS DONE IN C. 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 an integer called City. If they were not in a city together then the number -99 should be in City. Thanks for any help! Below is just what the homework says. Please try to keep it simpler without creating functions to do tasks since we have not gotten that far. Also I am only able to use the libraries #include and #include

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 For this assignment, you will write two programs, one in C and one in MIPS, as described below You should design, implement, and test your own code. Any submitted project containing code not fully created and debugged by the student constitutes academic misconduct. HW2-1: For this part, design and implement a C program to determine when Harry and Sally first resided in the same city and print the ID of that city. If there is no time in which they are both in the same city, print -99

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago