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

Algorithms

 
GeneralRe: Braille Alphabet Generation through images Pin
mittra14-Feb-14 9:30
mittra14-Feb-14 9:30 
QuestionBest algorithm for sound pattern storage and searching not to use any RDBMS then what?.. Pin
RahulAJoshi27-Jan-14 17:57
RahulAJoshi27-Jan-14 17:57 
AnswerRe: Best algorithm for sound pattern storage and searching not to use any RDBMS then what?.. Pin
Alan Balkany29-Jan-14 4:50
Alan Balkany29-Jan-14 4:50 
GeneralRe: Best algorithm for sound pattern storage and searching not to use any RDBMS then what?.. Pin
RahulAJoshi29-Jan-14 5:11
RahulAJoshi29-Jan-14 5:11 
Questionfind shortest root in maze using recursion Pin
Member 1055197427-Jan-14 5:23
Member 1055197427-Jan-14 5:23 
AnswerRe: find shortest root in maze using recursion Pin
Kornfeld Eliyahu Peter27-Jan-14 8:10
professionalKornfeld Eliyahu Peter27-Jan-14 8:10 
QuestionRe: find shortest root in maze using recursion Pin
thatraja27-Jan-14 14:16
professionalthatraja27-Jan-14 14:16 
Questionpattern/string matching algorithm Pin
asdf2321122-Jan-14 22:42
asdf2321122-Jan-14 22:42 
I think this should be common problem in Computer science.

I have a data like this

Java
List<Map<Integer,List<String>>> Qdata = new ArrayList<Map<Integer,List<String>>>();//QUERY
    List<Map<Integer,List<String>>> Tdata = new ArrayList<Map<Integer,List<String>>>();//TARGET

    List<String> Qg1 = Arrays.asList("C", "A", "PC", "R");
    List<String> Qg2 = Arrays.asList("DQ", "EQ", "KC", "AC");
    List<String> Qg3 = Arrays.asList("KQ", "AT");
    List<String> Qg4 = Arrays.asList("KQ", "AT", "DQ", "KC","AC","KQ", "AT", "KC","AC","KQ", "AT", "DQ", "KC","AC");
    List<String> Qg5 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List<String> Qg6 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List<String> Qg7 = Arrays.asList("AC","KQ", "AT","AT", "DQ", "KC","AC");

    Map<Integer,List<String>> Qmap = new HashMap<Integer, List<String>>();
    Qmap.put(1, Qg1);
    Qmap.put(2, Qg2);
    Qmap.put(3, Qg3);
    Qmap.put(4, Qg4);
    Qmap.put(5, Qg5);
    Qmap.put(6, Qg6);
    Qmap.put(7, Qg7);


    List<String> Tg1 = Arrays.asList("C", "A", "PC", "?");
    List<String> Tg2 = Arrays.asList("KQ", "AT","DQ", "EQ", "KC", "AC");
    List<String> Tg3 = Arrays.asList("AT", "DQ", "KC","AC");
    List<String> Tg4 = Arrays.asList("KQ", "AT", "DQ", "KC","AC","KQ", "AT", "KC","AC");
    List<String> Tg5 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List<String> Tg6 = Arrays.asList("KQ", "AT", "DQ", "KC","AC");
    List<String> Tg7 = Arrays.asList("AT","AT", "DQ", "KC","AC");
    List<String> Tg8 = Arrays.asList("AC");
    List<String> Tg9 = Arrays.asList("ACL","AC","C","A","PC");

    Map<Integer,List<String>> Tmap = new HashMap<Integer, List<String>>();
    Tmap.put(1, Tg1);
    Tmap.put(2, Tg2);
    Tmap.put(3, Tg3);
    Tmap.put(4, Tg4);
    Tmap.put(5, Tg5);
    Tmap.put(6, Tg6);
    Tmap.put(7, Tg7);
    Tmap.put(8, Tg8);
    Tmap.put(9, Tg9);

    Qdata.add(Qmap);
    Tdata.add(Tmap)


want to match Qdata with Tdata, the tricky part here is, if you observe the data

Qg3+Qg2 forms Tg2
Tg4+Tg3 forms Qg4 with "kQ" missing between Tg4 and Tg3
Tg8+Tg9 forms Qg7
and with the rest, it is pretty straight forward. I don't know how to deal with this tricky part.

I used map to store the data because it is more desired for the algorithm to finds matching in the same position in Tdata and Qdata like

Qg5 has a complete match with Tg5 Qg6 has a complete match with Tg6

The final ideal output that I expect in this case is:

Qg1 matches with Tg1 with a wild card("?") (some penalty for wild card)
Qg3+Qg2 matches Tg2
Qg4 matches Tg4+Tg3 (some penalty for missing word
Qg5 has a complete match with Tg5
Qg6 has a complete match with Tg6
Qg7 matches with Tg8+Tg9 (penalty)
and penalty for extra Tg9.


I already tried longest common subsequence and needleman wunsch algorithms they are good in aligning with gaps but I don't know how to mix two parts and match them like the tricky part I mentioned and how to teach algorithm when to mix parts and start matching and when not to?

Sorry for my bad english

I'm currently coding in java.

Any suggestions will very much keep me alive and get going.

Thanks in advance
QuestionOptimizing connectivity queries in a Directed Acyclic Graph Pin
ssuryakumar8915-Jan-14 17:55
ssuryakumar8915-Jan-14 17:55 
SuggestionBuilding dual axis solar tracking algorithm Pin
Member 105152259-Jan-14 20:14
professionalMember 105152259-Jan-14 20:14 
Questiondynamic activity selection Pin
Member 1040514815-Nov-13 21:11
Member 1040514815-Nov-13 21:11 
AnswerRe: dynamic activity selection Pin
Alan Balkany27-Nov-13 5:26
Alan Balkany27-Nov-13 5:26 
AnswerRe: dynamic activity selection Pin
jschell28-Nov-13 7:10
jschell28-Nov-13 7:10 
QuestionNeed help with this Pseudocode Pin
B-Sho10-Nov-13 7:23
B-Sho10-Nov-13 7:23 
AnswerRe: Need help with this Pseudocode Pin
Richard Andrew x6410-Nov-13 9:38
professionalRichard Andrew x6410-Nov-13 9:38 
GeneralRe: Need help with this Pseudocode Pin
B-Sho10-Nov-13 12:14
B-Sho10-Nov-13 12:14 
AnswerRe: Need help with this Pseudocode Pin
Richard Andrew x6410-Nov-13 12:23
professionalRichard Andrew x6410-Nov-13 12:23 
AnswerRe: Need help with this Pseudocode Pin
BillWoodruff10-Nov-13 15:54
professionalBillWoodruff10-Nov-13 15:54 
AnswerRe: Need help with this Pseudocode Pin
Kornfeld Eliyahu Peter10-Nov-13 19:28
professionalKornfeld Eliyahu Peter10-Nov-13 19:28 
GeneralRe: Need help with this Pseudocode Pin
B-Sho11-Nov-13 8:09
B-Sho11-Nov-13 8:09 
AnswerRe: Need help with this Pseudocode Pin
Richard Andrew x6411-Nov-13 11:56
professionalRichard Andrew x6411-Nov-13 11:56 
GeneralRe: Need help with this Pseudocode Pin
Kornfeld Eliyahu Peter11-Nov-13 19:12
professionalKornfeld Eliyahu Peter11-Nov-13 19:12 
GeneralRe: Need help with this Pseudocode Pin
Richard MacCutchan11-Nov-13 22:35
mveRichard MacCutchan11-Nov-13 22:35 
QuestionAn HTML5 platform to animate algorithms Pin
babakin7-Nov-13 8:31
babakin7-Nov-13 8:31 
GeneralRe: An HTML5 platform to animate algorithms Pin
harold aptroot7-Nov-13 8:44
harold aptroot7-Nov-13 8:44 

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.