Review of Chapter 9 張啟中. Inheritance Hierarchy Min PQ Max PQ Min Heap Mergeable Min PQ DeapMin-Max Min-LeftistMin-SkewMinFHeap MinBHeap DEPQMax Heap Symmetric.

Slides:



Advertisements
Similar presentations
Author : Chia-Hung Lin, Chia-Yin Hsu, and Sun-Yuan Hsieh Publisher : IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED SYSTEMS.
Advertisements

Fibonacci Heap BH&FH. Why BH&FH -- 程式目的 MinPQ Mergeable MinPQ MaxPQ DEPQ Min-LeftistMin-Skew Min-B-Heap Min-F-Heap Min Heap DeapMinMax Symmetric Max Data.
布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
資料的搜尋 搜尋的基本概念 循序搜尋法(Sequential Search) 二元搜尋法(Binary Search)
: A-Sequence 星級 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CIX 題號: Problem D : A-Sequence 解題者:薛祖淵 解題日期: 2006 年 2 月 21 日 題意:一開始先輸入一個.
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
Instructor: Ching-Chi Lin 林清池 助理教授
指導教授:陳淑媛 學生:李宗叡 李卿輔.  利用下列三種方法 (Edge Detection 、 Local Binary Pattern 、 Structured Local Edge Pattern) 來判斷是否為場景變換,以方便使用者來 找出所要的片段。
1.1 線性方程式系統簡介 1.2 高斯消去法與高斯-喬登消去法 1.3 線性方程式系統的應用(-Skip-)
Lecture 8 Median and Order Statistics. Median and Order Statistics2 Order Statistics 問題敘述 在 n 個元素中,找出其中第 i 小的元素。 i = 1 ,即為找最小值。 i = n ,即為找最大值。 i = 或 ,即為找中位數。
Graph V(G 1 )={0, 1, 2, 3, 4, 5, 6, 7, 8, 9} E(G 1 )={(0, 2), (0, 3), (1, 4), (2, 3), (2, 5), (2, 6), (3, 6), (3, 7), (4, 7), (5, 6), (5,
:New Land ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11871: New Land 解題者:施博修 解題日期: 2011 年 6 月 8 日 題意:國王有一個懶兒子,為了勞動兒子,他想了一個 辦法,令他在某天早上開始走路,直到太陽下山前,靠.
: ShellSort ★★☆☆☆ 題組: Problem D 題號: 10152: ShellSort 解題者:林一帆 解題日期: 2006 年 4 月 10 日 題意:烏龜王國的烏龜總是一隻一隻疊在一起。唯一改變烏龜位置 的方法為:一隻烏龜爬出他原來的位置,然後往上爬到最上方。給 你一堆烏龜原來排列的順序,以及我們想要的烏龜的排列順序,你.
Chapter 2 聯立線性方程式與矩陣 緒言 線性方程式組 (systems of linear equations) 出現 在多數線性模式 (linear model) 中。根據以往解 題的經驗,讀者們也許已發現方程式的解僅與 該方程式的係數有關,求解的過程也僅與係數 的運算有關,只要係數間的相關位置不改變,
:Quarter-Finals with Brazil!? No!!! ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11041: Quarter-Finals with Brazil!? No!!! 解題者:呂彥澂 解題日期:
JAVA 程式設計與資料結構 第十四章 Linked List. Introduction Linked List 的結構就是將物件排成一列, 有點像是 Array ,但是我們卻無法直接經 由 index 得到其中的物件 在 Linked List 中,每一個點我們稱之為 node ,第一個 node.
MATLAB 程式設計 第 11 章 多維陣列 多維陣列的定義 在 MATLAB 的資料型態中,向量可視為 一維陣列,矩陣可視二維陣列,對於維 度 (Dimensions) 超過 1 的陣列則均可視 為「多維陣列」 (Multidimesional Arrays , 簡稱 N-D Arrays)
8.1 何謂高度平衡二元搜尋樹 8.2 高度平衡二元搜尋樹的加入 8.3 高度平衡二元搜尋樹的刪除
: The Playboy Chimp ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10611: The Playboy Chimp 解題者:蔡昇宇 解題日期: 2010 年 2 月 28 日 題意:給一已排序的數列 S( 升冪.
: Nails ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 11096:Nails 解題者:蘇育彣 解題日期: 2007 年 3 月 13 日 題意:給定一個正整數 n (0
10215: The Largest/Smallest Box... ★ 題組: Problem Set Archive with Online Judge 題號: 10215: The Largest/Smallest Box... 解題者:張維珊 解題日期: 2006 年 4 月 17 日 題意:
國立中山大學財產管理系統 線上報廢、盤點系統 總務處保管組 策劃 計算機與網路中心 分析設計 2008/03.
桁架分析.
24-6 設定開始與結束場景中的 程式 最後我們要替這個遊戲收個尾, 幫它把開始 的等待畫面跟結束畫面處理一下。
: The largest Clique ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11324: The largest Clique 解題者:李重儀 解題日期: 2008 年 11 月 24 日 題意: 簡單來說,給你一個 directed.
計算機概論 - 排序 1 排序 (Sorting) 李明山 編撰 ※手動換頁.
圖層的操作與管理 圖層的作用就如同一張張透明的賽璐璐片, 你可以將動畫中的每項物件, 放置在不同圖 層中, 圖層交疊就形成完整的畫面。在各圖 層中的物件, 做任何的移動或變化, 都不會 相互干擾, 所以當你編輯一個物件時, 只要 在物件所在的圖層進行操作, 將可大幅降低 製作過程的複雜度與難度。
: Point of View in Flatland ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 11037: Point of View in Flatland 解題者:黃士庭 解題日期: 2007 年 5 月 15 日 題意:在座標平面上給三個圓,找一個點使從這.
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
各種線上電子資源的特異功能 SwetsWise 的 alert, TOC alert 與 Favorites 2003/4/28 修改.
期中考試解答 張啟中.
: Playing War ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11061: Playing War 解題者:陳盈村 解題日期: 2008 年 3 月 14 日 題意:在此遊戲中,有一類玩家一旦開始攻擊, 就會不停攻擊同一對手,直到全滅對方或無法再.
第十章 再論結構. 指標與結構的關係 /* File name: ex10-1a.c */ #include int main() { struct student { char *name; int score; }; struct student st= {"Brian", 97}; struct.
Review of Chapter 5 張啟中. Threaded Binary Tree 利用 Binary Tree 節點中的 0-links ,指向中序的先行 者或後繼者,以方便中序追蹤。 Threading Rules  A 0 RightChild field at node p is.
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
資料結構實習-一 參數傳遞.
Deletion in MIN-MAX Heaps Delete min element Delete max element.
: Efficient Solutions ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11020: Efficient Solutions 解題者:陳宜佐 解題日期: 2007 年 4 月 24 日 題意:給定 M 個 case.
4 堆疊與佇列 4.1 前言 四種基本的資料結構 (可儲存資料的容器) 陣列 (Array)、串列(List): 最基本
DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,
: Lucky Number ★★★★☆ 題組: Proble Set Archive with Online Judge 題號: 10909: Lucky Number 解題者:李育賢 解題日期: 2008 年 4 月 25 日 題意:給一個奇數數列 1,3,5,7,9,11,13,15…
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
: Automatic correction of misspellings ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11048: Automatic correction of misspellings 解題者:陳宜佐 解題日期:
1 第七章 植基於可調整式量化表及離散餘 弦轉換之浮水印技術. 2 Outlines 介紹 介紹 灰階浮水印藏入 灰階浮水印藏入 灰階浮水印取回 灰階浮水印取回 實驗結果 實驗結果.
: Flip Sort ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10327: Flip Sort 解題者:歐子揚 解題日期: 2010 年 2 月 26 日 題意:在這個問題中使用一種排序方式 (Flip) ,意思就是 只能交換相鄰的.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
本章重點 2-1 有序串列(Ordered List) 2-2 介紹陣列(array) 2-3 矩陣(matrix)的應用
: Help My Brother ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11033: Help My Brother 解題者: 呂明璁 解題日期: 2007 年 5 月 14 日.
2005/7 Linear system-1 The Linear Equation System and Eliminations.
中序轉後序 藉由由左向右掃瞄中序運算式產生後序運算式,遇到 運算元就直接輸出,遇到運算符號則先存入堆疊,將 優先權較高者輸出。 範例: a + b * c TokenStack [0] [1] [2] topoutput aa ++0a b+0ab *+ *1ab c+ *1abc eosabc*+
: Problem E Antimatter Ray Clearcutting ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11008: Problem E Antimatter Ray Clearcutting 解題者:林王智瑞.
資料結構實習-六.
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
數字系統與資料表示法 教師: 陳炯勳 數系轉換 r進制數字 稱為 base r或 radix r 有r個計數符號,計數順序逢r歸零(進位) A n A n - 1 ‥‥A 2 A 1 A 0 ﹒A -1 A -2 ‥‥A -m 其中A n 及A.
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
:Rings and Glue ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10301: Rings and Glue 解題者:施博修 解題日期: 2011 年 5 月 18 日 題意:小約翰有了個大麻煩,他不小心將 rings.
第七章 計算複雜度概論:排序問題 7.1計算複雜度 7.2插入排序與選擇排序 7.3每次比較至多移除一個導致之演算法的下限
Chapter 9 Heap Structures
單元7: Heap 定義 for priority queues Leftist trees Binomial heap
Tree Traversal Inorder traversal: A/B*C*D+E (LVR)
Data Structures -3 rd test- 2015/06/01 授課教授:李錫智. Question 1 Suppose we use an array to implement a sorted list. Please answer the following questions.
Double-Ended Priority Queues Primary operations  Insert  Remove Max  Remove Min Note that a single-ended priority queue supports just one of the above.
Data Structures -Final exam- 2015/6/22 授課教授:李錫智. Question 1. Let a hash table have 13 entries. Suppose we have 10 integer keys: 68, 100, 58, 80, 72, 101,
1 Chapter 13 Priority Queues. 2 Chap.13 Contents 13.1 Introduction 13.2 The PurePriorityQueue Interface 13.3 Implementations of the PurePriorityQueue.
Chapter 05 Trees (Part I). Definition A tree is a finite set of one or more nodes including: ▫A starting node called root. ▫The rest of nodes can be split.
Double-Ended Priority Queues
Presentation transcript:

Review of Chapter 9 張啟中

Inheritance Hierarchy Min PQ Max PQ Min Heap Mergeable Min PQ DeapMin-Max Min-LeftistMin-SkewMinFHeap MinBHeap DEPQMax Heap Symmetric Max Data Structures

Double-Ended Priority Queue A double-ended priority queue is a data structure that supports the following operations:  inserting an element with an arbitrary key  deleting an element with the largest key  deleting an element with the smallest key There are two kinds of DEPQ  Min-Max Heap  Deap

Min-Max Heaps Definition A min-max heap is a complete binary tree such that if it is not empty,  Each element has a data member called key.  Alternating levels of this tree are min levels and max levels, respectively.  The root is on a min level.  Let x be any node in a min-max heap. If x is on a min (max) level then the element in x has the minimum (maximum) key from among all elements in the subtree with root x. A node on a min (max) level is called a min (max) node.

Example min max

Insertion of a Min-Max Heap Step 1  將欲新增的元素插入 Min-Max Heap 最後一個節點 Step 2  將新增節點與其父節點做比較,若父節點位於 Min (Max) Level ,且新增節點小於 ( 大於 ) 父節點,則交換二者的位置。 Step 3  若交換後新增節點的位於 Min (Max) Level ,則依序往上與 各 Min (Max) Level 的節點比較,若新增節點較小 ( 大 ) ,則二 者交換。 Step 4  重複 Step 3 ,直至不能再交換或到 root 為止。

Insertion of a Min-Max Heap min max 5 O(logn)

Insertion of a Min-Max Heap min max 80

Deletion of The Min Element Step 1  刪除 root Step 2  將最後一個節點刪除,並重新插入 Min-Max Heap 的 root

Deletion of The Min Element Step 3  Case 1 The root has no children. In this case x is to be inserted into the root.  Case 2 The root has at least one child. Find the smallest key from the children or grandchildren of root. Assume node k has the smallest key. x is inserted node.  x.key <= h[k].key  Insert x to the root  x.key > h[k].key and k is child of the root  Interchange x and k  x.key > h[k].key and k is grandchild of the root  (1) h[k] is moved to the root. (2) Let p is parent of node k. If x.key > h[p].key then h[p] and x are to interchanged. Repeat Step 3 with root k.

Deletion of The Min Element min max O(logn)

Deaps Definition A deap is a complete binary tree that is either empty or satisfies the following properties  The root contains no element.  The left subtree is a min heap.  The right subtree is a max heap.  If the right subtree is not empty, then let i be any node in the left subtree. Let j be the corresponding node in the right subtree. If such a j does not exist, then let j be the node in the right subtree that corresponds to the parent of i. The key in node i is less than or equal to that of j.

Deap Min Heap Max Heap

Insertion Into a Deap Step 1  將新增的元素插入 Deap 的最後面一個節點 Step 2  與新增節點相對位置的節點比較大小,若該新增節 點的位於 Max (Min) Heap ,則新增節點必須大於 相對節點,否則必須交換。 Step 3  若新增節點位於 Min (Max) Heap ,則依 Min (Max) Heap 的新增方式進行。

Insertion Into a Deap j i

Insertion Into a Deap j i

Deletion of Min Element Step 1  刪除 Min Heap 的 root Step 2  比較 Min Heap 中 root 的兩個 child ,將較小的值 移到 root ,直到 leaf 為止。 Step 3  將最後一個節點刪除,插入空出的 Leaf ,並依照 Deap 新增的方式操作

Deletion of Min Element j i