将字符串数组解析为预购BST [英] Parsing of string array into preorder BST

查看:98
本文介绍了将字符串数组解析为预购BST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在使用C ++程序.它的一部分要求我使用元素的二进制搜索树预排序.我有一个带线的字符串数组,用于生物医学实体.将这些实体插入此bst之后,需要使用它们.

由于我不是来自CS背景,因此在一定的时间范围内,这似乎超出了我的范围.因此,如果有一些片段可以处理字符串数组的输出,我可以继续进一步处理我的程序.因此,如果有人可以提供帮助,我可能需要两个函数片段,一个是将我拥有的具有40个元素的字符串数组作为它们的出现插入到树中.第二部分将显示这些节点的预遍历.

我希望我对C专家的要求不高.

Hi all

I am working on a C++ program. A part of it requires that i use binary search tree preorder of the elements. I have a string array with lines for biomedical entities. These entities need to be used after they are inserted in this bst.

Since i am not from CS background, it seemed a bit out of my bounds given the time frame i have. So if there is some snippet that can process the string array output , i can move on to further process the program of mine. So i might need two function snippets if someone can help, one would be to take this string array with 40 elements that i have and insert them in the tree as their occurrence. Second part wold be to display the preorder traversal of those nodes.

I hope i am not demanding much with c gurus over here.

推荐答案

以下链接仅提供Java代码,但具有出色的文档:
http://en.wikipedia.org/wiki/Binary_search_tree [
The following link only provides Java code, but has excellent documentation:
http://en.wikipedia.org/wiki/Binary_search_tree[^]

I posted this to show you how complex a binary search tree is to implement. You implied you have a limited time frame, and therefore I have to ask: why do you need to use a BST at all? A simple list serves well enough for the purpose of storing and retrieving ordered data, and there are predefined sort functions in the Standard Template Library that you can use in case the data doesn''t come in an ordered sequence.

P.S.: there actually is a link to a C++ implementation at the bottom of the page I linked above.


这篇关于将字符串数组解析为预购BST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆