chapter3:栈、队列内容摘要:
现实世界中有许多问题(关系)可用队列描述,顾客服务部门的工作方式往往是排队方式,这类系统称作排队系统。 在计算机算法实现中,也经常使用队列记录需按 FIFO方式处理的数据。 • ────────────── • 出队 ← ○ ○ …… ○ ← ○进队 • ────────────── • 队头 队尾 Queue front rear enqueue dequeue A B C A queue is open at two ends. You can only add entry (enqueue) at the rear , and delete entry (dequeue) at the front. Note that you cannot add/extract entry in the middle of the queue. Firstin Firstout (FIFO) When we enqueue entries in the queue and then dequeue them one by one, we will get the entries in the same order. A B C A A B B C C The first one enqueued is the first one dequeued. (FIFO) 抽象数据类型队列 • ADT Queue{ • 数据对象 : D={ai| ai(ElemSet,i=1,2,...,n,n=0} • 数据关系 : R1={ai1,ai | ai1,ai( D,i=2,...,n} • 基本操作: • InitQueue(amp。 Q) 构造一个空队列 Q • Destroyqueue(amp。 Q) 队列 Q存在则销毁 Q • ClearQueue(amp。 Q) 队列 Q存在则将 Q清为空队列 • QueueEmpty(Q) 队列 Q存在 ,若 Q为空队列则返回 TRUE,否则返回 FALSE • QueueLenght(Q) 队列 Q存在 ,返回 Q的元素个数 ,即队列的长度 • GetHead(Q,amp。 e) Q为非空队列 ,用 e返回 Q的队头元素 • EnQueue(amp。 Q,e) 队列 Q存在 ,插入元素 e为 Q的队尾元素 • DeQueue(amp。 Q,amp。 e) Q为非空队列 ,删除 Q的队头元素 ,并用 e返回其值 • QueueTraverse(Q,vivsit()) Q存在且非空 ,从队头到队尾 ,依次对 Q的每个数据元素调用函数 visit()。 一旦 visit()失败,则操作失败 • }ADT Queue 二、链队列-队列的链式表示和实现 • 用链表表示的队列简称为链队列。 一个链队列显然需要两个分别指示队头和队尾的指针。 LinkedListItr a1 a2 a3 a4 Front of queue Back of queue 链队列表示和实现 • //存储表示 • typedef struct QNode{ • QElemType data。 • struct QNode *next。 • }QNode,*QueuePtr。 • typedef struct{ • QueuePtr front。 • QueuePtr rear。 • }LinkQueue。 • //操作说明 • Status InitQueue(LinkQueue amp。 Q) • //构造一个空队列 Q • Status Destroyqueue(LinkQueue amp。 Q) • //队列 Q存在则销毁 Q • Status ClearQueue(LinkQueue amp。 Q) • //队列 Q存在则将 Q清为空队列 • Status QueueEmpty(LinkQueue Q) • // 队列 Q存在 ,若 Q为空队列则返回 TRUE,否则返回 FALSE • Status QueueLenght(LinkQueue Q) • // 队列 Q存在 ,返回 Q的元素个数 ,即队列的长度 • Status GetHead(LinkQueue Q,QElemType amp。 e) • //Q为非空队列 ,用 e返回 Q的队头元素 • Status EnQueue(LinkQueue amp。 Q,QElemType e) • //队列 Q存在 ,插入元素 e为 Q的队尾元素 • Status DeQueue(LinkQue。chapter3:栈、队列
相关推荐
on the size of the 没有对缓冲区大小的限制 boundedbuffer assumes that there is a fixed buffer 缓冲 对缓冲区大小作了限定 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – SharedMemory Solution The Buffer may
isual C++ – Windows CE的 C++編譯器 Compact .Net Framework – 精簡的 .Net平台,可快速移植桌上型程式到 Windows CE平台中 415 BSP Board support package 元件 說明 啟動程式 系統啟動時,啟動程式會下載作業系統 ( OS)映像檔。 OEM配階層 ( OAL) 連結核心映像檔,將硬體初始化並管理之。
子商務軟體基本的功能 電子商務軟體需要提供以下功能 型錄展示 購物推車功能 交易處理(含金流) 購物者在網站進行虛擬的結帳時,按下結帳按鈕時才會開始進行 其他加值功能 7 標示語言 HTML: Hypertext Markup Language 簡單的超文本標示語言,有固定的標簽 SGML: Standard Generalized ML ISO 8879:1986
10 100 370 10 700 )1()( 222nnyynS)16(6 10700622 S 3 62 SS練習 6個樣本數據 :,, 求其標準差 解 : 數據減去 再乘上 100倍 算出來的標準差 會是原來的 100倍 ∴ 標準差為 x y= z=100y z2 5 25 6 36 4 16 5 25 2 4 0 0 0 4 106 0)16(6
} 四川大学 计算机学院 唐宁九 template class Type int StackType::GetTop ( Type amp。 x ) { if ( IsEmpty ( ) ) return 0。 x = topdata。 return 1。 } 四川大学 计算机学院 唐宁九 Linked Stacks 四川大学 计算机学院 唐宁九 四川大学 计算机学院 唐宁九 四川大学
Liver toxicity Cardiotoxicity Erythromycin Erythromycin lactobionate(乳糖酸红霉素) erythromycin estolate(无味红霉素 ) erythromycin stearate(硬脂酸红霉素) erythromycin ethylsuccinate(琥乙红霉素, 利君沙 ) New