Click here to Skip to main content
15,887,434 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult9-Jan-12 13:15
mvePIEBALDconsult9-Jan-12 13:15 
GeneralRe: nQueens algorithm Pin
Member 419459311-Jan-12 8:25
Member 419459311-Jan-12 8:25 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult11-Jan-12 9:35
mvePIEBALDconsult11-Jan-12 9:35 
GeneralRe: nQueens algorithm Pin
Member 419459311-Jan-12 10:01
Member 419459311-Jan-12 10:01 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult11-Jan-12 10:22
mvePIEBALDconsult11-Jan-12 10:22 
GeneralRe: nQueens algorithm Pin
Member 419459311-Jan-12 10:42
Member 419459311-Jan-12 10:42 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult11-Jan-12 11:16
mvePIEBALDconsult11-Jan-12 11:16 
QuestionTuring Machine Simulator witch greedy algorithm Pin
nasser moradbeiki27-Dec-11 2:59
nasser moradbeiki27-Dec-11 2:59 
Turing Machine Simulator
Write a program that simulates a Turing machine (Tm). A Tm is a primitive model of a general purpose computer. Programs for a Tm consist of a collection of quadruples, each of the following form:

<state> <symbol> <action> <nextstate>

where

<state> ::= a non-negative integer
<symbol> ::= 1 | B
<action> ::= <symbol> | L | R
<nextstate> ::= a non-negative integer

A Tm stores data on a tape divided into squares, each of which contains one symbol, either 1 or B. Only one square can be inspected at a time. Initially, a sequence of symbols is written on the tape (this is the input to the Tm), the Tm's "read/write head" is positioned over the leftmost symbol, and the state of the Tm is set to some "start state".

At any point in a Tm computation, the Tm is in a particular state with its read/write head scanning the symbol in a particular square. What happens next depends on whether the Tm's program contains a quadruple whose <state> is the Tm's current state and whose <symbol> is the symbol contained in the square currently being scanned. If such a quadruple exists (there cannot be more than one such), the <action> part of this quadruple controls what happens next:

if <action> specifies a symbol, then that symbol replaces whatever symbol is in the square currently under scan
if <action> is L, the Tm's read/write head is moved one square to the left (the symbol in the square previously under scan is not changed)
if <action> is R, the Tm's read/write head is moved one square to the right (the symbol in the square previously under scan is not changed)
After one of the above actions is done, the Tm changes to state <nextstate> and we repeat the process of searching for an appropriate quadruple to "execute". This is continued until no quadruple matches the current state and symbol under scan, in which case the Tm halts and we consider its output to be the sequence of symbols between the first and last 1's on the tape, inclusive (if no 1's remain, we consider the output to be just B).

The input is a sequence of Tm instruction quadruples followed by a "start" line that specifies the initial state for the Tm, followed by the sequence of symbols that make up the initial value stored on the Tm's tape. Generically:

<state> <symbol> <action> <nextstate>
<state> <symbol> <action> <nextstate>
<state> <symbol> <action> <nextstate>
<state> <symbol> <action> <nextstate>
...
start <state>
<symbol>
<symbol>
<symbol>
<symbol>
<symbol>
...

For example:

0 1 R 0
0 B 1 1
start 0
1
1
1
1

Given the above input, the output should be:

11111

Note
If a quadruple requires moving left from the leftmost symbol on the tape, or right from the rightmost symbol, a square containing the symbol B must be added to the appropriate end of the tape (which is thus "finite, but unbounded")
AnswerRe: Turing Machine Simulator witch greedy algorithm Pin
Richard MacCutchan27-Dec-11 4:49
mveRichard MacCutchan27-Dec-11 4:49 
AnswerRe: Turing Machine Simulator witch greedy algorithm Pin
PIEBALDconsult30-Dec-11 8:33
mvePIEBALDconsult30-Dec-11 8:33 
QuestionIs "Day.Month DayOfWeek" an Unique Date Time? Pin
Henning Dieterichs22-Dec-11 12:02
Henning Dieterichs22-Dec-11 12:02 
AnswerRe: Is "Day.Month DayOfWeek" an Unique Date Time? Pin
Luc Pattyn22-Dec-11 12:18
sitebuilderLuc Pattyn22-Dec-11 12:18 
GeneralA more effective way to find the number of points with a given distance between them on a line? Pin
Erik Rude19-Dec-11 22:32
Erik Rude19-Dec-11 22:32 
GeneralRe: A more effective way to find the number of points with a given distance between them on a line? Pin
Richard Andrew x6420-Dec-11 6:49
professionalRichard Andrew x6420-Dec-11 6:49 
GeneralRe: A more effective way to find the number of points with a given distance between them on a line? Pin
IdUnknown21-Dec-11 6:39
IdUnknown21-Dec-11 6:39 
AnswerRe: A more effective way to find the number of points with a given distance between them on a line? Pin
Luc Pattyn21-Dec-11 8:23
sitebuilderLuc Pattyn21-Dec-11 8:23 
GeneralWholesale Sources Pin
Andrew Dudley16-Dec-11 19:46
Andrew Dudley16-Dec-11 19:46 
NewsDiscover How FX Brokers Can Earn On Forex Trading Pin
forex platform30-Nov-11 21:09
forex platform30-Nov-11 21:09 
QuestionDirichlet problem for the unit circle code Pin
Chesnokov Yuriy27-Nov-11 17:19
professionalChesnokov Yuriy27-Nov-11 17:19 
AnswerRe: Dirichlet problem for the unit circle code Pin
Roger Wright9-Dec-11 4:03
professionalRoger Wright9-Dec-11 4:03 
QuestionSafely storing passwords Pin
Bernhard Hiller15-Nov-11 20:55
Bernhard Hiller15-Nov-11 20:55 
AnswerRe: Safely storing passwords Pin
Alan Balkany22-Nov-11 4:06
Alan Balkany22-Nov-11 4:06 
AnswerRe: Safely storing passwords Pin
canlel9-Dec-11 0:08
canlel9-Dec-11 0:08 
AnswerRe: Safely storing passwords Pin
OriginalGriff9-Dec-11 1:06
mveOriginalGriff9-Dec-11 1:06 
QuestionLearning software design patterns Pin
Hypermommy9-Nov-11 22:26
Hypermommy9-Nov-11 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.