山东大学:《数据结构》课程教学资源(PPT课件讲稿)第7章 跳表和散列(Skip List and Hashing)

第7章 跳表和散列 (Skip List and Hashing) 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 1 第 7 章 跳表和散列 (Skip List and Hashing)

本章内容 7.1字典 dictionaries 7.2线性表描述 Linear list 7.3跳表描述 Skip list 7.4散列表描述 Hash tab|e 75应用 Applications 山东大学计算机科学与技术学院数据结构第7章跳表和散列 2
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 2 本章内容 ◼ 7.1 字典 dictionaries ◼ 7.2 线性表描述 Linear List ◼ 7.3 跳表描述 Skip List ◼ 7.4 散列表描述 Hash table ◼ 7.5 应用 Applications

Bird's eye view Although a sorted array of n elements can be searched in O(logn time using the binary search method and o(n time for sorted chain, we still like to improve the search performance of a sorted chain by placing additional pointers in some or all the chain nodes. These additional points permit us to skip over several nodes of of the chain during a search. Chains augmented with additional forward points are called skip lists 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 Bird’s eye view ◼ Although a sorted array of n elements can be searched in O(logn) time using the binary search method and O(n) time for sorted chain, we still like to improve the search performance of a sorted chain by placing additional pointers in some or all the chain nodes. These additional points permit us to skip over several nodes of the chain during a search. Chains augmented with additional forward points are called skip lists

7.1字典 字典( dictionary)是一些元素的集合。每个元素有 个称作key的域,不同元素的key各不相同 有关字典的操作有: 插入( Insert)具有给定关键字值的元素 ■在字典中寻找/搜索( Search)具有给定关键字值的元素 ■删除( Delete)具有给定关键字值的元素 例,班级的学生注册表,key=学号 有重复元素的字典 a dictionary with duplicates May be there are more than one elements have a same key 例,班级的学生考试报表,key=成绩 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 4 7.1 字典 ◼ 字典(dictionary)是一些元素的集合。每个元素有 一个称作key 的域,不同元素的key 各不相同。 ◼ 有关字典的操作有: ◼ 插入(Insert)具有给定关键字值的元素。 ◼ 在字典中寻找/搜索(Search)具有给定关键字值的元素。 ◼ 删除(Delete)具有给定关键字值的元素 ◼ 例,班级的学生注册表,key =学号 ⚫有重复元素的字典 A dictionary with duplicates –May be there are more than one elements have a same key –例,班级的学生考试报表,key =成绩

AbstractDataType AbstractDataT ype dictionary Instances Collection of elements with distinct keys operations Create(O):创建一个空字典 Search(kx):搜索关键字为k的元素,结果放入x; 如果没找到,则返回alse,香则返回true Inseri(x):向字典中插入元素x Delete(kx):删除关键字为k的元素,并将其放入x 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 5 AbstractDataType AbstractDataType Dictionary{ Instances Collection of elements with distinct keys operations Create(): 创建一个空字典 Search(k,x): 搜索关键字为k的元素,结果放入x; 如果没找到,则返回false,否则返回true Insert(x): 向字典中插入元素x Delete(k,x): 删除关键字为k的元素,并将其放入x }

72线性表描述 有序线性表:L=(e1re2,e3r…,en) ■关键字从左到右依次增大 在计算机存储器中的数据描述 ■公式化描述 链表描述 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 6 7.2 线性表描述 ◼ 有序线性表: L = (e1 , e2 , e3 , …, en ), ◼ 关键字从左到右依次增大 ◼ 在计算机存储器中的数据描述 ◼ 公式化描述 ◼ 链表描述

链表描述的有序线性表(字典) 采用链表描述的有序线性表——有序链表 ■类 Sorted Chain 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 7 链表描述的有序线性表(字典) ➢ 采用链表描述的有序线性表——有序链表 ◼ 类 SortedChain

类 Sorted chain first e template>//E:链表元素,K:关键字。 class Sorted ChainNode& Friend sorted chain private e data Sorted chainnode link 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 8 类 SortedChain template >//E:链表元素,K:关键字。 class SortedChainNode{ Friend SortedChain private: E data; SortedChainNode *link; } ; first e1 e2 0 en … ei ei-1 … ei+1

Class sorted chain template class Sorted Chain( public Sorted(first=0; sorted Chain bool isemptyo const return first==0; int Lengthy const bool search(const K&k, e& e)const Sorted chain& delete(const K&k, e& e Sorted chain& Insert( const e&e)许关键字相同 Sorted chain& DistinctInsert( const ec&e)/不允许关 键字相同 private Sorted chainnode *first 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 9 Class SortedChain template class SortedChain{ public : SortedChain() {first =0;} ~SortedChain(); bool IsEmpty() const {return first = =0;} int Length() const; bool Search(const K& k , E& e) const; SortedChain& Delete(const K& k , E& e); SortedChain& Insert(const E& e);//允许关键字相同 SortedChain& DistinctInsert(const E& e);//不允许关 键字相同 private: SortedChainNode *first; } ;

操作 search template bool Sorted chain: Search(const K&k, e& e)const /搜索与k匹配的元素,结果放入e,返回true ∥如果没有匹配的元素,则返回 false Sorted ChainNodee, K> * p=first for(;p&&p>datalink),∥搜索与k相匹配的元素 ∥验证是否与k匹配 if(p&&p->data==k)∥与k相匹配 te=p->data; return true; i return false;∥/不存在相匹配的元素 山东大学计算机科学与技术学院数据结构第7章跳表和散列
山东大学计算机科学与技术学院 数据结构 第7章 跳表和散列 10 操作 ‘search’ template bool SortedChain::Search(const K& k, E& e) const {// 搜索与k匹配的元素,结果放入e,返回true. //如果没有匹配的元素,则返回false SortedChainNode *p = first; for (; p && p->data link); // 搜索与k相匹配的元素 // 验证是否与k匹配 if (p && p->data = = k) // 与k相匹配 {e = p->data; return true;} return false; // 不存在相匹配的元素 }
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《Android 程序设计基础》课程教学资源(PPT课件讲稿)第5章 Android用户界面(界面设计、控件操作).ppt
- 山东大学计算机科学与技术学院:Web Service(PPT讲稿).ppt
- 《编译原理》课程教学资源(PPT课件讲稿)第七章 语义分析和中间代码生成.ppt
- 《计算机组成原理》课程教学资源(PPT课件讲稿)第八章 I/O操作的实现.ppt
- 《C++语言程序设计》课程教学课件(PPT讲稿)第13讲 多态.ppt
- 山东大学:《人机交互技术》课程教学资源(PPT课件讲稿)第9章 可用性分析与评估.ppt
- 多媒体图像处理技术(PPT课件讲稿,共六章).ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第四章 指令系统及汇编语言程序设计 4.5 各类指令详解.ppt
- 《微机原理》课程教学资源(PPT课件)第2章 微处理器与总线.ppt
- 《网页设计与制作》课程教学资源(PPT课件讲稿)第四章 设计页面布局.ppt
- 《网页设计与制作》课程教学资源(PPT课件讲稿)第七章 模板与库的应用.ppt
- 《单片机原理及应用》课程教学资源(PPT课件)第8章 AT89S51单片机外部存储器的扩展.ppt
- 《微机原理》课程教学资源(PPT课件)第六章 微型计算机的输入/输出.ppt
- 《计算机应用基础》课程教学资源(PPT课件讲稿)第3章 Word 2007文字处理.ppt
- 中国铁道出版社:《局域网技术与组网工程》课程教学资源(PPT课件讲稿)第7章 网络系统集成与网络维护.ppt
- 西安交通大学:《微型计算机接口技术》课程教学资源(PPT课件讲稿)第二章 微型处理器与单片机.ppt
- 长安大学:《微机原理》课程教学资源(PPT课件讲稿)第7章 汇编语言程序设计.pptx
- 《数字图像处理基础》课程教学资源(教学大纲.pdf
- 《数据库基础与Access应用》课程教学资源(PPT课件)第12章 应用实例.pptx
- 《数据库基础与应用》课程PPT教学课件(Access案例教程)第8章 宏.pptx
- 文字处理软件 Word 2010(PPT讲稿).pptx
- 烟台理工学院:《算法与数据结构》课程教学资源(PPT课件)第1章 绪论(主讲:高慧).ppt
- 《大学计算机基础》课程教学资源(PPT课件讲稿)第三章 字处理软件Word 2003.ppt
- Enabling SOA Using Messaging(PPT讲稿).ppt
- Folksonomies and Social Tagging(PPT讲稿).ppt
- 兰州大学:搜索引擎的使用(PPT讲稿,主讲 杨青).ppt
- 中国科学技术大学:《数据结构及其算法》课程电子教案(PPT课件讲稿)第7章 图(主讲:刘东).pptx
- 《计算机算法设计与分析》课程教学资源(PPT课件讲稿)分支界限法.ppt
- 电子工业出版社:《计算机网络》课程教学资源(PPT课件讲稿)第1章 概述.pptx
- 《软件测试 Software Testing》教学资源(PPT讲稿)Part 3 Applying Your Testing Skills.ppt
- 《编译原理与技术》课程教学资源(PPT课件讲义)中间代码生成.ppt
- 南京大学:《编译原理》课程教学资源(PPT课件讲稿)第六章 中间代码生成.ppt
- 合肥工业大学:《网络安全概论》课程教学资源(PPT课件讲稿)第一讲 网络安全概述.ppt
- 中国科学技术大学:《计算机体系结构》课程教学资源(PPT课件讲稿)第五章 存储层次.ppt
- 南京大学:移动Agent系统支撑(PPT讲稿)Mobile Agent Communication——Software Agent.pptx
- 西安电子科技大学:《现代密码学》课程教学资源(PPT课件讲稿)第七章 数字签名和密码协议.ppt
- 《编译原理》课程教学资源(PPT课件讲稿)第九章 独立于机器的优化.ppt
- 湖南科技大学:分布式工作流系统的时间管理模型研究(PPT讲稿,周春姐).ppt
- 《计算机网络》课程教学资源(PPT课件讲稿)Chapter 04 网络层 Network Layer.ppt
- 《计算机情报检索原理》课程教学资源(PPT课件)第五章 自动标引.ppt