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

Algorithms

 
Questionneed help with number base conversion algorithm for computers Pin
mickcs4-Nov-15 10:14
mickcs4-Nov-15 10:14 
AnswerRe: need help with number base conversion algorithm for computers Pin
Richard Andrew x644-Nov-15 10:36
professionalRichard Andrew x644-Nov-15 10:36 
AnswerRe: need help with number base conversion algorithm for computers Pin
Patrice T4-Nov-15 14:55
mvePatrice T4-Nov-15 14:55 
QuestionFeistel Cipher Algorithm: Problems aim to solve Pin
Ka Mal31-Oct-15 15:07
Ka Mal31-Oct-15 15:07 
AnswerRe: Feistel Cipher Algorithm: Problems aim to solve Pin
Richard MacCutchan31-Oct-15 21:41
mveRichard MacCutchan31-Oct-15 21:41 
GeneralRe: Feistel Cipher Algorithm: Problems aim to solve Pin
Richard Deeming2-Nov-15 1:50
mveRichard Deeming2-Nov-15 1:50 
GeneralRe: Feistel Cipher Algorithm: Problems aim to solve Pin
Richard MacCutchan2-Nov-15 1:59
mveRichard MacCutchan2-Nov-15 1:59 
Questionanalysis of boolean table to optimize code ? Pin
BillWoodruff30-Oct-15 22:59
professionalBillWoodruff30-Oct-15 22:59 
Recently, a question on QA here about implementing a Rock-Scissors-Paper (RSP) game [^], to which I responded, left me with a curiosity to see how efficiently/tersely I could implement the possible analysis of the result of game play.

Which got me interested in the more general question of how, given a complex matrix of values and criteria which can be expressed in typical De Morgan table form can be ... possibly ... analyzed by code in such a way that either an optimal implementation of the matrix (code-generation) is generated, or, some set of heuristics is generated that the programmer can interpret and use to write optimized code.

To use the RSP possible outcomes as a simple example, and excluding the obvious condition that if two "players" select the same "object," the game is a tie:
C#
assume 0 => Rock , 1 => Scissors, 2 => Paper

0 1 true   ... rock breaks scissors => player1 wins
1 2 true
2 0 true

0 2 false   ... paper covers rock => player1 loses
1 0 false
2 1 false
Of course, it's straightforward to write a simple switch statement, or if/else/ chain to "solve" this.

"Eyeballing" such a table, and looking for "patterns" in the outcomes, the mind may naturally think about various boolean operations like XOR, or using modulo some number, looking for "heuristics;" look for "threshold" values that can "prune" the possible comparison matrix.

Looking further than this simple example, one can think about the complexity of an airfare reservations system where there might be twenty different factors resulting in the selection of the final airfare price from some list of pricing levels.

And, of course, the programmer will (hopefully) have (or create somehow) some clear description of the "business rules" that describe the calculation process.

Let's say the outcome in the airfare scenario is a matrix of 1000 combinations (to be conservative). To our brains it's pretty easy to look at the criteria and use the business rules to select the criterion (like passenger Age) that may have the most "impact" on the matrix of combinations: i.e., you'd want to first "prune" the matrix by a switch statement using Age as the selector.

And, it would be logical, as you eyeball the criteria to consider those with the fewest number of "states" and use testing those in the "outer" switch statements to reduce computation.

However, an interesting complication may be that some criterion with only one, or a few states may be, in practice, rarely of predictive value: that, imho, takes you into the analysis of the criterion based on context (world-knowledge, statistics of use, etc.). I want to exclude that from this post.

Then there are the interactions of variables; in the airfare scenario a discount for early booking may not apply to the fare calculation for accompanied children between age 5~11, for example. While some variables may be inherently "binary," such as, perhaps, the need for a wheelchair, many variables may have a number of "levels," like, for example, age broken out by infant, child, teen, adult, senior.

I'm sure that Decision Table theory which has been around for so long has generated some algorithms/heuristics for analyzing complex boolean matrices and optimizing code.

Appreciate your thoughts !
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.


modified 1-Nov-15 2:33am.

AnswerRe: analysis of boolean table to optimize code ? Pin
Gerry Schmitz3-Nov-15 8:28
mveGerry Schmitz3-Nov-15 8:28 
AnswerRe: analysis of boolean table to optimize code ? Pin
Patrice T3-Nov-15 17:09
mvePatrice T3-Nov-15 17:09 
Questiongrid search Pin
Member 1208345324-Oct-15 0:21
Member 1208345324-Oct-15 0:21 
AnswerRe: grid search Pin
Patrice T24-Oct-15 22:12
mvePatrice T24-Oct-15 22:12 
AnswerRe: grid search Pin
Richard MacCutchan24-Oct-15 22:48
mveRichard MacCutchan24-Oct-15 22:48 
AnswerRe: grid search Pin
BillWoodruff30-Oct-15 23:10
professionalBillWoodruff30-Oct-15 23:10 
QuestionA max profit question Pin
JStagg14-Oct-15 23:15
JStagg14-Oct-15 23:15 
AnswerRe: A max profit question Pin
Eddy Vluggen20-Oct-15 7:39
professionalEddy Vluggen20-Oct-15 7:39 
QuestionHow can I found max of multiplication of subtree nodes? Pin
mortalphilosopher11-Oct-15 19:56
mortalphilosopher11-Oct-15 19:56 
GeneralRe: How can I found max of multiplication of subtree nodes? Pin
harold aptroot11-Oct-15 21:54
harold aptroot11-Oct-15 21:54 
AnswerRe: How can I found max of multiplication of subtree nodes? Pin
Patrice T13-Oct-15 10:09
mvePatrice T13-Oct-15 10:09 
GeneralRe: How can I found max of multiplication of subtree nodes? Pin
mortalphilosopher13-Oct-15 23:28
mortalphilosopher13-Oct-15 23:28 
GeneralRe: How can I found max of multiplication of subtree nodes? Pin
Matt T Heffron14-Oct-15 8:09
professionalMatt T Heffron14-Oct-15 8:09 
QuestionData selection and classification algorithms Pin
Member 120412687-Oct-15 13:15
Member 120412687-Oct-15 13:15 
SuggestionRe: Data selection and classification algorithms Pin
Matt T Heffron7-Oct-15 14:29
professionalMatt T Heffron7-Oct-15 14:29 
GeneralRe: Data selection and classification algorithms Pin
Member 120412687-Oct-15 16:55
Member 120412687-Oct-15 16:55 
QuestionHow you gonna start with this question? Pin
lebanner6-Oct-15 14:52
lebanner6-Oct-15 14:52 

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.