Click here to Skip to main content
15,920,801 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Can you do this with a convex hull? Pin
Kyudos16-Feb-12 15:31
Kyudos16-Feb-12 15:31 
GeneralRe: Can you do this with a convex hull? Pin
BobJanova17-Feb-12 0:36
BobJanova17-Feb-12 0:36 
Questionwordwrap with minimum raggedness Pin
Member 858607226-Jan-12 10:09
Member 858607226-Jan-12 10:09 
AnswerCrosspost Pin
Peter_in_278026-Jan-12 11:37
professionalPeter_in_278026-Jan-12 11:37 
QuestionA type of balanced 0–1 matrix Pin
Member 858607221-Jan-12 8:01
Member 858607221-Jan-12 8:01 
AnswerRe: A type of balanced 0–1 matrix Pin
Alan Balkany16-Feb-12 4:08
Alan Balkany16-Feb-12 4:08 
Questioninput Pin
AsadRana21-Jan-12 1:27
AsadRana21-Jan-12 1:27 
AnswerRe: input Pin
Richard MacCutchan21-Jan-12 2:34
mveRichard MacCutchan21-Jan-12 2:34 
AnswerRe: input Pin
BillWoodruff29-Jan-12 13:08
professionalBillWoodruff29-Jan-12 13:08 
QuestionnQueens algorithm Pin
PIEBALDconsult31-Dec-11 4:02
mvePIEBALDconsult31-Dec-11 4:02 
AnswerRe: nQueens algorithm Pin
DaveAuld31-Dec-11 4:49
professionalDaveAuld31-Dec-11 4:49 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult31-Dec-11 15:08
mvePIEBALDconsult31-Dec-11 15:08 
GeneralRe: nQueens algorithm Pin
Member 41945931-Jan-12 13:20
Member 41945931-Jan-12 13:20 
GeneralRe: nQueens algorithm Pin
PIEBALDconsult1-Jan-12 16:14
mvePIEBALDconsult1-Jan-12 16:14 
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 

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.