Skip to content

best way through a truth table

suppose you have a “truth table” which looks like this for example:

with this algorithm you can get from the left to the right side of the table
by switching the true Boolean values next to each other. It calculates the number
of row switches down to the minimum possible !!!
the Alg. is recursive but it’s not deterministic when in a column is no true Boolean value at all.
In the above picture the alg switches only one time to get from the left to the right side.

It works like this (really abstract):

  1. it builds this table by making maps and lists
  2. the loop starts at the most left side of every row in the table and checks for the column value
  3. count the occurrences of unbreaked true values from step 2
  4. if a false value is detected the counting of the true values before is saved in x and the counter is resetted.
  5. get the maximum x in the whole table. this one result y is then one of the best ways.
  6. delete the columns included in y from the table.
  7. if the table has more columns go back to point 2.

in my alg i work with calendar dates as columns and row numbers.
most of the comments are in German, ask me if you like a translation.

here

this is just a innerclass not the actual one, please implement this in your own class…

Categories: algorithms.

Tags: , , , ,

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.