I am currently learning about the concept of Turing Machines and trying to relate it with my knowledge on the application of the Binary Search algorithm.
The problem I am working on is to write an algorithm that can find an unknown natural number between two given natural numbers by guessing.
A solution would look like the following code in JavaScript.
// fixed structure "generateAsk" is always provided to the problem
let generateAsk = function() {
let guess = window.prompt("Guess: ");
return function(x) {
return ((x < guess) && "<") || ((x > guess) && ">") || "="
};
};
let ask = generateAsk();
let low = window.prompt("Low: ")
, high = window.prompt("High: ");
function find_unknown_number(low, high, ask) {
// uses Binary Search to search the unknown value
// and returns the unknown value when found or -1 otherwise
}
let result = find_unknown_number(low, high, ask)
console.log(result);
My question is not meant to ask for how to solve this problem, but to ask the practical use of any algorithm that can be introduced above.
To be clearer, as I know, mostly any program can be debugged. Isn't anyone able to just stop the program written above, during its execution, with a debugger and then just filter the body of the "ask" function parameter and extract the unknown value?
The way my question is related to the Turing Machines is that, for what I know, the Turing Machines receive input on a tape (so any character introduced on the tape may very well be "visible" from the outside during any execution phase of the algorithm).
Therefore, the questions that I present to you are:
How the implementation of a solution to this problem on a Turing Machine would not be pointless from the perspective in which one can stop the program, read the "ask" function body by reading the corresponding tokens on the Turing Machine and then return the "unknown" value?
Is there any concept of "privacy" of tokens in the world of Turing Machines or some structure that can be used to implement "privacy" in some specific tokens written on a Turing Machine?
ask
be an oracle TM $A$, in which casefind_unknown_number
would be represented by a TM $F$ relative toask
. So theguess
is not in the input tape of $F$, since it is inside the oracle $A$. There are other natural extensions of the TM model to support encrypted tapes, but oracle TMs are clearly the right way the view this guess-number problem. $\endgroup$