Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Loapo Ohyeah and her team are competing in a speed skating relay race having n race segments, where each race segment has integer length.
Loapo Ohyeah and her team are competing in a speed skating relay race having n race segments, where each race segment has integer length. Loapo will skate exactly two of the race segments, and she needs to choose which ones to skate. In the interest of pacing, Loapo wants her pair of race segments to be evenly uneven: specifically, she wants one of her two race segments to be exactly four times the length of the other. (a) [8 points] Given the list of race segments in the relay, describe an expected O(n)-time algorithm to find an evenly uneven pair, or return that no such pair exists. (b) [8 points] If the length of every race segment is less than n, describe a worst-case O(n)-time algorithm to find an evenly uneven pair, or return that no such pair exists.
Step by Step Solution
★★★★★
3.49 Rating (166 Votes )
There are 3 Steps involved in it
Step: 1
a To find an evenly uneven pair of race segments in Ontime we can use a hash set to keep track of th...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started