CSE 100: TREAPS AND RANDOMIZED SEARCH TREES
|
|
- Derrick Booker
- 6 years ago
- Views:
Transcription
1 CSE 100: TREAPS AND RANDOMIZED SEARCH TREES
2 Midterm Review Practice Midterm covered during Sunday discussion Today Run time analysis of building the Huffman tree AVL rotations and treaps
3 Huffman s algorithm 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. How long do these steps take?
4 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. How long do these steps take, using a heap-implemented Priority Queue?
5 Huffman s algorithm N = number of distinct symbols K = total number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. A. O(logN) B. O(N) C. O(N*logN) D. O(N^2) E. other How long do these steps take, using a heap-implemented Priority Queue?
6 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. A. O(logN) B. O(N) C. O(N*logN) D. O(N^2) E. O(K) How long do these steps take, using a heap-implemented Priority Queue?
7 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. A. O(logN) B. O(N) C. O(N*logN) D. O(N^2) E. O(K) How long do these steps take, using a heap-implemented Priority Queue?
8 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. A. O(logN) B. O(N) C. O(N*logN) D. O(N^2) E. O(K) How long do these steps take, using a heap-implemented Priority Queue?
9 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. A. O(logN) B. O(N) C. O(N*logN) D. O(N^2) E. O(K) How long do these steps take, using a heap-implemented Priority Queue?
10 Huffman s algorithm N = number of distinct symbols K = number of symbols in the file 0. Determine the count of each symbol in the input message. 1. Create a forest of single-node trees containing symbols and counts for each non-zero-count symbol. 2. Loop while there is more than 1 tree in the forest: 2a. Remove the two lowest count trees 2b. Combine these two trees into a new tree (summing their counts). 2c. Insert this new tree in the forest, and go to Return the one tree in the forest as the Huffman code tree. O(K) O(N*logN) O(N*logN) O(1) How long does the whole thing take, using a heap-implemented Priority Queue?
11 Treap insert G 50 C 35 H 29 A 21 B 24 D 8 F 40 I 25 L 16 I am midway in the insertion of F,40 into the treap. Have my steps been correct so far? A. Yes B. No C. Not enough information to comment E 33 J 13 K 9
12 Treap insert G 50 C 35 H 29 B 24 E 33 I 25 A 21 D 8 F 40 L 16 J 13 Insert (F,40) K 9
13 AVL rotation to the rescue! G 50 C 35 H 29 B 24 F 40 I 25 A 21 E 33 L 16 D 8 J 13 Step 1: Insert using BST insert Step 2: Fix heap ordering K 9 Insert (F, 40)
14 AVL rotation to the rescue! rotate F 40 G 50 H 29 C 35 I 25 B 24 E 33 L 16 A 21 D 8 J 13 K 9
15 How would you delete in a treap? Rotate down! G 50 F 40 H 29 C 35 I 25 B 24 E 33 L 16 A 21 D 8 J 13 To delete C, rotate it? A. Left B. Right C. None of these K 9
16 How would you delete in a treap? Rotate down! G 50 F 40 H 29 E 33 I 25 C 35 L 16 B 24 D 8 J 13 A 21 K 9 Delete C
17 How would you delete in a treap? Rotate down! G 50 F 40 H 29 E 33 I 25 B 24 L 16 A 21 C 35 J 13 D 8 K 9 Delete C
18 How would you delete in a treap? Rotate down! G 50 F 40 H 29 E 33 I 25 B 24 L 16 A 21 D 8 J 13 C 35 K 9 Delete C
19 How would you delete in a treap? Rotate down! G 50 F 40 H 29 E 33 I 25 B 24 L 16 A 21 D 8 J 13 K 9 Delete C
20 Why Treaps? Treaps are worth studying because... they permit very easy implementations of split and join operations, as well as pretty simple implementations of insert, delete, and find they are the basis of randomized search trees, which have performance comparable to balanced search trees but are simpler to implement they also lend themselves well to more advanced tree concepts, such as weighted trees, interval trees, etc. We will look at the first two of these points
21 Tree splitting The tree splitting problem is this: Given a tree and a key value K not in the tree, create two trees: One with keys less than K, and one with keys greater than K L 50 Insert (K, Inf) Try with K= K C 35 M 29 B 24
22 Tree splitting This is easy to solve with a treap, once the insert operation has been implemented: Insert (K,INFINITY) in the treap Since this has a higher priority than any node in the heap, it will become the root of the treap after insertion Because of the BST ordering property, the left subtree of the root will be a treap with keys less than K, and the right subtree of the root will be a treap with keys greater than K. These subtrees then are the desired result of the split Since insert can be done in time O(H) where H is the height of the treap, splitting can also be done in time O(H) (yes, this same idea could be used in an ordinary BST as well...) How could you do a join? For the answer, see
23 Worst case time to find in a treap The worst case time to find an element in a treap is O(H), where H is the height of the treap. Unfortunately, a standard treap can become very unbalanced. Is it possible to develop a balanced treap data structure (while still maintaining the two essential treap relationships) if the user provides the keys and priorities? A. Yes B. No
24 Randomized Search Trees RST s are treaps in which priorities are assigned randomly by the insert algorithm when keys are inserted
25 Randomized Search Trees Randomized search trees were invented by Ceclia Aragon and Raimund Seidel, in early 1990 s RST s are treaps in which priorities are assigned randomly by the insert algorithm when keys are inserted To implement a randomized search tree: Adapt a treap implementation and its insert method that takes a (key,priority) pair as argument To implement the RST insert method that takes a key as argument: call a random number generator to generate a uniformly distributed random priority (a 32-bit random int is more than enough in typical applications; fewer bits can also be made to work well) that is independent of the key call the treap insert method with the key value and that priority That s all there is to it: none of the other treap operations need to be changed at all (The RST implementation should take care to hide the random priorities, however)
26 Analysis of RSTs How many steps are required, on average, to find that the key you re looking for is in the tree? (Average case analysis of a successful find ) You can read about this here: Punch line: The average number of comparisons for a successful find in an RST is exactly the same as the average number of comparisons in a BST! So what have we gained by using an RST??
27 BST Probabilistic Assumptions Which of the following is/are the probabilistic assumptions we made in our average case successful find in a BST? A. All keys are equally likely to be searched for B. The tree is approximately balanced C. All orders of data are equally likely to occur D. A&B E. A&C
28 RST Probabilistic Assumptions Which of the probabilistic assumptions from the BST is NOT included in the RST analysis? A. All keys are equally likely to be searched for B. All orders of data are equally likely to occur Why not? What second assumption is it replaced with? Why is that important?
29 RST Probabilistic Assumptions Suppose you have a RST with N keys x 1,.. x N, A set of priorities p 1, p 2,.p N are generated for each node For convenience we will assume that: keys are listed in sorted order: for all 0<i<N (though keys can be inserted in any order), all priorities are distinct C 35 B 24 E 33 A 21 D 8
30 RST Probabilistic Assumptions We make the following 2 probabilistic assumptions: Assumption #1: Each key in the tree is equally likely to be searched for Assumption #2: The priorities are randomly uniformly generated independently of each other and of the keys C 35 B 24 E 33 A 21 D 8
31 Recall our BST analysis D(N) = all BSTs with N nodes N 1 N! d(x i ) i=1 What is d(x i )? A. The average depth of a node in a specific BST with N nodes B. The average depth of a node in any BST with N nodes C. The depth of the node in the average BST with N nodes D. The depth of the node in a specific BST with N nodes
32 Recall our BST analysis D(N) = all BSTs with N nodes N 1 N! d(x i ) i=1 What does the inner sum do (boxed)? A. Finds the average depth of a node in a specific BST with N nodes B. Finds the total depth of the nodes in a specific BST with N nodes C. Finds the average depth of a node in the average BST with N nodes
33 Recall our BST analysis D(N) = all BSTs with N nodes N 1 N! d(x i ) i=1 What does the outer sum do? A. Finds the average total depth of all BSTs with N nodes B. Finds the total depth of all BSTs with N nodes C. Finds the average time to find a node in any BST with N nodes
34 Expected node depth in an RST Now, d(x i ) is the depth of the node with the i th smallest key (recall that we assume keys are ordered from smallest to largest) We want to find the expected depth of this specific node across all RSTs with N nodes (similar to the outer sum before, but for one specific node) Before, we averaged over all possible key insertion sequences. Should we do this again? A. Yes B. No C. I have no idea
35 Expected node depth in an RST We will average over all ways of generating priorities during insertion, because that s what will affect the position of this node in the treap given our assumption that the keys are in sorted order Let Pr(p 1, p 2,.p N ) be the probability of generating N priority values p 1, p 2,.p N So the expected value (i.e. average) of is:
36 Expected depth and ancestors Define A ij to be the indicator function for the RST s ancestor relation: C 35 B 24 E 33 A 21 D 8 Which of the following correctly represents d(x i ) in terms of A ij d(x i ) = N N A mi d(x i ) = A im m=1 m=1 A. B.
37 Expected depth and ancestors d(x i ) = N A mi m=1 So, the expected value of the depth of node x i is (using the fact that the expectation of a sum is the sum of the expectations):
38 Probability of being an ancestor A mi is a random variable that takes values 0, 1 Its expected value is just equal to the probability that it has value 1, i.e. What is Pr(A mi = 1), in English? A. The probability that node x m is an ancestor of node x i B. The average depth of node x i C. The average difference in depth between nodes x m and x i
39 Probability of being an ancestor Lemma (by Seidel and Aragon): x m is an ancestor of x i if and only if among all priorities p h such that h lies between the indices m and i inclusive, p m is the largest Convince yourself you believe it. C 35 B 24 E 33 A 21 D 8
40 Probability of being an ancestor So, probability that node x m is an ancestor of x i is just the probability that the random priority generated for x m is higher than the other priorities generated for nodes with indexes between m and i inclusive In total, there are m-i +1 of these nodes. What is the probability that any one of these nodes has the highest priority? A. It depends on the node C. 1/N B. 1 ( m i +1 ) D. 1/(m i)
41 Expected depth of x i This is the expected depth of a single node in over all RSTs. So where do we go from here? A. We re done B. We need to average over all data keys C. We need to average over all insertion orders of the keys D. We need to average over all probability sequences
42 Expected depth of x i This is the expected depth of a specific node over all RSTs. Below is the expected depth of any node over all RSTs:
43 The solution Can be simplified to Which is exactly the same as the average time to find an element in a normal BST! (Why does this make sense?) So what have we gained??
44
Successor. CS 361, Lecture 19. Tree-Successor. Outline
Successor CS 361, Lecture 19 Jared Saia University of New Mexico The successor of a node x is the node that comes after x in the sorted order determined by an in-order tree walk. If all keys are distinct,
More informationChapter 16. Binary Search Trees (BSTs)
Chapter 16 Binary Search Trees (BSTs) Search trees are tree-based data structures that can be used to store and search for items that satisfy a total order. There are many types of search trees designed
More information1 Solutions to Tute09
s to Tute0 Questions 4. - 4. are straight forward. Q. 4.4 Show that in a binary tree of N nodes, there are N + NULL pointers. Every node has outgoing pointers. Therefore there are N pointers. Each node,
More informationSET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2)
SET 1C Binary Trees 1. Construct a binary tree whose preorder traversal is K L N M P R Q S T and inorder traversal is N L K P R M S Q T 2. (i) Define the height of a binary tree or subtree and also define
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Binomial Heaps CLRS 6.1, 6.2, 6.3 University of Manitoba Priority queues A priority queue is an abstract data type formed by a set S of
More information2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes
¼ À ÈÌ Ê ½¾ ÈÊÇ Ä ÅË ½µ ½¾º¾¹½ ¾µ ½¾º¾¹ µ ½¾º¾¹ µ ½¾º¾¹ µ ½¾º ¹ µ ½¾º ¹ µ ½¾º ¹¾ µ ½¾º ¹ µ ½¾¹¾ ½¼µ ½¾¹ ½ (1) CLR 12.2-1 Based on the structure of the binary tree, and the procedure of Tree-Search, any
More informationHomework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class
Homework #4 CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class o Grades depend on neatness and clarity. o Write your answers with enough detail about your approach and concepts
More informationBinary Search Tree and AVL Trees. Binary Search Tree. Binary Search Tree. Binary Search Tree. Techniques: How does the BST works?
Binary Searc Tree and AVL Trees Binary Searc Tree A commonly-used data structure for storing and retrieving records in main memory PUC-Rio Eduardo S. Laber Binary Searc Tree Binary Searc Tree A commonly-used
More informationCSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions
CSE 1 Winter 016 Homework 6 Due: Wednesday, May 11, 016 at 11:59pm Instructions Homework should be done in groups of one to three people. You are free to change group members at any time throughout the
More informationPractical session No. 5 Trees
Practical session No. 5 Trees Tree Binary Tree k-tree Trees as Basic Data Structures ADT that stores elements hierarchically. Each node in the tree has a parent (except for the root), and zero or more
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 8 November 6, 206 洪國寶 Outline Review Amortized analysis Advanced data structures Binary heaps Binomial heaps Fibonacci heaps Data structures for disjoint
More informationPriority Queues 9/10. Binary heaps Leftist heaps Binomial heaps Fibonacci heaps
Priority Queues 9/10 Binary heaps Leftist heaps Binomial heaps Fibonacci heaps Priority queues are important in, among other things, operating systems (process control in multitasking systems), search
More informationHeaps. Heap/Priority queue. Binomial heaps: Advanced Algorithmics (4AP) Heaps Binary heap. Binomial heap. Jaak Vilo 2009 Spring
.0.00 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Advanced Algorithmics (4AP) Heaps Jaak Vilo 00 Spring Binary heap http://en.wikipedia.org/wiki/binary_heap Binomial heap http://en.wikipedia.org/wiki/binomial_heap
More informationCOSC160: Data Structures Binary Trees. Jeremy Bolton, PhD Assistant Teaching Professor
COSC160: Data Structures Binary Trees Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Binary Trees I. Implementations I. Memory Management II. Binary Search Tree I. Operations Binary Trees A
More informationPractical session No. 5 Trees
Practical session No. 5 Trees Tree Trees as Basic Data Structures ADT that stores elements hierarchically. With the exception of the root, each node in the tree has a parent and zero or more children nodes.
More informationHeaps
AdvancedAlgorithmics (4AP) Heaps Jaak Vilo 2009 Spring Jaak Vilo MTAT.03.190 Text Algorithms 1 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Binary heap http://en.wikipedia.org/wiki/binary_heap
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 9 November 19, 2014 洪國寶 1 Outline Advanced data structures Binary heaps(review) Binomial heaps Fibonacci heaps Data structures for disjoint sets 2 Mergeable
More informationOn the Optimality of a Family of Binary Trees Techical Report TR
On the Optimality of a Family of Binary Trees Techical Report TR-011101-1 Dana Vrajitoru and William Knight Indiana University South Bend Department of Computer and Information Sciences Abstract In this
More informationAdministration CSE 326: Data Structures
Administration CSE : Data Structures Binomial Queues Neva Cherniavsky Summer Released today: Project, phase B Due today: Homework Released today: Homework I have office hours tomorrow // Binomial Queues
More informationAdvanced Algorithmics (4AP) Heaps
Advanced Algorithmics (4AP) Heaps Jaak Vilo 2009 Spring Jaak Vilo MTAT.03.190 Text Algorithms 1 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Binary heap http://en.wikipedia.org/wiki/binary
More informationIntroduction to Greedy Algorithms: Huffman Codes
Introduction to Greedy Algorithms: Huffman Codes Yufei Tao ITEE University of Queensland In computer science, one interesting method to design algorithms is to go greedy, namely, keep doing the thing that
More informationYao s Minimax Principle
Complexity of algorithms The complexity of an algorithm is usually measured with respect to the size of the input, where size may for example refer to the length of a binary word describing the input,
More informationDesign and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 9 November 20, 2013 洪國寶 1 Outline Advanced data structures Binary heaps (review) Binomial heaps Fibonacci heaps Dt Data structures t for disjoint dijitsets
More informationSplay Trees. Splay Trees - 1
Splay Trees In balanced tree schemes, explicit rules are followed to ensure balance. In splay trees, there are no such rules. Search, insert, and delete operations are like in binary search trees, except
More informationMax Registers, Counters and Monotone Circuits
James Aspnes 1 Hagit Attiya 2 Keren Censor 2 1 Yale 2 Technion Counters Model Collects Our goal: build a cheap counter for an asynchronous shared-memory system. Two operations: increment and read. Read
More informationSplay Trees Goodrich, Tamassia, Dickerson Splay Trees 1
Spla Trees v 6 3 8 4 2004 Goodrich, Tamassia, Dickerson Spla Trees 1 Spla Trees are Binar Search Trees BST Rules: entries stored onl at internal nodes kes stored at nodes in the left subtree of v are less
More informationCS4311 Design and Analysis of Algorithms. Lecture 14: Amortized Analysis I
CS43 Design and Analysis of Algorithms Lecture 4: Amortized Analysis I About this lecture Given a data structure, amortized analysis studies in a sequence of operations, the average time to perform an
More informationBinary and Binomial Heaps. Disclaimer: these slides were adapted from the ones by Kevin Wayne
Binary and Binomial Heaps Disclaimer: these slides were adapted from the ones by Kevin Wayne Priority Queues Supports the following operations. Insert element x. Return min element. Return and delete minimum
More informationProbability. An intro for calculus students P= Figure 1: A normal integral
Probability An intro for calculus students.8.6.4.2 P=.87 2 3 4 Figure : A normal integral Suppose we flip a coin 2 times; what is the probability that we get more than 2 heads? Suppose we roll a six-sided
More informationUNIT VI TREES. Marks - 14
UNIT VI TREES Marks - 14 SYLLABUS 6.1 Non-linear data structures 6.2 Binary trees : Complete Binary Tree, Basic Terms: level number, degree, in-degree and out-degree, leaf node, directed edge, path, depth,
More informationCSE 417 Algorithms. Huffman Codes: An Optimal Data Compression Method
CSE 417 Algorithms Huffman Codes: An Optimal Data Compression Method 1 Compression Example 100k file, 6 letter alphabet: a 45% b 13% c 12% d 16% e 9% f 5% File Size: ASCII, 8 bits/char: 800kbits 2 3 >
More informationAVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1.
AVL Trees In order to have a worst case running time for insert and delete operations to be O(log n), we must make it impossible for there to be a very long path in the binary search tree. The first balanced
More informationFundamental Algorithms - Surprise Test
Technische Universität München Fakultät für Informatik Lehrstuhl für Effiziente Algorithmen Dmytro Chibisov Sandeep Sadanandan Winter Semester 007/08 Sheet Model Test January 16, 008 Fundamental Algorithms
More informationCSCI 104 B-Trees (2-3, 2-3-4) and Red/Black Trees. Mark Redekopp David Kempe
1 CSCI 104 B-Trees (2-3, 2-3-4) and Red/Black Trees Mark Redekopp David Kempe 2 An example of B-Trees 2-3 TREES 3 Definition 2-3 Tree is a tree where Non-leaf nodes have 1 value & 2 children or 2 values
More informationInformation Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay
Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture - 15 Adaptive Huffman Coding Part I Huffman code are optimal for a
More informationOutline for this Week
Binomial Heaps Outline for this Week Binomial Heaps (Today) A simple, flexible, and versatile priority queue. Lazy Binomial Heaps (Today) A powerful building block for designing advanced data structures.
More information> asympt( ln( n! ), n ); n 360n n
8.4 Heap Sort (heapsort) We will now look at our first (n ln(n)) algorithm: heap sort. It will use a data structure that we have already seen: a binary heap. 8.4.1 Strategy and Run-time Analysis Given
More informationCh 10 Trees. Introduction to Trees. Tree Representations. Binary Tree Nodes. Tree Traversals. Binary Search Trees
Ch 10 Trees Introduction to Trees Tree Representations Binary Tree Nodes Tree Traversals Binary Search Trees 1 Binary Trees A binary tree is a finite set of elements called nodes. The set is either empty
More information3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k
//1 Adapted from: Kevin Wayne B k B k B k : a binomial tree with the addition of a left child with another binomial tree Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N( ) = 2 k B 1 B 2 B
More informationSublinear Time Algorithms Oct 19, Lecture 1
0368.416701 Sublinear Time Algorithms Oct 19, 2009 Lecturer: Ronitt Rubinfeld Lecture 1 Scribe: Daniel Shahaf 1 Sublinear-time algorithms: motivation Twenty years ago, there was practically no investigation
More informationData Structures. Binomial Heaps Fibonacci Heaps. Haim Kaplan & Uri Zwick December 2013
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick December 13 1 Heaps / Priority queues Binary Heaps Binomial Heaps Lazy Binomial Heaps Fibonacci Heaps Insert Find-min Delete-min Decrease-key
More informationLecture l(x) 1. (1) x X
Lecture 14 Agenda for the lecture Kraft s inequality Shannon codes The relation H(X) L u (X) = L p (X) H(X) + 1 14.1 Kraft s inequality While the definition of prefix-free codes is intuitively clear, we
More informationMA 1125 Lecture 05 - Measures of Spread. Wednesday, September 6, Objectives: Introduce variance, standard deviation, range.
MA 115 Lecture 05 - Measures of Spread Wednesday, September 6, 017 Objectives: Introduce variance, standard deviation, range. 1. Measures of Spread In Lecture 04, we looked at several measures of central
More informationCSCE 750, Fall 2009 Quizzes with Answers
CSCE 750, Fall 009 Quizzes with Answers Stephen A. Fenner September 4, 011 1. Give an exact closed form for Simplify your answer as much as possible. k 3 k+1. We reduce the expression to a form we ve already
More informationPRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley
PRIORITY QUEUES binary heaps d-ary heaps binomial heaps Fibonacci heaps Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated
More information1.6 Heap ordered trees
1.6 Heap ordered trees A heap ordered tree is a tree satisfying the following condition. The key of a node is not greater than that of each child if any In a heap ordered tree, we can not implement find
More informationAlgorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps
Priority queue data type Lecture slides by Kevin Wayne Copyright 05 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos PRIORITY QUEUES binary heaps d-ary heaps binomial heaps Fibonacci
More informationBITTIGER #11. Oct
BITTIGER #11 Oct 22 2016 PROBLEM LIST A. Five in a Row brute force, implementation B. Building Heap data structures, divide and conquer C. Guess Number with Lower or Higher Hints dynamic programming, mathematics
More informationPrinciples of Program Analysis: Algorithms
Principles of Program Analysis: Algorithms Transparencies based on Chapter 6 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag 2005. c
More informationDevelopmental Math An Open Program Unit 12 Factoring First Edition
Developmental Math An Open Program Unit 12 Factoring First Edition Lesson 1 Introduction to Factoring TOPICS 12.1.1 Greatest Common Factor 1 Find the greatest common factor (GCF) of monomials. 2 Factor
More informationFibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04
Fibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04 1 Binary heap Binomial heap Fibonacci heap Procedure (worst-case) (worst-case) (amortized) Make-Heap Θ(1) Θ(1) Θ(1) Insert Θ(lg n) O(lg n) Θ(1)
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms Instructor: Sharma Thankachan Lecture 9: Binomial Heap Slides modified from Dr. Hon, with permission 1 About this lecture Binary heap supports various operations quickly:
More informationSum-Product: Message Passing Belief Propagation
Sum-Product: Message Passing Belief Propagation 40-956 Advanced Topics in AI: Probabilistic Graphical Models Sharif University of Technology Soleymani Spring 2015 All single-node marginals If we need the
More informationSum-Product: Message Passing Belief Propagation
Sum-Product: Message Passing Belief Propagation Probabilistic Graphical Models Sharif University of Technology Spring 2017 Soleymani All single-node marginals If we need the full set of marginals, repeating
More informationData Structures and Algorithms February 10, 2007 Pennsylvania State University CSE 465 Professors Sofya Raskhodnikova & Adam Smith Handout 10
Data Structures and Algorithms February 10, 2007 Pennsylvania State University CSE 465 Professors Sofya Raskhodnikova & Adam Smith Handout 10 Practice Exam 1 Do not open this exam booklet until you are
More informationThe following content is provided under a Creative Commons license. Your support
MITOCW Recitation 6 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make
More informationData Analysis and Statistical Methods Statistics 651
Data Analysis and Statistical Methods Statistics 651 http://wwwstattamuedu/~suhasini/teachinghtml Suhasini Subba Rao Review of previous lecture The main idea in the previous lecture is that the sample
More information******************************* The multi-period binomial model generalizes the single-period binomial model we considered in Section 2.
Derivative Securities Multiperiod Binomial Trees. We turn to the valuation of derivative securities in a time-dependent setting. We focus for now on multi-period binomial models, i.e. binomial trees. This
More informationDESCENDANTS IN HEAP ORDERED TREES OR A TRIUMPH OF COMPUTER ALGEBRA
DESCENDANTS IN HEAP ORDERED TREES OR A TRIUMPH OF COMPUTER ALGEBRA Helmut Prodinger Institut für Algebra und Diskrete Mathematik Technical University of Vienna Wiedner Hauptstrasse 8 0 A-00 Vienna, Austria
More information1 Binomial Tree. Structural Properties:
Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 0 Advanced Data Structures
More informationECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2017
ECON 459 Game Theory Lecture Notes Auctions Luca Anderlini Spring 2017 These notes have been used and commented on before. If you can still spot any errors or have any suggestions for improvement, please
More information6.854J / J Advanced Algorithms Fall 2008
MIT OpenCourseWare http://ocw.mit.edu 6.854J / 18.415J Advanced Algorithms Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advanced
More informationCEC login. Student Details Name SOLUTIONS
Student Details Name SOLUTIONS CEC login Instructions You have roughly 1 minute per point, so schedule your time accordingly. There is only one correct answer per question. Good luck! Question 1. Searching
More informationBinary Tree Applications
Binary Tree Applications Lecture 32 Section 19.2 Robb T. Koether Hampden-Sydney College Wed, Apr 17, 2013 Robb T. Koether (Hampden-Sydney College) Binary Tree Applications Wed, Apr 17, 2013 1 / 46 1 Expression
More informationInitializing A Max Heap. Initializing A Max Heap
Initializing A Max Heap 3 4 5 6 7 8 70 8 input array = [-,,, 3, 4, 5, 6, 7, 8,, 0, ] Initializing A Max Heap 3 4 5 6 7 8 70 8 Start at rightmost array position that has a child. Index is n/. Initializing
More information0/1 knapsack problem knapsack problem
1 (1) 0/1 knapsack problem. A thief robbing a safe finds it filled with N types of items of varying size and value, but has only a small knapsack of capacity M to use to carry the goods. More precisely,
More informationHeaps. c P. Flener/IT Dept/Uppsala Univ. AD1, FP, PK II Heaps 1
Heaps (Version of 21 November 2005) A min-heap (resp. max-heap) is a data structure with fast extraction of the smallest (resp. largest) item (in O(lg n) time), as well as fast insertion (also in O(lg
More informationFibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt..
Fibonacci Heaps You You can can submit submit Problem Problem Set Set 3 in in the the box box up up front. front. Outline for Today Review from Last Time Quick refresher on binomial heaps and lazy binomial
More information4.2 Probability Distributions
4.2 Probability Distributions Definition. A random variable is a variable whose value is a numerical outcome of a random phenomenon. The probability distribution of a random variable tells us what the
More informationPriority Queues. Fibonacci Heap
ibonacci Heap hans to Sartaj Sahni for the original version of the slides Operation mae-heap insert find-min delete-min union decrease-ey delete Priority Queues Lined List Binary Binomial Heaps ibonacci
More informationOn the Optimality of a Family of Binary Trees
On the Optimality of a Family of Binary Trees Dana Vrajitoru Computer and Information Sciences Department Indiana University South Bend South Bend, IN 46645 Email: danav@cs.iusb.edu William Knight Computer
More informationIt is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission
It is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission -The code can be described in terms of a binary tree -0 corresponds to
More informationMeld(Q 1,Q 2 ) merge two sets
Priority Queues MakeQueue Insert(Q,k,p) Delete(Q,k) DeleteMin(Q) Meld(Q 1,Q 2 ) Empty(Q) Size(Q) FindMin(Q) create new empty queue insert key k with priority p delete key k (given a pointer) delete key
More informationNOTES ON FIBONACCI TREES AND THEIR OPTIMALITY* YASUICHI HORIBE INTRODUCTION 1. FIBONACCI TREES
0#0# NOTES ON FIBONACCI TREES AND THEIR OPTIMALITY* YASUICHI HORIBE Shizuoka University, Hamamatsu, 432, Japan (Submitted February 1982) INTRODUCTION Continuing a previous paper [3], some new observations
More informationCMPSCI 311: Introduction to Algorithms Second Midterm Practice Exam SOLUTIONS
CMPSCI 311: Introduction to Algorithms Second Midterm Practice Exam SOLUTIONS November 17, 2016. Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question.
More informationis a path in the graph from node i to node i k provided that each of(i i), (i i) through (i k; i k )isan arc in the graph. This path has k ; arcs in i
ENG Engineering Applications of OR Fall 998 Handout The shortest path problem Consider the following problem. You are given a map of the city in which you live, and you wish to gure out the fastest route
More informationPARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES
PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES WIKTOR JAKUBIUK, KESHAV PURANMALKA 1. Introduction Dijkstra s algorithm solves the single-sourced shorest path problem on a
More informationIntroduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Splay Trees Date: 9/27/16
600.463 Introduction to lgoritms / lgoritms I Lecturer: Micael initz Topic: Splay Trees ate: 9/27/16 8.1 Introduction Today we re going to talk even more about binary searc trees. -trees, red-black trees,
More informationThe suffix binary search tree and suffix AVL tree
Journal of Discrete Algorithms 1 (2003) 387 408 www.elsevier.com/locate/jda The suffix binary search tree and suffix AVL tree Robert W. Irving, Lorna Love Department of Computing Science, University of
More informationSmoothed Analysis of Binary Search Trees
Smoothed Analysis of Binary Search Trees Bodo Manthey and Rüdiger Reischuk Universität zu Lübeck, Institut für Theoretische Informatik Ratzeburger Allee 160, 23538 Lübeck, Germany manthey/reischuk@tcs.uni-luebeck.de
More informationAlgorithmic Game Theory and Applications. Lecture 11: Games of Perfect Information
Algorithmic Game Theory and Applications Lecture 11: Games of Perfect Information Kousha Etessami finite games of perfect information Recall, a perfect information (PI) game has only 1 node per information
More informationSupporting Information
Supporting Information Novikoff et al. 0.073/pnas.0986309 SI Text The Recap Method. In The Recap Method in the paper, we described a schedule in terms of a depth-first traversal of a full binary tree,
More informationEmpirical and Average Case Analysis
Empirical and Average Case Analysis l We have discussed theoretical analysis of algorithms in a number of ways Worst case big O complexities Recurrence relations l What we often want to know is what will
More informationOutline for this Week
Binomial Heaps Outline for this Week Binomial Heaps (Today) A simple, fexible, and versatile priority queue. Lazy Binomial Heaps (Today) A powerful building block for designing advanced data structures.
More informationuseful than solving these yourself, writing up your solution and then either comparing your
CSE 441T/541T: Advanced Algorithms Fall Semester, 2003 September 9, 2004 Practice Problems Solutions Here are the solutions for the practice problems. However, reading these is far less useful than solving
More informationRecitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210!
Recitation 1 Solving Recurrences 1.1 Announcements Welcome to 1510! The course website is http://www.cs.cmu.edu/ 1510/. It contains the syllabus, schedule, library documentation, staff contact information,
More informationCS227-Scientific Computing. Lecture 6: Nonlinear Equations
CS227-Scientific Computing Lecture 6: Nonlinear Equations A Financial Problem You invest $100 a month in an interest-bearing account. You make 60 deposits, and one month after the last deposit (5 years
More informationLecture 10/12 Data Structures (DAT037) Ramona Enache (with slides from Nick Smallbone and Nils Anders Danielsson)
Lecture 10/12 Data Structures (DAT037) Ramona Enache (with slides from Nick Smallbone and Nils Anders Danielsson) Balanced BSTs: Problem The BST operahons take O(height of tree), so for unbalanced trees
More informationPriority queue. Advanced Algorithmics (6EAP) Binary heap. Heap/Priority queue. Binomial heaps: Merge two heaps.
Priority queue Advanced Algorithmics (EAP) MTAT.03.38 Heaps Jaak Vilo 0 Spring Insert Q, x Retrieve x from Q s.t. x.value is min (or max) Sorted linked list: O(n) to insert x into right place O() access-
More informationBioinformatics - Lecture 7
Bioinformatics - Lecture 7 Louis Wehenkel Department of Electrical Engineering and Computer Science University of Liège Montefiore - Liège - November 20, 2007 Find slides: http://montefiore.ulg.ac.be/
More information15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018
15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018 Today we ll be looking at finding approximately-optimal solutions for problems
More informationUNIT 2. Greedy Method GENERAL METHOD
UNIT 2 GENERAL METHOD Greedy Method Greedy is the most straight forward design technique. Most of the problems have n inputs and require us to obtain a subset that satisfies some constraints. Any subset
More informationCIS 540 Fall 2009 Homework 2 Solutions
CIS 54 Fall 29 Homework 2 Solutions October 25, 29 Problem (a) We can choose a simple ordering for the variables: < x 2 < x 3 < x 4. The resulting OBDD is given in Fig.. x 2 x 2 x 3 x 4 x 3 Figure : OBDD
More informationDynamic Programming cont. We repeat: The Dynamic Programming Template has three parts.
Page 1 Dynamic Programming cont. We repeat: The Dynamic Programming Template has three parts. Subproblems Sometimes this is enough if the algorithm and its complexity is obvious. Recursion Algorithm Must
More informationMaximum Contiguous Subsequences
Chapter 8 Maximum Contiguous Subsequences In this chapter, we consider a well-know problem and apply the algorithm-design techniques that we have learned thus far to this problem. While applying these
More informationOptimal Satisficing Tree Searches
Optimal Satisficing Tree Searches Dan Geiger and Jeffrey A. Barnett Northrop Research and Technology Center One Research Park Palos Verdes, CA 90274 Abstract We provide an algorithm that finds optimal
More informationDecision Trees Decision Tree
Decision Trees The Payoff Table and the Opportunity Loss Table are two very similar ways of looking at a Decision Analysis problem. Another way of seeing the structure of the problem is the Decision Tree.
More informationQ1. [?? pts] Search Traces
CS 188 Spring 2010 Introduction to Artificial Intelligence Midterm Exam Solutions Q1. [?? pts] Search Traces Each of the trees (G1 through G5) was generated by searching the graph (below, left) with a
More informationOutline for Today. Quick refresher on binomial heaps and lazy binomial heaps. An important operation in many graph algorithms.
Fibonacci Heaps Outline for Today Review from Last Time Quick refresher on binomial heaps and lazy binomial heaps. The Need for decrease-key An important operation in many graph algorithms. Fibonacci Heaps
More informationLecture 8 Feb 16, 2017
CS 4: Advanced Algorithms Spring 017 Prof. Jelani Nelson Lecture 8 Feb 16, 017 Scribe: Tiffany 1 Overview In the last lecture we covered the properties of splay trees, including amortized O(log n) time
More information