假设我有一个如下的数据集:
Seq1 | Seq2 | Seq3 |疾病|年龄
====================================
发烧、干咳| 24
T|C|G|高血压| 56
C|T|A|糖尿病,高血压| 79
我应该选择哪种数据结构来支持字母数据{A/T/C/G}、集值数据{糖尿病、高血压}和数字数据{年龄}?
如果我有一个coount查询,比如: seq2 =T,age>50 =‘’,==>,答案应该是2。
我想知道我应该使用哪种数据结构来有效地适应所有类型的数据和上述查询?或者我需要构建3个数据结构,然后将结果相交?
发布于 2017-10-05 05:32:08
如果您正在使用OOP语言,请考虑创建一个包含所需所有属性的类(序列1、序列2、序列3、症状列表、年龄)。然后,您可以实例化该类,并将结果对象放入各种数据结构(如列表)中。
发布于 2017-10-05 23:49:36
类应该是处理这种结构的正确方法,在C#中的简单实现如下所示:
using System.Collections.Generic;
namespace DataStructure
{
class Program
{
static void Main(string[] args)
{
// Creating Data Set
var AllDataSet = new List<DataStructure>();
AllDataSet.Add(
new DataStructure(new char[] { 'A', 'T', 'G' }, new string[] { "Fever", "Cough" }, 24)
);
AllDataSet.Add(
new DataStructure(new char[] { 'T', 'C', 'G' }, new string[] { "High Blood Pressure" }, 56)
);
AllDataSet.Add(
new DataStructure(new char[] { 'A', 'T', 'G' }, new string[] { "Diabetes", "High Blood Pressure" }, 79)
);
}
}
public class DataStructure
{
public char[] DNAChar;
public string[] SetValuedData;
public int Age;
public DataStructure(char[] dnaChar, string[] setValuedData, int age)
{
DNAChar = dnaChar;
SetValuedData = setValuedData;
Age = age;
}
// Add other logic here
}
}然后,您可以添加功能来实现您的逻辑。希望这会有帮助的!
https://stackoverflow.com/questions/46574304
复制相似问题