开发者

Best and simple data structure

I am trying to create the below matrix in my vb.net so during processing I can get the match scores for the alphabets, for example: What is the match for A开发者_如何转开发 and N?, I will look into my inbuilt matrix and return -2 Similarly, What is the match for P and L?, I will look into my inbuilt matrix and return -3

Please suggest me how to go about it, I was trying to use nested dictionary like this:

Dim myNestedDictionary As New Dictionary(Of String, Dictionary(Of String, Integer))()
Dim lTempDict As New Dictionary(Of String, Integer)
lTempDict.Add("A", 4)
myNestedDictionary.Add("A", lTempDict)

The other way could be is to read the Matrix from a text based file and then fill the two dimensional array.

Thanks.

Best and simple data structure

(source: clcbio.com)


I would think it would be simpler to use an un-nested dictionary with two-character keys.

myDictionary.add("AA", 4)


Use a two dimensional array and create a mapping for your alphabet as an enumeration that will also serve as an index into the arrays:

public enum AlphaBet
{
   A = 0,
   R = 1,
   ...
}

// Init the array
int[][] scores = ...;

int score = scores[AlphaBet.A][AlphaBet.N]; // score = -2


take one dictionary that maps char to int. the ints must be sequential. then take 2d array, thats it. first you look into dictionary for index for both chars then go to array

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜