Inexact Move Function solution is incorrect.

 7 I think the solution given in the course (the one in 'cs373_unit1_19_s_Inexact-Move-Function') is incorrect, because 'overshoot' and 'undershoot' correspond to the actual direction driven. For example, instead of p[(i-U-1) % len(p)], it should be p[(i-U-sign) % len(p)], where sign is the sign of U (i.e., sign = cmp(U, 0)). That doesn't matter if U is positive, or if pOvershoot/ pUndershoot are symmetric, of course. asked 24 Feb '12, 03:29 Claus 121●1●3●3 accept rate: 0% Margarita Ma... 3.7k●4●19●48

 1 There was a nice post about this problem here - my-2-on-overshoot-undershoot answered 26 Feb '12, 01:25 Gundega ♦♦ 46.2k●70●176●316
 0 My initial suspicion was that the solution was right, but having just drawn a bunch of boxes, arrows, and numbers on my pad, I've come to the conclusion you're right! answered 24 Feb '12, 07:21 MerseyViking 525●2●6●15
 0 In this case, because pOvershoot and pUndershoot have the same probability, no matter the direction of move. For other cases in which pOvershoot and pUndershoot have different probabilities, the function has to be rewritten. :D answered 24 Feb '12, 08:22 Gustavo A. V... 994●6●12●28
 0 I am thinking that there is error in that solution. However, say we have a list with 4 elements [a,b,c,d]. And say U is 1. Lets start off with index 1 of the list. So, 1-U == 0, which will pick element 'a' which is index at 0. Now, 1-U-1 == -1, which will pick element 'd' which is indexed at -1. Finally, 1-U+1 == 1. answered 26 Feb '12, 01:19 Emeka 5●1
Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×7,340
×3,767
×151
×76
×10
×9

Asked: 24 Feb '12, 03:29

Seen: 569 times

Last updated: 28 Feb '12, 15:15