- 1、本文档共56页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
程序设计与算法基础
程序设计与算法基础(2) 潘爱民 2006/9/25 提纲 基本数据结构——list 基本数据结构——stack 基本数据结构——queue list 单链表(singly linked list) 双链表(doubly linked list) List的性质 在两端插入元素非常快速、简单 查找中间元素效率不高 SkipList 查找过程 构造和维护过程 * 建议对p2p技术有兴趣的同学看一看SkipNet List的广泛应用 从系统底层,到应用层的数据管理 系统层: 内核对象的管理 动态数据块的管理 应用层: 稀疏表格(矩阵) 各种纪录信息 List的一个实现 DDK中单链表的定义 typedef struct _SINGLE_LIST_ENTRY { struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY; DDK中双链表的定义 typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; } LIST_ENTRY; stack stack: a linear data structure, it can be accessed only at one of its ends for storing and retrieving data. The last entry put in the stack is the first entry removed from the stack. —— LIFO(Last in/first out,后进先出) Stack is like a special container, a stack of trays in a cafeteria: New trays are put on top of the stack The trays are taken off just from the top of the stack, not from the middle or the bottom of the stack Stack: C function calls how to implement function calls in C? C function calls Stack frame or activation record Before entering a function, the caller stores the specific state info into a stack frame, and resume the state after the function finishes. If all stack frames are put into a container, the stack frame retrieved at the time of resuming the caller’s state is the one put recently —— LIFO Stack can be used to implement the function calls The stack frame in C function calls Delimiter Matching in C expression S=t[5]+u/(v*(w+y)) Output pairs (u,v) such that the left delimiter at position u is matched with the right delimiter at v. (3,5) (9,17) (12,16) (a+b))*((c+d) right parenthesis at 4 has no matching left parenthesis (7,11) left parenthesis at 6 has no matching right parenthesis Delimiter Matching scan expression from left to right when a left delimiter is encountered, add its position to the stack when a right delimiter is encountered, remove matching position from stack Example S=t[5]+u/(v*(w+y)) Example S=t[5]+u/(v*(w+y)) Example S=t[5
文档评论(0)