Data Structures Fibonacci Heaps, Amortized Analysis
|
|
- Prudence Jones
- 7 years ago
- Views:
Transcription
1 Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn
2 Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure: A Fibonacci heap consists of a collection of trees satisfying the min heap property. Variables:. : root of the tree containing the (a) minimum key. : circular, doubly linked, unordered list containing the roots of all trees. : number of nodes currently in Algorithm Theory, WS 2012/13 Fabian Kuhn 2
3 Trees in Fibonacci Heaps Structure of a single node : parent left key degree right child mark. : points to circular, doubly linked and unordered list of the children of.,. : pointers to siblings (in doubly linked list). : will be used later Advantages of circular, doubly linked lists: Deleting an element takes constant time Concatenating two lists takes constant time Algorithm Theory, WS 2012/13 Fabian Kuhn 3
4 Example Figure: Cormen et al., Introduction to Algorithms Algorithm Theory, WS 2012/13 Fabian Kuhn 4
5 Simple (Lazy) Operations Initialize Heap :.. Merge heaps and : concatenate root lists update. Insert element into : create new one node tree containing H merge heaps and Get minimum element of : return. Algorithm Theory, WS 2012/13 Fabian Kuhn 5
6 Operation Delete Min Delete the node with minimum key from and return its element: 1.. ; 2. if. 0 then 3. remove. from. ; 4. add.. (list) to. 5.. ; // Repeatedly merge nodes with equal degree in the root list // until degrees of nodes in the root list are distinct. // Determine the element with minimum key 6. return Algorithm Theory, WS 2012/13 Fabian Kuhn 6
7 Rank and Maximum Degree Ranks of nodes, trees, heap: Node : : degree of Tree : : rank (degree) of root node of Heap : : maximum degree of any node in Assumption ( : number of nodes in ): for a known function Algorithm Theory, WS 2012/13 Fabian Kuhn 7
8 Merging Two Trees Given: Heap ordered trees, with Assume: min key of min key of Operation, : Removes tree from root list and adds to child list of 1. Algorithm Theory, WS 2012/13 Fabian Kuhn 8
9 Consolidation of Root List Array pointing to find roots with the same rank: Consolidate: Time: 1. for 0to do null;. 2. while. null do 3. delete and return first element of. 4. while nulldo 5. ; 6. ; 7., Create new. and. Algorithm Theory, WS 2012/13 Fabian Kuhn 9
10 Operation Decrease Key Decrease Key, : (decrease key of node to new value ) 1. if. then return; 2.. ; update. ; 3. if... then return 4. repeat 5.. ; 6.. ; 7. ; 8. until.. ; 9. if. then. ; Algorithm Theory, WS 2012/13 Fabian Kuhn 10
11 Operation Cut( ) Operation. : Cuts s sub tree from its parent and adds to rootlist 1. if. then 2. // cut the link between and its parent ; 4. remove from.. (list) 5.. null; 6. add to Algorithm Theory, WS 2012/13 Fabian Kuhn 11
12 Decrease Key Example Green nodes are marked Decrease Key, Algorithm Theory, WS 2012/13 Fabian Kuhn 12
13 Fibonacci Heap Marks History of a node : is being linked to a node. a child of is cut. a second child of is cut. Hence, the boolean value. indicates whether node has lost a child since the last time was made the child of another node. Algorithm Theory, WS 2012/13 Fabian Kuhn 13
14 Cost of Delete Min & Decrease Key Delete Min: 1. Delete min. root and add. to. time: 1 2. Consolidate. time: length of. Step 2 can potentially be linear in (size of ) Decrease Key (at node ): 1. If new key parent key, cut sub tree of node time: 1 2. Cascading cuts up the tree as long as nodes are marked time: number of consecutive marked nodes Step 2 can potentially be linear in Exercises: Both operations can take time in the worst case! Algorithm Theory, WS 2012/13 Fabian Kuhn 14
15 Cost of Delete Min & Decrease Key Cost of delete min and decrease key can be Θ Seems a large price to pay to get insert and merge in 1 time Maybe, the operations are efficient most of the time? It seems to require a lot of operations to get a long rootlist and thus, an expensive consolidate operation In each decrease key operation, at most one node gets marked: We need a lot of decrease key operations to get an expensive decrease key operation Can we show that the average cost per operation is small? We can requires amortized analysis Algorithm Theory, WS 2012/13 Fabian Kuhn 15
16 Amortization Consider sequence,,, of operations (typically performed on some data structure ) : execution time of operation : total execution time The execution time of a single operation might vary within a large range (e.g., 1, ) The worst case overall execution time might still be small average execution time per operation might be small in the worst case, even if single operations can be expensive Algorithm Theory, WS 2012/13 Fabian Kuhn 16
17 Analysis of Algorithms Best case Worst case Average case Amortized worst case What it the average cost of an operation in a worst case sequence of operations? Algorithm Theory, WS 2012/13 Fabian Kuhn 17
18 Example: Binary Counter Incrementing a binary counter: determine the bit flip cost: Operation Counter Value Cost Algorithm Theory, WS 2012/13 Fabian Kuhn 18
19 Accounting Method Observation: Each increment flips exactly one 0 into a Idea: Have a bank account (with initial amount 0) Paying to the bank account costs Take money from account to pay for expensive operations Applied to binary counter: Flip from 0 to 1: pay 1 to bank account (cost: 2) Flip from 1 to 0: take 1 from bank account (cost: 0) Amount on bank account = number of ones We always have enough money to pay! Algorithm Theory, WS 2012/13 Fabian Kuhn 19
20 Accounting Method Op. Counter Cost To Bank From Bank Net Cost Credit Algorithm Theory, WS 2012/13 Fabian Kuhn 20
21 Potential Function Method Most generic and elegant way to do amortized analysis! But, also more abstract than the others State of data structure / system: (state space) Potential function : Operation : : actual cost of operation : state after execution of operation ( : initial state) Φ : potential after exec. of operation : amortized cost of operation : Algorithm Theory, WS 2012/13 Fabian Kuhn 21
22 Potential Function Method Operation : actual cost: amortized cost: Φ Φ Overall cost: Φ Φ Algorithm Theory, WS 2012/13 Fabian Kuhn 22
23 Binary Counter: Potential Method Potential function: : Clearly, Φ 0and Φ 0for all 0 Actual cost : 1 flip from 0 to 1 1flips from 1 to 0 Potential difference: Φ Φ Amortized cost: Φ Φ 2 Algorithm Theory, WS 2012/13 Fabian Kuhn 23
24 Back to Fibonacci Heaps Worst case cost of a single delete min or decrease key operation is Ω Can we prove a small worst case amortized cost for delete min and decrease key operations? Remark: Data structure that allows operations,, We say that operation has amortized cost if for every execution the total time is where is the number of operations of type Algorithm Theory, WS 2012/13 Fabian Kuhn 24,
25 Amortized Cost of Fibonacci Heaps Initialize heap, is empty, get min, insert, and merge have worst case cost Delete min has amortized cost Decrease key has amortized cost Starting with an empty heap, any sequence of operations with at most delete min operations has total cost (time). We will now need the marks Cost for Dijkstra: log Algorithm Theory, WS 2012/13 Fabian Kuhn 25
26 Fibonacci Heaps: Marks Cycle of a node: 1. Node is removed from root list and linked to a node. 2. Child node of is cut and added to root list. 3. Second child of is cut node is cut as well and moved to root list The boolean value. indicates whether node has lost a child since the last time was made the child of another node. 26 Algorithm Theory, WS 2012/13 Fabian Kuhn Winter term 11/12 26
27 Potential Function System state characterized by two parameters: : number of trees (length of. ) : number of marked nodes that are not in the root list Potential function: Example: , 2 Φ 11 Algorithm Theory, WS 2012/13 Fabian Kuhn 27
28 Actual Time of Operations Operations: initialize heap, is empty, insert, get min, merge actual time: 1 Normalize unit time such that,,,, 1 Operation delete min: Actual time: length of. Normalize unit time such that length of. Operation descrease key: Actual time: length of path to next unmarked ancestor Normalize unit time such that lengthof path to next unmarked ancestor Algorithm Theory, WS 2012/13 Fabian Kuhn 28
29 Amortized Times Assume operation is of type: initialize heap: actual time: 1, potential: Φ Φ 0 amortized time: Φ Φ 1 is empty, get min: actual time: 1, potential: Φ Φ (heap doesn t change) amortized time: Φ Φ 1 merge: Actual time: 1 combined potential of both heaps: Φ Φ amortized time: Φ Φ 1 Algorithm Theory, WS 2012/13 Fabian Kuhn 29
30 Amortized Time of Insert Assume that operation is an insert operation: Actual time: 1 Potential function: remains unchanged (no nodes are marked or unmarked, no marked nodes are moved to the root list) grows by 1 (one element is added to the root list), Φ Φ 1 1 Amortized time: Algorithm Theory, WS 2012/13 Fabian Kuhn 30
31 Amortized Time of Delete Min Assume that operation is a delete min operation: Actual time:. Potential function : : changes from. to at most : (# of marked nodes that are not in the root list) no new marks if node is moved away from root list,. is set to false value of does not change!,. Φ Φ. Amortized Time: Algorithm Theory, WS 2012/13 Fabian Kuhn 31
32 Amortized Time of Decrease Key Assume that operation is a decrease key operation at node : Actual time: length of path to next unmarked ancestor Potential function : Assume, node and nodes,, are moved to root list,, are marked and moved to root list,. mark is set to true marked nodes go to root list, 1node gets newly marked grows by 1, grows by 1 and is decreased by 1, 1 Φ Φ Φ 3 Amortized time: Algorithm Theory, WS 2012/13 Fabian Kuhn 32
33 Complexities Fibonacci Heap Initialize Heap: Is Empty: Insert: Get Min: Delete Min: Decrease Key: amortized Merge (heaps of size and, ): How large can get? Algorithm Theory, WS 2012/13 Fabian Kuhn 33
34 Rank of Children Lemma: Consider a node of rank and let,, be the children of in the order in which they were linked to. Then, Proof:. Algorithm Theory, WS 2012/13 Fabian Kuhn 34
35 Size of Trees Fibonacci Numbers: 0, 1, 2: Lemma: In a Fibonacci heap, the size of the sub tree of a node with rank is at least. Proof: : minimum size of the sub tree of a node of rank Algorithm Theory, WS 2012/13 Fabian Kuhn 35
36 Size of Trees 1, 2, 2: 2 Claim about Fibonacci numbers: 0: 1 Algorithm Theory, WS 2012/13 Fabian Kuhn 36
37 Size of Trees 1, 2, 2: 2, 1 Claim of lemma: Algorithm Theory, WS 2012/13 Fabian Kuhn 37
38 Size of Trees Lemma: In a Fibonacci heap, the size of the sub tree of a node with rank is at least. Theorem: The maximum rank of a node in a Fibonacci heap of size is at most. Proof: The Fibonacci numbers grow exponentially: For, we need nodes Algorithm Theory, WS 2012/13 Fabian Kuhn 38
39 Summary: Binomial and Fibonacci Heaps Binomial Heap Fibonacci Heap initialize insert get min delete min * decrease key * merge is empty amortized time Algorithm Theory, WS 2012/13 Fabian Kuhn 39
Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child
Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using
More informationFull and Complete Binary Trees
Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full
More informationCSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.
Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure
More informationCS711008Z Algorithm Design and Analysis
CS711008Z Algorithm Design and Analysis Lecture 7 Binary heap, binomial heap, and Fibonacci heap 1 Dongbo Bu Institute of Computing Technology Chinese Academy of Sciences, Beijing, China 1 The slides were
More information1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++
Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The
More informationBinary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R
Binary Search Trees A Generic Tree Nodes in a binary search tree ( B-S-T) are of the form P parent Key A Satellite data L R B C D E F G H I J The B-S-T has a root node which is the only node whose parent
More informationA binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property
CmSc 250 Intro to Algorithms Chapter 6. Transform and Conquer Binary Heaps 1. Definition A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called
More informationCpt S 223. School of EECS, WSU
Priority Queues (Heaps) 1 Motivation Queues are a standard mechanism for ordering tasks on a first-come, first-served basis However, some tasks may be more important or timely than others (higher priority)
More informationQuestions 1 through 25 are worth 2 points each. Choose one best answer for each.
Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in
More informationConverting a Number from Decimal to Binary
Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive
More information5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.
1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The
More informationFrom Last Time: Remove (Delete) Operation
CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From
More informationOrdered Lists and Binary Trees
Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:
More informationThe Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,
The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints
More informationOutline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb
Binary Search Trees Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 27 1 Properties of Binary Search Trees 2 Basic BST operations The worst-case time complexity of BST operations
More informationPES Institute of Technology-BSC QUESTION BANK
PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions
More informationAlgorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
More informationData Structures and Algorithms
Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationData Structure [Question Bank]
Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:
More informationAnalysis of Algorithms I: Binary Search Trees
Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary
More information10CS35: Data Structures Using C
CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a
More information- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time
Skip Lists CMSC 420 Linked Lists Benefits & Drawbacks Benefits: - Easy to insert & delete in O(1) time - Don t need to estimate total memory needed Drawbacks: - Hard to search in less than O(n) time (binary
More informationUnordered Linked Lists
Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered
More information6 March 2007 1. Array Implementation of Binary Trees
Heaps CSE 0 Winter 00 March 00 1 Array Implementation of Binary Trees Each node v is stored at index i defined as follows: If v is the root, i = 1 The left child of v is in position i The right child of
More informationCS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
More informationSection IV.1: Recursive Algorithms and Recursion Trees
Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller
More informationClass Notes CS 3137. 1 Creating and Using a Huffman Code. Ref: Weiss, page 433
Class Notes CS 3137 1 Creating and Using a Huffman Code. Ref: Weiss, page 433 1. FIXED LENGTH CODES: Codes are used to transmit characters over data links. You are probably aware of the ASCII code, a fixed-length
More informationBinary Search Trees CMPSC 122
Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than
More informationAbstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types
EECS 281: Data Structures and Algorithms The Foundation: Data Structures and Abstract Data Types Computer science is the science of abstraction. Abstract Data Type Abstraction of a data structure on that
More informationData Structures and Algorithms Written Examination
Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where
More informationAnalysis of a Search Algorithm
CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,
More informationOutline. Introduction Linear Search. Transpose sequential search Interpolation search Binary search Fibonacci search Other search techniques
Searching (Unit 6) Outline Introduction Linear Search Ordered linear search Unordered linear search Transpose sequential search Interpolation search Binary search Fibonacci search Other search techniques
More informationChapter 13: Query Processing. Basic Steps in Query Processing
Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing
More informationTables so far. set() get() delete() BST Average O(lg n) O(lg n) O(lg n) Worst O(n) O(n) O(n) RB Tree Average O(lg n) O(lg n) O(lg n)
Hash Tables Tables so far set() get() delete() BST Average O(lg n) O(lg n) O(lg n) Worst O(n) O(n) O(n) RB Tree Average O(lg n) O(lg n) O(lg n) Worst O(lg n) O(lg n) O(lg n) Table naïve array implementation
More informationKrishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C
Tutorial#1 Q 1:- Explain the terms data, elementary item, entity, primary key, domain, attribute and information? Also give examples in support of your answer? Q 2:- What is a Data Type? Differentiate
More informationDATA STRUCTURES USING C
DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give
More informationPrevious Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles
B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:
More informationSequential Data Structures
Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year
More informationThe Goldberg Rao Algorithm for the Maximum Flow Problem
The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }
More informationB-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees
B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:
More informationGuessing Game: NP-Complete?
Guessing Game: NP-Complete? 1. LONGEST-PATH: Given a graph G = (V, E), does there exists a simple path of length at least k edges? YES 2. SHORTEST-PATH: Given a graph G = (V, E), does there exists a simple
More informationK-Cover of Binary sequence
K-Cover of Binary sequence Prof Amit Kumar Prof Smruti Sarangi Sahil Aggarwal Swapnil Jain Given a binary sequence, represent all the 1 s in it using at most k- covers, minimizing the total length of all
More informationTREE BASIC TERMINOLOGIES
TREE Trees are very flexible, versatile and powerful non-liner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and
More information1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.
1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated
More informationGRAPH THEORY LECTURE 4: TREES
GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection
More informationPersistent Binary Search Trees
Persistent Binary Search Trees Datastructures, UvA. May 30, 2008 0440949, Andreas van Cranenburgh Abstract A persistent binary tree allows access to all previous versions of the tree. This paper presents
More informationLearning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees
Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture
More information14.1 Rent-or-buy problem
CS787: Advanced Algorithms Lecture 14: Online algorithms We now shift focus to a different kind of algorithmic problem where we need to perform some optimization without knowing the input in advance. Algorithms
More informationBinary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *
Binary Heaps A binary heap is another data structure. It implements a priority queue. Priority Queue has the following operations: isempty add (with priority) remove (highest priority) peek (at highest
More informationRow Echelon Form and Reduced Row Echelon Form
These notes closely follow the presentation of the material given in David C Lay s textbook Linear Algebra and its Applications (3rd edition) These notes are intended primarily for in-class presentation
More informationInternational Journal of Advanced Research in Computer Science and Software Engineering
Volume 3, Issue 7, July 23 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Greedy Algorithm:
More informationLecture Notes on Binary Search Trees
Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative
More information6.3 Conditional Probability and Independence
222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted
More informationDATABASE DESIGN - 1DL400
DATABASE DESIGN - 1DL400 Spring 2015 A course on modern database systems!! http://www.it.uu.se/research/group/udbl/kurser/dbii_vt15/ Kjell Orsborn! Uppsala Database Laboratory! Department of Information
More informationroot node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain
inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each
More informationScheduling Shop Scheduling. Tim Nieberg
Scheduling Shop Scheduling Tim Nieberg Shop models: General Introduction Remark: Consider non preemptive problems with regular objectives Notation Shop Problems: m machines, n jobs 1,..., n operations
More informationData Structures and Data Manipulation
Data Structures and Data Manipulation What the Specification Says: Explain how static data structures may be used to implement dynamic data structures; Describe algorithms for the insertion, retrieval
More informationAlgorithms Chapter 12 Binary Search Trees
Algorithms Chapter 1 Binary Search Trees Outline Assistant Professor: Ching Chi Lin 林 清 池 助 理 教 授 chingchi.lin@gmail.com Department of Computer Science and Engineering National Taiwan Ocean University
More informationComplexity of Union-Split-Find Problems. Katherine Jane Lai
Complexity of Union-Split-Find Problems by Katherine Jane Lai S.B., Electrical Engineering and Computer Science, MIT, 2007 S.B., Mathematics, MIT, 2007 Submitted to the Department of Electrical Engineering
More informationEfficient Data Structures for Decision Diagrams
Artificial Intelligence Laboratory Efficient Data Structures for Decision Diagrams Master Thesis Nacereddine Ouaret Professor: Supervisors: Boi Faltings Thomas Léauté Radoslaw Szymanek Contents Introduction...
More informationData Structures Using C++ 2E. Chapter 5 Linked Lists
Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given
More informationSample Questions Csci 1112 A. Bellaachia
Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k
More informationRandomized Binary Search Trees
CONRADO MARTÍNEZ AND SALVADOR ROURA Universitat Politècnica de Catalunya, Barcelona, Catalonia, Spain Abstract. In this paper, we present randomized algorithms over binary search trees such that: (a) the
More informationBinary Search Trees (BST)
Binary Search Trees (BST) 1. Hierarchical data structure with a single reference to node 2. Each node has at most two child nodes (a left and a right child) 3. Nodes are organized by the Binary Search
More informationBinary Heap Algorithms
CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell
More informationClass Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction
Class Overview CSE 326: Data Structures Introduction Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know
More informationStrategic Deployment in Graphs. 1 Introduction. v 1 = v s. v 2. v 4. e 1. e 5 25. e 3. e 2. e 4
Informatica 39 (25) 237 247 237 Strategic Deployment in Graphs Elmar Langetepe and Andreas Lenerz University of Bonn, Department of Computer Science I, Germany Bernd Brüggemann FKIE, Fraunhofer-Institute,
More informationSolutions for Practice problems on proofs
Solutions for Practice problems on proofs Definition: (even) An integer n Z is even if and only if n = 2m for some number m Z. Definition: (odd) An integer n Z is odd if and only if n = 2m + 1 for some
More informationFundamental Algorithms
Fundamental Algorithms Chapter 6: AVL Trees Michael Bader Winter 2011/12 Chapter 6: AVL Trees, Winter 2011/12 1 Part I AVL Trees Chapter 6: AVL Trees, Winter 2011/12 2 Binary Search Trees Summary Complexity
More informationData storage Tree indexes
Data storage Tree indexes Rasmus Pagh February 7 lecture 1 Access paths For many database queries and updates, only a small fraction of the data needs to be accessed. Extreme examples are looking or updating
More informationM(0) = 1 M(1) = 2 M(h) = M(h 1) + M(h 2) + 1 (h > 1)
Insertion and Deletion in VL Trees Submitted in Partial Fulfillment of te Requirements for Dr. Eric Kaltofen s 66621: nalysis of lgoritms by Robert McCloskey December 14, 1984 1 ackground ccording to Knut
More informationData Structures. Jaehyun Park. CS 97SI Stanford University. June 29, 2015
Data Structures Jaehyun Park CS 97SI Stanford University June 29, 2015 Typical Quarter at Stanford void quarter() { while(true) { // no break :( task x = GetNextTask(tasks); process(x); // new tasks may
More informationSolutions to Math 51 First Exam January 29, 2015
Solutions to Math 5 First Exam January 29, 25. ( points) (a) Complete the following sentence: A set of vectors {v,..., v k } is defined to be linearly dependent if (2 points) there exist c,... c k R, not
More informationLaboratory Module 6 Red-Black Trees
Laboratory Module 6 Red-Black Trees Purpose: understand the notion of red-black trees to build, in C, a red-black tree 1 Red-Black Trees 1.1 General Presentation A red-black tree is a binary search tree
More informationLecture Notes on Binary Search Trees
Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure
More informationOptimal Binary Search Trees Meet Object Oriented Programming
Optimal Binary Search Trees Meet Object Oriented Programming Stuart Hansen and Lester I. McCann Computer Science Department University of Wisconsin Parkside Kenosha, WI 53141 {hansen,mccann}@cs.uwp.edu
More informationChapter 8: Structures for Files. Truong Quynh Chi tqchi@cse.hcmut.edu.vn. Spring- 2013
Chapter 8: Data Storage, Indexing Structures for Files Truong Quynh Chi tqchi@cse.hcmut.edu.vn Spring- 2013 Overview of Database Design Process 2 Outline Data Storage Disk Storage Devices Files of Records
More informationHow To Create A Tree From A Tree In Runtime (For A Tree)
Binary Search Trees < 6 2 > = 1 4 8 9 Binary Search Trees 1 Binary Search Trees A binary search tree is a binary tree storing keyvalue entries at its internal nodes and satisfying the following property:
More informationIntroduction to Data Structures and Algorithms
Introduction to Data Structures and Algorithms Chapter: Elementary Data Structures(1) Lehrstuhl Informatik 7 (Prof. Dr.-Ing. Reinhard German) Martensstraße 3, 91058 Erlangen Overview on simple data structures
More informationAPP INVENTOR. Test Review
APP INVENTOR Test Review Main Concepts App Inventor Lists Creating Random Numbers Variables Searching and Sorting Data Linear Search Binary Search Selection Sort Quick Sort Abstraction Modulus Division
More informationLecture 5 - CPA security, Pseudorandom functions
Lecture 5 - CPA security, Pseudorandom functions Boaz Barak October 2, 2007 Reading Pages 82 93 and 221 225 of KL (sections 3.5, 3.6.1, 3.6.2 and 6.5). See also Goldreich (Vol I) for proof of PRF construction.
More informationBinary Heaps. CSE 373 Data Structures
Binary Heaps CSE Data Structures Readings Chapter Section. Binary Heaps BST implementation of a Priority Queue Worst case (degenerate tree) FindMin, DeleteMin and Insert (k) are all O(n) Best case (completely
More informationTo My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers
To My Parents -Laxmi and Modaiah To My Family Members To My Friends To IIT Bombay To All Hard Workers Copyright 2010 by CareerMonk.com All rights reserved. Designed by Narasimha Karumanchi Printed in
More informationMidterm Practice Problems
6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator
More informationData Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010
Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Problem 1. In each of the following question, please specify if the statement
More informationSorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)
Sorting revisited How did we use a binary search tree to sort an array of elements? Tree Sort Algorithm Given: An array of elements to sort 1. Build a binary search tree out of the elements 2. Traverse
More informationSatisfiability Checking
Satisfiability Checking SAT-Solving Prof. Dr. Erika Ábrahám Theory of Hybrid Systems Informatik 2 WS 10/11 Prof. Dr. Erika Ábrahám - Satisfiability Checking 1 / 40 A basic SAT algorithm Assume the CNF
More informationPersistent Data Structures and Planar Point Location
Persistent Data Structures and Planar Point Location Inge Li Gørtz Persistent Data Structures Ephemeral Partial persistence Full persistence Confluent persistence V1 V1 V1 V1 V2 q ue V2 V2 V5 V2 V4 V4
More informationThe Butterfly, Cube-Connected-Cycles and Benes Networks
The Butterfly, Cube-Connected-Cycles and Benes Networks Michael Lampis mlambis@softlab.ntua.gr NTUA The Butterfly, Cube-Connected-Cycles and Benes Networks p.1/16 Introduction Hypercubes are computationally
More informationWRITING PROOFS. Christopher Heil Georgia Institute of Technology
WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this
More informationFind-The-Number. 1 Find-The-Number With Comps
Find-The-Number 1 Find-The-Number With Comps Consider the following two-person game, which we call Find-The-Number with Comps. Player A (for answerer) has a number x between 1 and 1000. Player Q (for questioner)
More information1 Definition of a Turing machine
Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,
More informationBinary Search Trees. basic implementations randomized BSTs deletion in BSTs
Binary Search Trees basic implementations randomized BSTs deletion in BSTs eferences: Algorithms in Java, Chapter 12 Intro to Programming, Section 4.4 http://www.cs.princeton.edu/introalgsds/43bst 1 Elementary
More informationExam study sheet for CS2711. List of topics
Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure
More informationA binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:
Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)
More informationData Structures. Level 6 C30151. www.fetac.ie. Module Descriptor
The Further Education and Training Awards Council (FETAC) was set up as a statutory body on 11 June 2001 by the Minister for Education and Science. Under the Qualifications (Education & Training) Act,
More informationAn algorithmic classification of open surfaces
An algorithmic classification of open surfaces Sylvain Maillot January 8, 2013 Abstract We propose a formulation for the homeomorphism problem for open n-dimensional manifolds and use the Kerekjarto classification
More informationPractical Guide to the Simplex Method of Linear Programming
Practical Guide to the Simplex Method of Linear Programming Marcel Oliver Revised: April, 0 The basic steps of the simplex algorithm Step : Write the linear programming problem in standard form Linear
More informationLecture 6: Binary Search Trees CSCI 700 - Algorithms I. Andrew Rosenberg
Lecture 6: Binary Search Trees CSCI 700 - Algorithms I Andrew Rosenberg Last Time Linear Time Sorting Counting Sort Radix Sort Bucket Sort Today Binary Search Trees Data Structures Data structure is a
More information