lec17+18

# Now we have a clever prisoner among n prisoners he

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Now we have a clever prisoner among n prisoners. He selects the position on the ﬁrst day such that he escapes after n-1 days from the prison. What position did he select ? Let us denote the solution as Clever Prisoner Position(n,m) 18 An easier problem // The following function computes the position of the prisoner // who will be sentenced to life term when there are n prisoners // in the row and the selection-number is m public static int The_Unlucky_Position(int m, int n) { ??? } 19 An easier problem // The following function computes the position of the prisoner // who will be sentenced to life term when there are n prisoners // in the row and the selection-number is m public static int The_Unlucky_Position(int m, int n) { if(m%n==0) return n; else return m%n; } 20 A simple instance : what is Clever Prisoner Position(2,m) ? if m...
View Full Document

Ask a homework question - tutors are online