CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions

Size: px
Start display at page:

Download "CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions"

Transcription

1 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 quarter. Problems should be solved together, not divided up between partners. A single representative of your group should submit your work through Gradescope. Submissions must be received by 11:59pm on the due date, and there are no exceptions to this rule. Homework solutions should be neatly written or typed and turned in through Gradescope by 11:59pm on the due date. No late homeworks will be accepted for any reason. You will be able to look at your scanned work before submitting it. Please ensure that your submission is legible (neatly written and not too faint or your homework may not be graded. Students should consult their textbook, class notes, lecture slides, instructors, TAs, and tutors when they need help with homework. Students should not look for answers to homework problems in other texts or sources, including the internet. Only post about graded homework questions on Piazza if you suspect a typo in the assignment, or if you don t understand what the question is asking you to do. Other questions are best addressed in office hours. Your assignments in this class will be evaluated not only on the correctness of your answers, but on your ability to present your ideas clearly and logically. You should always explain how you arrived at your conclusions, using mathematically sound reasoning. Whether you use formal proof techniques or write a more informal argument for why something is true, your answers should always be well-supported. Your goal should be to convince the reader that your results and methods are sound. For questions that require pseudocode, you can follow the same format as the textbook, or you can write pseudocode in your own style, as long as you specify what your notation means. For example, are you using = to mean assignment or to check equality? You are welcome to use any algorithm from class as a subroutine in your pseudocode. For example, if you want to sort list A using InsertionSort, you can call InsertionSort(A instead of writing out the pseudocode for InsertionSort. Required Reading Rosen 10.4 through Theorem 1, 11.1, 11. through Theorem Key Concepts Rooted and unrooted trees, binary search trees, basic counting principles (sum and product rules, inclusion-exclusion, quotient (category rule, coding, coding 1

2 1. A binomial tree is a special kind of rooted tree used for various data structures in computer science. A degree d binomial tree can be defined recursively as follows. A degree 0 binomial tree is a single vertex with no edges. A degree d binomial tree has a root vertex with out-degree d. The first (that is, leftmost subtree is a degree d 1 binomial tree. The second (that is, second to left subtree is a degree d binomial tree. Continue on in this way so that the last (rightmost subtree is a degree 0 binomial tree. (a ( points Draw binomial trees of degree 1,, 3, and 4. Solution: Binomial trees of degrees 1 through 4 appear from left to right. (b (3 points What is the height h(d of a degree d binomial tree? Prove your result by induction on d. Solution: A binomial tree of degree d has a height of d. We prove this statement by strong induction. Base case: When d = 0 the tree is just one node, so it has a height of 0. Strong induction hypothesis: Suppose that for all degrees d less than or equal to some positive integer k, a binomial tree of degree d has a height of d. Suppose we have a binomial tree of degree k + 1. Its root has children of degrees k,k-1, By our induction hypothesis, the subtree rooted at the child of degree k has a height k (and this is the maximum height of all children subtrees. Thus the height of our binomial tree is k + 1. (c ( points Write a recurrence for the number of nodes n(d in a binomial tree of degree d. Solution: n(d = n(0 + n(1 + n( +... n(d 1 + 1; n(0 = 1 (d (3 points Use the guess-and-check method to guess a formula for n(d. Prove that your formula holds by induction on d. Solution: We guess that n(d = d and prove our guess by strong induction on d. Base case: When d = 0 the tree is just one node so n(0 = 1, which is equal to d = 0. Strong induction hypothesis: Suppose that for all degrees d less or equal to some positive integer k, we have that n(d = d. Proof of statement for k + 1 Suppose we have a binomial tree of degree k + 1. Its root has children of degrees k,k-1, As was given in the recurrence from part (c, the number of nodes in the whole tree is equal to the

3 number of nodes in all of the root s subtrees plus 1 (for the root. Using this recurrence along with our induction hypothesis we get: n(k + 1 = n(0 + n(1 + n( +... n(k + 1 = k + 1 (by IH = k+1. Give an algorithm that, given a vertex in a binary search tree x with associated value V (x, finds the successor of that value, the vertex y with the smallest value V (y with V (y > V (x. Your algorithm should run in time O(h, where h is the height of the binary search tree. ( points correct algorithm, points correctness proof, 1 point time analysis. Then use this algorithm to give another algorithm that given the root r of a binary search tree of size n and a number 1 k n, outputs a sorted list of the k smallest values in the tree. This algorithm should run in time O(hk. ( points correct algorithm, points correctness proof, 1 point time analysis. Say the succesor exists and is at vertex y. Consider the paths from the root to x and to y. At some point, these paths must differ. Since the value at y is greater than that of x, at the first difference, the path to y must end or go right, and the path to x must end or go left. If the path to y goes right, that to x must end, since otherwise the value of the vertex where x goes left and y goes right is intermediate between the two values. Then y is in the right sub-tree of x, and must have the smallest value in this subtree (since any smaller value in the subtree would be intermediate between x s and y s values. We can find y in this case as follows: Go to the right child of x (which must exist in this case. Then go left until the left child no longer exists. This will end at y. Since we only go down in the tree, this process will take no more time than the height of the tree. If the path to y ends, x must be in the left-subtree of y and must have the greatest value in this subtree, for any value in this sub-tree greater than x would be intermediate between x and y s values. If we follow the path from y to x, then, we must go left as the first step, and from then on, go right. So to find y, we follow the path starting at x to its ancestors, and the first step that went from a left-child must end at y. This method always goes up in the tree, so its time is at most O(h. If we don t know what case we were in, we could do both above and compare the results. But actually, the first case can only happen if x has a right child, and the second can only happen if x does not have a right child. So we could first look to see if x s right child pointer is null, and use that to decide whether to look up the tree or down the tree. If x has no right child, and we go all the way to the root without a left turn, then x had the largest value in the tree, and we output no successor exists. To get the smallest k elements using the above method, we can find the smallest element in the tree by going left until the left-child is null, and then using the above method k = 1 times to get the next smallest k 1 elements in order. Since finding the smallest and the successor are both O(h time, and we use it k times, the total time would be O(hk. However, this is too pessimistic (although it is full credit. The total time is actually the smaller of O(h + k and O(n, where n is the size of the tree. If you don t care about this, skip the rest. We can view the algorithm recursively as follows: InOrder (r: root; k: integer: returns the k smallest elements of the tree rooted at r, or all of them if k n. (a If r = NUL return the empty list. (b If k = 0 return the empty list (c If left(r = NUL, return r InOrder(right(r, k 1. (d L InOrder(left(r, k. 3

4 (e IF L = k return L (f IF L = k 1 return L r (g Return L r InOrder(right(r, k 1 L. We will prove the time analysis by strong induction on n. For constants c and d, the time is at most c min((h + k, n and at most dn. We can pick c to make the base case n = 1 true. For the induction step, consider running the algorithm to find the smallest k elements in a tree of height h and size n. Let n L and n R be the number of vertices in the left and right sub-trees. The total time for our algorithm is at most the time to make a recursive call to n L and to n R, plus a constant c. So the total time is at most cn L + cn R + c cn. So the time is at most linear. Also, if n L > k 1, we actually will only make one recursive call, since L will have at least k 1 values in line 4. Since the height of the left sub-tree is at most h 1. the total time will be at most c(k + h 1 + c c(h + k. Otherwise, the first call takes time at most cn L and will return all n L values in the left sub-tree. Then the second call will take time at most c(k n L 1 + c(h 1 and the total time will be at most cn L + c(k n L 1 + c(h 1 + c < c(k + h. So the algorithm is actually linear time in the greater of the height and the number of elements you return. A three coloring of a graph labels each vertex v with one of three colors, say R, B or G, so that the two endpoints of any edge have different colors. Consider an undirected graph which is a single path, i.e., where the vertices are v 1...v n, and there is an edge between each v i and v i+1 for i = 1..n 1. How many 3 colorings does this graph have? ( points correct answer. 1 point short explanation. How many bits are required to describe such a 3-coloring? ( points correct answer, 1 point short explanation Give coding and decoding algorithms that given the 3-coloring, outputs a string of the length above that codes it, and given the code, outputs the original 3-coloring. (3 points algorithm description, 1 point short explanation. We can choose any of the three colors for v 1. From then on, we must choose one of two colors for v i+1, either of the two colors not used for v i. This gives 3 n 1 possible colorings. To represent such a coloring, we will need log (3 n 1 bits, or after algebraic simplification occurs, + n 1 = n + 1. The reason above for the number of colors also inspires an efficient encoding. We give each color a two bit name, and use the first two bits to describe the color of v 1. Organize the colors in a triangle. If color of v i+1 is clockwise from that of v i, write 1 as the i + nd bit of the code, and otherwise write 0. To decode, we reverse the process. We use the first two bits to get the color of v 1, and then if the i + nd bit is 1, we give v i+1 the color that is clockwise from taht of v i, and else give it the one that is counter-clockwise. Since we are using bits for the first color and 1 bit each for the remaining n 1, the code has the optimal length of n A normal deck of cards has, for each of 13 possible values (..10, J,K,Q,A, one card with that face value for each of the four suits (hearts, spades, diamonds, clubs. A can either be the highest or lowest value. Compute the number of five card hands (unordered sets of five distinct cards with the following properties ( points each, You can leave your answer in terms of factorials or binomial co-efficients. 1 point correct answer, 1 point explanation: (a The highest value card in the hand is 9 (and aces count higher than 9. The easiest solution is to subtract hands that have only...8 s from the number of hands that have only..9. I.e., remove from the number of hands with highest card at most 9, those that have highest value strictly less. There are 3 cards with values...9, and 8 with values...8. Since we are picking any five of them, the total is ( ( 3 5 = 8 (b Two pairs: there are two pairs with the same value, but no three have the same value. Lets first select the three face values involved, and then the suits of the cards with those face values. However, a subtle point is that the two pairs are symmetric to each other but not to the singleton. So we pick the two face values for the two pairs in ( 13 ways, leaving 11 face values for the singleton. For the two pairs we then pick of the four suits, and one of the four for the singleton. This gives a total of ( ( 4 ( 4 1 = (13 1/ 11 (4 3/ 4. 4

5 There are many other ways to think about it that give the same answer, but there are also many ways to think about it incorrectly that give you the wrong answer. (c Flush: All cards have the same suit If we pick the suit first, we can pick any five of the thirteen cards of that suit. So the total is r ( 13 (d Have at least one card of each suit. Like the two pairs example, we need to think about symmetric vs. non-symmetric choices. Three of the suits will have exactly one card, and one will have two. There are four ways to pick the one with two. Then the two cards of this suit will be symmetric, but the others will be unique. This gives a total of 4 ( hands. (e Have at least one royal card (J,K,Q. Like the first problem, it is easier to count the hands that do not have a royal and subtract that from the total number of hands. This gives ( ( 5 5 = There are n people in the tennis club who want to play (individual tennis. How many different ways are there of pairing them up into n matches so that each member is in exactly one match? You can leave your answer in terms of factorials or binomial co-efficients. (5 points correct answer, 5 points explanation. This uses the categories method. Say we present a roster of matches, of the form P 1 vs.p, P 3 vsp 4,..P n 1 vs.p n. We can make such a roster using any of the (n! orders of the n players. But different lists are identical if they just involve permuting the order of the n matches or switching the order pairs of matched players appear. This means rosters come in categories of n! n equivalent rosters. So the total number of matchings is (n!/(n! n = (n 1(n

1 Solutions to Tute09

1 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 information

On the Optimality of a Family of Binary Trees Techical Report TR

On 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 information

2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes

2 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 information

SET 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. 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 information

CMPSCI 311: Introduction to Algorithms Second Midterm Practice Exam SOLUTIONS

CMPSCI 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 information

Homework #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 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 information

Structural Induction

Structural Induction Structural Induction Jason Filippou CMSC250 @ UMCP 07-05-2016 Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 1 / 26 Outline 1 Recursively defined structures 2 Proofs Binary Trees Jason

More information

CSCE 750, Fall 2009 Quizzes with Answers

CSCE 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 information

Fundamental Algorithms - Surprise Test

Fundamental 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 information

Course Information and Introduction

Course Information and Introduction August 20, 2015 Course Information 1 Instructor : Email : arash.rafiey@indstate.edu Office : Root Hall A-127 Office Hours : Tuesdays 12:00 pm to 1:00 pm in my office (A-127) 2 Course Webpage : http://cs.indstate.edu/

More information

A relation on 132-avoiding permutation patterns

A relation on 132-avoiding permutation patterns Discrete Mathematics and Theoretical Computer Science DMTCS vol. VOL, 205, 285 302 A relation on 32-avoiding permutation patterns Natalie Aisbett School of Mathematics and Statistics, University of Sydney,

More information

COSC160: Data Structures Binary Trees. Jeremy Bolton, PhD Assistant Teaching Professor

COSC160: 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 information

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1.

AVL 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 information

On the Optimality of a Family of Binary Trees

On 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 information

Introduction to Greedy Algorithms: Huffman Codes

Introduction 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 information

Recitation 1. Solving Recurrences. 1.1 Announcements. Welcome to 15210!

Recitation 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 information

Sublinear Time Algorithms Oct 19, Lecture 1

Sublinear 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 information

Practical session No. 5 Trees

Practical 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 information

Successor. CS 361, Lecture 19. Tree-Successor. Outline

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 information

Maximum Contiguous Subsequences

Maximum 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 information

Discrete Mathematics for CS Spring 2008 David Wagner Final Exam

Discrete Mathematics for CS Spring 2008 David Wagner Final Exam CS 70 Discrete Mathematics for CS Spring 2008 David Wagner Final Exam PRINT your name:, (last) SIGN your name: (first) PRINT your Unix account login: Your section time (e.g., Tue 3pm): Name of the person

More information

UNIT VI TREES. Marks - 14

UNIT 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 information

MAC Learning Objectives. Learning Objectives (Cont.)

MAC Learning Objectives. Learning Objectives (Cont.) MAC 1140 Module 12 Introduction to Sequences, Counting, The Binomial Theorem, and Mathematical Induction Learning Objectives Upon completing this module, you should be able to 1. represent sequences. 2.

More information

Fibonacci 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 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 information

Ch 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 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 information

Lecture l(x) 1. (1) x X

Lecture 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 information

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES CSE 100: TREAPS AND RANDOMIZED SEARCH TREES Midterm Review Practice Midterm covered during Sunday discussion Today Run time analysis of building the Huffman tree AVL rotations and treaps Huffman s algorithm

More information

Binary Decision Diagrams

Binary Decision Diagrams Binary Decision Diagrams Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: zheng@cse.usf.edu Phone: (813)974-4757 Fax: (813)974-5456 Hao Zheng

More information

1 Binomial Tree. Structural Properties:

1 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 information

MSU CSE Spring 2011 Exam 2-ANSWERS

MSU CSE Spring 2011 Exam 2-ANSWERS MSU CSE 260-001 Spring 2011 Exam 2-NSWERS Name: This is a closed book exam, with 9 problems on 5 pages totaling 100 points. Integer ivision/ Modulo rithmetic 1. We can add two numbers in base 2 by using

More information

Design and Analysis of Algorithms

Design 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 information

LECTURE 2: MULTIPERIOD MODELS AND TREES

LECTURE 2: MULTIPERIOD MODELS AND TREES LECTURE 2: MULTIPERIOD MODELS AND TREES 1. Introduction One-period models, which were the subject of Lecture 1, are of limited usefulness in the pricing and hedging of derivative securities. In real-world

More information

Supporting Information

Supporting 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 information

Binary Decision Diagrams

Binary Decision Diagrams Binary Decision Diagrams Hao Zheng Department of Computer Science and Engineering University of South Florida Tampa, FL 33620 Email: zheng@cse.usf.edu Phone: (813)974-4757 Fax: (813)974-5456 Hao Zheng

More information

Practical session No. 5 Trees

Practical 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 information

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants Due Wednesday March 12, 2014. CS 20 students should bring a hard copy to class. CSCI

More information

Chapter 16. Binary Search Trees (BSTs)

Chapter 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 information

Algorithmic Game Theory and Applications. Lecture 11: Games of Perfect Information

Algorithmic 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 information

MAT385 Final (Spring 2009): Boolean Algebras, FSM, and old stuff

MAT385 Final (Spring 2009): Boolean Algebras, FSM, and old stuff MAT385 Final (Spring 2009): Boolean Algebras, FSM, and old stuff Name: Directions: Problems are equally weighted. Show your work! Answers without justification will likely result in few points. Your written

More information

Heaps

Heaps 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 information

The Binomial Theorem and Consequences

The Binomial Theorem and Consequences The Binomial Theorem and Consequences Juris Steprāns York University November 17, 2011 Fermat s Theorem Pierre de Fermat claimed the following theorem in 1640, but the first published proof (by Leonhard

More information

Lecture 4: Divide and Conquer

Lecture 4: Divide and Conquer Lecture 4: Divide and Conquer Divide and Conquer Merge sort is an example of a divide-and-conquer algorithm Recall the three steps (at each level to solve a divideand-conquer problem recursively Divide

More information

Outline for this Week

Outline 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 information

Node betweenness centrality: the definition.

Node betweenness centrality: the definition. Brandes algorithm These notes supplement the notes and slides for Task 11. They do not add any new material, but may be helpful in understanding the Brandes algorithm for calculating node betweenness centrality.

More information

Tug of War Game. William Gasarch and Nick Sovich and Paul Zimand. October 6, Abstract

Tug of War Game. William Gasarch and Nick Sovich and Paul Zimand. October 6, Abstract Tug of War Game William Gasarch and ick Sovich and Paul Zimand October 6, 2009 To be written later Abstract Introduction Combinatorial games under auction play, introduced by Lazarus, Loeb, Propp, Stromquist,

More information

Heaps. Heap/Priority queue. Binomial heaps: Advanced Algorithmics (4AP) Heaps Binary heap. Binomial heap. Jaak Vilo 2009 Spring

Heaps. 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 information

Practical SAT Solving

Practical SAT Solving Practical SAT Solving Lecture 1 Carsten Sinz, Tomáš Balyo April 18, 2016 NSTITUTE FOR THEORETICAL COMPUTER SCIENCE KIT University of the State of Baden-Wuerttemberg and National Laboratory of the Helmholtz

More information

Outline for this Week

Outline 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

The potential function φ for the amortized analysis of an operation on Fibonacci heap at time (iteration) i is given by the following equation:

The potential function φ for the amortized analysis of an operation on Fibonacci heap at time (iteration) i is given by the following equation: Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 01 Advanced Data Structures

More information

COMP Analysis of Algorithms & Data Structures

COMP 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 information

Lecture 6. 1 Polynomial-time algorithms for the global min-cut problem

Lecture 6. 1 Polynomial-time algorithms for the global min-cut problem ORIE 633 Network Flows September 20, 2007 Lecturer: David P. Williamson Lecture 6 Scribe: Animashree Anandkumar 1 Polynomial-time algorithms for the global min-cut problem 1.1 The global min-cut problem

More information

Chapter 15 - The Binomial Formula PART

Chapter 15 - The Binomial Formula PART Chapter 15 - The Binomial Formula PART IV : PROBABILITY Dr. Joseph Brennan Math 148, BU Dr. Joseph Brennan (Math 148, BU) Chapter 15 - The Binomial Formula 1 / 19 Pascal s Triangle In this chapter we explore

More information

PRIORITY 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 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 information

UNIT 2. Greedy Method GENERAL METHOD

UNIT 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 information

arxiv: v1 [math.co] 31 Mar 2009

arxiv: v1 [math.co] 31 Mar 2009 A BIJECTION BETWEEN WELL-LABELLED POSITIVE PATHS AND MATCHINGS OLIVIER BERNARDI, BERTRAND DUPLANTIER, AND PHILIPPE NADEAU arxiv:0903.539v [math.co] 3 Mar 009 Abstract. A well-labelled positive path of

More information

CSE 417 Algorithms. Huffman Codes: An Optimal Data Compression Method

CSE 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 information

Algorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps

Algorithms 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 information

Binary 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 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 information

Lecture 2. Multinomial coefficients and more counting problems

Lecture 2. Multinomial coefficients and more counting problems 18.440: Lecture 2 Multinomial coefficients and more counting problems Scott Sheffield MIT 1 Outline Multinomial coefficients Integer partitions More problems 2 Outline Multinomial coefficients Integer

More information

Advanced Algorithmics (4AP) Heaps

Advanced 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 information

ECE 586GT: Problem Set 1: Problems and Solutions Analysis of static games

ECE 586GT: Problem Set 1: Problems and Solutions Analysis of static games University of Illinois Fall 2018 ECE 586GT: Problem Set 1: Problems and Solutions Analysis of static games Due: Tuesday, Sept. 11, at beginning of class Reading: Course notes, Sections 1.1-1.4 1. [A random

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 3 Tuesday, February 2, 2016 1 Inductive proofs, continued Last lecture we considered inductively defined sets, and

More information

Binomial Coefficient

Binomial Coefficient Binomial Coefficient This short text is a set of notes about the binomial coefficients, which link together algebra, combinatorics, sets, binary numbers and probability. The Product Rule Suppose you are

More information

PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES

PARELLIZATION 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 information

Practice Second Midterm Exam II

Practice Second Midterm Exam II CS13 Handout 34 Fall 218 November 2, 218 Practice Second Midterm Exam II This exam is closed-book and closed-computer. You may have a double-sided, 8.5 11 sheet of notes with you when you take this exam.

More information

Mathematics Success Grade 8

Mathematics Success Grade 8 Mathematics Success Grade 8 T379 [OBJECTIVE] The student will derive the equation of a line and use this form to identify the slope and y-intercept of an equation. [PREREQUISITE SKILLS] Slope [MATERIALS]

More information

Outline for Today. Quick refresher on binomial heaps and lazy binomial heaps. An important operation in many graph algorithms.

Outline 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 information

The following content is provided under a Creative Commons license. Your support

The 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 information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 3 Tuesday, January 30, 2018 1 Inductive sets Induction is an important concept in the theory of programming language.

More information

The Tree Data Model. Laura Kovács

The Tree Data Model. Laura Kovács The Tree Data Model Laura Kovács Trees (Baumstrukturen) Definition Trees are sets of points, called nodes (Knoten) and lines, called edges (Kanten), connecting two distinct nodes, such that: n 2 n 3 n

More information

Sequential allocation of indivisible goods

Sequential allocation of indivisible goods 1 / 27 Sequential allocation of indivisible goods Thomas Kalinowski Institut für Mathematik, Universität Rostock Newcastle Tuesday, January 22, 2013 joint work with... 2 / 27 Nina Narodytska Toby Walsh

More information

Notes on Natural Logic

Notes on Natural Logic Notes on Natural Logic Notes for PHIL370 Eric Pacuit November 16, 2012 1 Preliminaries: Trees A tree is a structure T = (T, E), where T is a nonempty set whose elements are called nodes and E is a relation

More information

Binary Tree Applications

Binary 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 information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶

Design 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 information

Yao s Minimax Principle

Yao 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 information

Counting Basics. Venn diagrams

Counting Basics. Venn diagrams Counting Basics Sets Ways of specifying sets Union and intersection Universal set and complements Empty set and disjoint sets Venn diagrams Counting Inclusion-exclusion Multiplication principle Addition

More information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶

Design 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 information

Fibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04

Fibonacci 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 information

Week 3: Binomials Coefficients. 26 & 28 September MA204/MA284 : Discrete Mathematics. Niall Madden (and Emil Sköldberg)

Week 3: Binomials Coefficients. 26 & 28 September MA204/MA284 : Discrete Mathematics. Niall Madden (and Emil Sköldberg) (1/22) qz0z0z0z LNZ0Z0Z0 0mkZ0Z0Z Z0Z0Z0Z0 0Z0Z0Z0Z Z0Z0Z0Z0 0Z0Z0Z0Z Z0Z0Z0Z0 pz0z0z0z OpO0Z0Z0 0ZKZ0Z0Z Z0Z0Z0Z0 0Z0Z0Z0Z Z0Z0Z0Z0 0Z0Z0Z0Z Z0Z0Z0Z0 MA204/MA284 : Discrete Mathematics Week 3: Binomials

More information

Final Project. College Algebra. Upon successful completion of this course, the student will be able to:

Final Project. College Algebra. Upon successful completion of this course, the student will be able to: COURSE OBJECTIVES Upon successful completion of this course, the student will be able to: 1. Perform operations on algebraic expressions 2. Perform operations on functions expressed in standard function

More information

Algorithms and Networking for Computer Games

Algorithms and Networking for Computer Games Algorithms and Networking for Computer Games Chapter 4: Game Trees http://www.wiley.com/go/smed Game types perfect information games no hidden information two-player, perfect information games Noughts

More information

NOTES ON FIBONACCI TREES AND THEIR OPTIMALITY* YASUICHI HORIBE INTRODUCTION 1. FIBONACCI TREES

NOTES 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 information

Priority 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 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 information

Notes on the symmetric group

Notes on the symmetric group Notes on the symmetric group 1 Computations in the symmetric group Recall that, given a set X, the set S X of all bijections from X to itself (or, more briefly, permutations of X) is group under function

More information

Data 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 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 information

TEST 1 SOLUTIONS MATH 1002

TEST 1 SOLUTIONS MATH 1002 October 17, 2014 1 TEST 1 SOLUTIONS MATH 1002 1. Indicate whether each it below exists or does not exist. If the it exists then write what it is. No proofs are required. For example, 1 n exists and is

More information

Q1. [?? pts] Search Traces

Q1. [?? 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 information

CEC login. Student Details Name SOLUTIONS

CEC 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 information

Bioinformatics - Lecture 7

Bioinformatics - 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 information

Design and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶

Design 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 information

Lecture 10: The knapsack problem

Lecture 10: The knapsack problem Optimization Methods in Finance (EPFL, Fall 2010) Lecture 10: The knapsack problem 24.11.2010 Lecturer: Prof. Friedrich Eisenbrand Scribe: Anu Harjula The knapsack problem The Knapsack problem is a problem

More information

CH 39 CREATING THE EQUATION OF A LINE

CH 39 CREATING THE EQUATION OF A LINE 9 CH 9 CREATING THE EQUATION OF A LINE Introduction S ome chapters back we played around with straight lines. We graphed a few, and we learned how to find their intercepts and slopes. Now we re ready to

More information

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking!

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking! CMSC 630 March 13, 2007 1 CTL Model Checking Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking! Mathematically, M is a model of σ if s I = M

More information

Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros

Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros Midterm #1, February 3, 2017 Name (use a pen): Student ID (use a pen): Signature (use a pen): Rules: Duration of the exam: 50 minutes. By

More information

1) S = {s}; 2) for each u V {s} do 3) dist[u] = cost(s, u); 4) Insert u into a 2-3 tree Q with dist[u] as the key; 5) for i = 1 to n 1 do 6) Identify

1) S = {s}; 2) for each u V {s} do 3) dist[u] = cost(s, u); 4) Insert u into a 2-3 tree Q with dist[u] as the key; 5) for i = 1 to n 1 do 6) Identify CSE 3500 Algorithms and Complexity Fall 2016 Lecture 17: October 25, 2016 Dijkstra s Algorithm Dijkstra s algorithm for the SSSP problem generates the shortest paths in nondecreasing order of the shortest

More information

Math 14 Lecture Notes Ch The Normal Approximation to the Binomial Distribution. P (X ) = nc X p X q n X =

Math 14 Lecture Notes Ch The Normal Approximation to the Binomial Distribution. P (X ) = nc X p X q n X = 6.4 The Normal Approximation to the Binomial Distribution Recall from section 6.4 that g A binomial experiment is a experiment that satisfies the following four requirements: 1. Each trial can have only

More information

Algebra homework 8 Homomorphisms, isomorphisms

Algebra homework 8 Homomorphisms, isomorphisms MATH-UA.343.005 T.A. Louis Guigo Algebra homework 8 Homomorphisms, isomorphisms For every n 1 we denote by S n the n-th symmetric group. Exercise 1. Consider the following permutations: ( ) ( 1 2 3 4 5

More information

IEOR E4004: Introduction to OR: Deterministic Models

IEOR E4004: Introduction to OR: Deterministic Models IEOR E4004: Introduction to OR: Deterministic Models 1 Dynamic Programming Following is a summary of the problems we discussed in class. (We do not include the discussion on the container problem or the

More information

Microeconomics of Banking: Lecture 5

Microeconomics of Banking: Lecture 5 Microeconomics of Banking: Lecture 5 Prof. Ronaldo CARPIO Oct. 23, 2015 Administrative Stuff Homework 2 is due next week. Due to the change in material covered, I have decided to change the grading system

More information

Notes on the EM Algorithm Michael Collins, September 24th 2005

Notes on the EM Algorithm Michael Collins, September 24th 2005 Notes on the EM Algorithm Michael Collins, September 24th 2005 1 Hidden Markov Models A hidden Markov model (N, Σ, Θ) consists of the following elements: N is a positive integer specifying the number of

More information