下载此文档

数据结构与程序设计.ppt


文档分类:IT计算机 | 页数:约20页 举报非法文档有奖
1/20
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/20 下载此文档
文档列表 文档介绍
数据结构与程序设计(29)
教师:鲍钰
******@.
11/14/2017
1
数据结构与程序设计教师:鲍钰
Chapter 11
MULTIWAY TREES
11/14/2017
2
数据结构与程序设计教师:鲍钰
Tries: Lexicographic Search Trees P531
DEFINITION
A trie of order m is either empty or consists of an ordered sequence of exactly m tries of order m.
11/14/2017
3
数据结构与程序设计教师:鲍钰
11/14/2017
4
数据结构与程序设计教师:鲍钰
C++ Trie Declarations
Every Record has a Key that is an alphanumeric string.
Method char key_letter(int position) returns the character in the given position of the key or returns a NONE, if the key has length less than position.
Auxiliary function int alphabetic_order(char symbol) returns the alphabetic position of the character symbol, or 27 for nonblank, nonalphabetic characters, or 0 for blank, NONE characters.
11/14/2017
5
数据结构与程序设计教师:鲍钰
Trie--Key
#include ""
#include ""
const int key_size = 10;
class Key {
char str[key_size];
public:
Key (char s[]);
char * the_key( ) const;
char key_letter(int position) const;
};
11/14/2017
6
数据结构与程序设计教师:鲍钰
Trie--Key
#include ""
Key::Key(char s[]){
for(int i=0; i<=strlen(s); i++)
str[i]=s[i];
}
char * Key::the_key() const{
return (char *)str;
}
char Key::key_letter (int position) const{
if(position<strlen(str)) return str[position];
else return '\0';
}
11/14/2017
7
数据结构与程序设计教师:鲍钰
Trie--Record
#include ""
class Record{
public:
operator Key( ); // implicit conversion from Record to Key .
Record(char s[]="");
char * the_key() const;
char key_letter(int position) const;
private:
char str[key_size];
};
ostream & operator << (ostream &output, Record &x);
11/14/2017
8
数据结构与程序设计教师:鲍钰
Trie--Record
#include ""
Record::Record(char s[]){
for(int i=0; i<=strlen(s); i++)
str[i]=s[i];
}
Record::operator Key( ){
Key tmp(str);
}
11/14/2017
9
数据结构与程序设计教师:鲍钰
Trie--Record
char Record::key_letter(int position) const{
if(position<strlen(str)) return str[position];
else return '\0';
}
char * Record::the_key() const{
return (

数据结构与程序设计 来自淘豆网www.taodocs.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数20
  • 收藏数0 收藏
  • 顶次数0
  • 上传人小玉儿
  • 文件大小0 KB
  • 时间2013-12-09