We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,956 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Characters alignement

Hello world !

I have two arrays (max 100 characters) that I want to align, and add an "-" when there is disparity I found the Needleman–Wunsch algorithm, which is based on dynamic programming, and the Smith–Waterman algorithm is a general local alignment method also based on dynamic programming but they seems too complex for what I want.

Is there a way do this alignement with a diff algorithm ? If yes can someone point me how to do this.

My program already works with the Needleman algorith and its about 200 lines of code.

Example of desired input/output :

Input
Array 1 : MKNLASREVN
Array 2 : QMASREVNIY

Output
Array 1 (or a simple print) : -MKNLASREVN
Array 2 (or a simple print) : QM---ASREVN

Thanks

2
Contributors
1
Reply
13 Hours
Discussion Span
2 Months Ago
Last Updated
27
Views
nacedo
Newbie Poster
11 posts since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

if ( char from array 1 at index i == char from array 2 at index i )
print (not println) char from array 1
else
print -

is that what you mean?

stultuske
Industrious Poster
4,372 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0645 seconds using 2.65MB