Download presentation

Presentation is loading. Please wait.

Published byGrace Wolf Modified over 2 years ago

1
Senior Q2 Shy Tortoise

2
Sample >>> ><> <><> <><>> >> 13431

3
Statistic Max : 60 Min : 0 Mean : 30 Surprisingly no one get full mark, or even 75%.

4
Simulation 30% while not in order find first ‘<‘, say s[i] ++count[i – 1] ++count[i] swap(s[i – 1], s[i]) A lot of work is done repeatedly (find first ‘<‘).

5
Simulation 50% (Mode) while not in order t = s for each ‘ ’ set t[i – 1] = ‘ ’ ++count[i – 1] ++count[i] s = t

6
Finding direction only - 50% Key observation: number of ‘>’/’ ’. count total number of ‘ ’

7
75% Combine the two 50% solution. Simulation is too slow but is able to count. Counting is fast but unable to count. if n <= 5000 simulation else counting

8
Full solution Consider tortoise ending with ‘<‘. Observation: the tortoise need to turn around only if its left have some ‘>’. More, each ‘>’ contributes 2 turns.

9
Full solution (cont.) e.g. >>><< Consider the second tortoise. It needs 1 turn to make it correct. A ‘>’ in its left contributes 2 more turns. Thus count[2] = 3.

10
Full solution (cont.) set left[1] = 0 for i = 2 to n if s[i – 1] = ‘>’ left[i] = left[i – 1] + 1 else left[i] = left[i – 1] for i = 1 to n count[i] = 2*left[i] if s[i] = ‘>’ ++count[i]

Similar presentations

OK

Two topics in R: Simulation and goodness-of-fit HWU - GS.

Two topics in R: Simulation and goodness-of-fit HWU - GS.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on circuit breaker switching and arc modeling Ppt on asian continents Ppt on social contract theory definition Ppt on mars one astronaut Ppt on mobile and wireless networks Ppt on limits and continuity quiz Ppt on index numbers line Ppt on cross docking pictures Ppt on water resources management Ppt on nursing management of spinal cord injury