- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
switch (n)
{
case (-1)://分裂节点,父分裂点为point->breakpoint
tempuse =point->strdata;
cnode=(mynode) new node;
if (point->Child.size() !=0)
{
cnode->Child =point->Child;
}
cnode->flag =point->flag;
point->Child.erase(point->Child.begin(),point->Child.end());
point->strdata.erase(point->strdata.begin(),point->strdata.end());
for (h = 0; hbreakpoint); h++)
{
point->strdata.insert(point->strdata.end(),tempuse[h]);
}
for (h =(point->breakpoint); h
{
cnode->strdata.insert(cnode->strdata.end(), tempuse[h]);
}
point->Child.push_back(cnode);
cnode = (mynode) new node;
cnode->strdata = left;
cnode->flag = 0;
point->Child.push_back(cnode);
point->flag = 1;
break;
case (0)://do nothing
break;
case (1)://在叶节点point处追加left字符串
point->strdata =point->strdata+left;
break;
case (2)://在父节点point下添加子节点cnode
cnode = (mynode) new node;
cnode->strdata = left;
cnode->flag = 0;
point->Child.push_back(cnode);
point->flag = 1;
break;
}
}
}
}
//返回1: 则在指针point所指向的节点的strdata后追加 left字符串
//返回2: 则生成point所指向的节点的子节点,子节点的strdata值为left字符串
//返回0: 则donothing
//返回-1:则分裂节点将分裂点写入point指针所指向的 节点的breakpoint,并将目标字符串的剩余字符串写入left
intCSuffixTree::Search(string str)
{
stack s;
int i, n = 0;
mynode child;
char target;
point = ST; //初始搜索位置为根
child = NULL;
for (i = (str.length()-1); i >= 0; i--)//将目标字符串str压栈
{
s.push(str[i]);
}
while(!s.empty())//直到搜索完str串
{
//寻找point所指向的节点下与str首字母相同的子节点
for (i = 0; i Child.size()-1); i++)
{
if(point->Child[i]->strdata[0] == s.top())
{
child =point->Child[i]; //child指针指向与str具有相同首字母的节点
break;
}
}
责编:罗莉
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>