ANS:
|
|
- Alexia Greer
- 5 years ago
- Views:
Transcription
1 Math 15-Spring 17-Final Exam Solutions 1. Consider the following definition of the symbol. Definition. Let x and y be integers. Write x y if 5x + 7y = 11k for some integer k. (a) Show that 1 4, 2 8, and = 11 3, = 11 6, and = 11 5 (b) Find a counterexample to the following statement: If a b and c d, then a c b d. 1 4 and 4 5, but 4 20, since = 160 is not a multiple of To prove a statement of the form ( x)(p (x) Q(x)), using contraposition, begin your proof with a sentence of the form Let x be [an element of the domain], and suppose Q(x). Then write a sequence of justified conclusions culminating in P (x). Use this method to prove the following: Let n be an integer. If n 2 + n + 1 is even, then n is odd. Let n Z and suppose n 2Z, then k Z n = 2k. This means that n 2 + n = (2k) 2 + 2k = 2(2k 2 + k) is even, so n 2 + n + 1 is odd. The odd thing about this proof, of course, is that n 2 + n + 1 is always odd! 3. Draw an undirected graph G with the following properties. The vertices of G correspond to the elements of the power set P ({0, 1, 2}). Two vertices (corresponding to A, B P ({0, 1, 2})) are connected by an edge if and only if A B =. {1, 2, 3} {2, 3} {1} {1, 3} {2} {1, 2} {3} 4. Construct addition and multiplication tables for Z/7. (only use equivalence class representatives in {0, 1, 2, 3, 4, 5, 6})
2 5. A partition of a positive integer n is a list of positive integers a 1, a 2,..., a k such that a 1 +a 2 + +a k = n. For example, the partitions of 5 are {5}, {1, 4}, {2, 3}, {1, 1, 3}, {1, 2, 2}, {1, 1, 1, 2}, {1, 1, 1, 1, 1}. The order of the list doesn t matter. There is a natural partial ordering on the set of partitions of n: if P 1 and P 2 are partitions, define P 1 P 2 if P 1 can be obtained by combining parts of P 2. For example, {1, 2, 2} {1, 1, 1, 1, 1} because {1, 2, 2} = {1, 1 + 1, 1 + 1}. On the other hand, {2, 3} and {1, 4} are incomparable elements in this poset. (a) Write the partitions of 6 in a Hasse diagram. (There are 11 partitions of 6.) (b) If a poset (X, ) has no incomparable elements, it is called a total ordering. For example, the real numbers R are totally ordered by the relation. Is the above ordering on the partitions of 6 a total ordering? Why or why not? No. There are incomparable elements, (e.g., 3,3 and 2,2,2). 6. The complete bipartite graph K m,n is the simple undirected graph with m + n vertices split into two sets V 1 and V 2 ( V 1 = m, V 2 = n) such that vertices x, y share an edge if and only if x V 1 and y V 2. (a) Draw K 3,3. How many edges does it have? l 1 r 1 l 2 r 2 l 3 r 3 K 3,3 has 9 edges. (b) How many edges does K n,n have? How do you know? Since forming an edge means choosing 1 of the vertices on the left and 1 of the vertices on Page 2
3 the right, and there are n choices for each, the number of edges is n n = n 2. (c) Let E(n) be the number of edges in K n,n. Clearly, E(1) = 1. Write E(n) in terms of E(n 1) for n > 1. E(n) = E(n 1) + 2n 1 For instance, E(3) = E(2) + 5 = Analyze the sequence 2, 7, 34, 91, 190 using sequences of differences. (a) From what degree polynomial does this sequence appear to be drawn? (Don t bother finding the coefficients of the polynomial.) p(x) Evidently, the third-order difference are the same, so the polynomial is cubic. (b) What would the next number in the sequence be? Given that the third order difference of the next term will be 12, the second order difference would be 54, the first order difference would be 153 and p(x next ) = Define a set X of numbers as follows. B. 5 X. R 1. If x X, so is 3x. R 2. If x X, so is x + 6. (a) List, in order, all the elements of X that are less than 50. {x x X and x < 50} = {5, 11, 15, 17, 21, 23, 27, 29, 33, 35, 39, 41, 45, 47} (b) Use induction to prove that every element of X is odd. Base case: 5 is odd. Assume that x X is odd, then x = 2k + 1 for some k Z both x + 6 = 2(k + 3) + 1 and 3x = 2(3k + 1) + 1 are odd, so all elements of X are odd. 9. Recall the definition for a sorted list: Definition An SList is B. x where x R, the real numbers. R. (X, Y ) where X and Y are SLists having the same number of elements, and the last number in X Page 3
4 is less than the first number in Y. Let L be an SList. Define a recursive function Dubup as follows. B. Suppose L = x. Then Dubup(L) = 2x+1. R. Suppose L = (X, Y ). Then Dubup(L) =Dubup(X)+Dubup(Y ). (a) Evaluate Dubup(((1, 2), (3, 4))), showing all steps. Dubup(((1, 2), (3, 4))) =Dubup((1, 2))+Dubup((3, 4)) =Dubup(1)+Dubup(2)+Dubup(3)+Dubup(4) = (2 + 1) + (4 + 1) + (6 + 1) + (8 + 1) = 24 (b) Give a recurrence relation for S(p), the number of + operations performed by Dubup on an SList of depth p, for p 0. { 1 : p = 0 S(p) = 2S(p 1) + 1 : p > 1 (c) Give a recurrence relation for M(p), the number of operations performed by Dubup on an SList of depth p, for p 0. { 1 : p = 0 M(p) = 2M(p 1) : p > Suppose that license plates in a certain municipality come in two forms: one digit (0... 9) followed by three letters (A... Z) followed by three digits. How many different license plates are possible? (You can express this as a product and not multiply it out.) = 175, 760, How many different strings can be formed by rearranging the letters of ABRACADABRA? (Again, express this as a product without multiplying.) 11! 5! 2 2 = The following figure consists of 6 horizontal lines and 12 vertical lines. The goal of this problem is to count the number of rectangles (squares are a kind of rectangle, but line segments are not). Let V be the set of all sets of two vertical lines, and let H be the set of all sets of two horizontal lines. Let R be the set of all rectangles in the figure. Define a function f : R V H by (a) Explain why f is well defined. Two vertical lines and two horizontal lines completely determine a rectangle in this scheme. Plus, all possible pairs of vertical and horizontal lines are in the domain. (b) Explain why f is one-to-one. The function f is 1-1 (injective) because two vertical and two horizontal lines determine a unique rectangle. Page 4
5 (c) Explain why f is onto. The function f is onto (surjective) because there is a rectangle for every two vertical and two horizontal lines: Every pair of vertical and horizontal lines is determined by some rectangle. (d) Compute R, the number of rectangles in the figure. ( 12 2 ) ( 6 2) = = 990. (e) The previous figure contains 6 12 = 72 intersection points. Let P be the set of all sets {X, Y } of two intersection points. Suppose we tried counting R by defining a function g : R P, which maps a rectangle to the set containing its lower left and upper right vertices: Explain why g is not a one-to-one correspondence. The function g is not onto (surjective): for example, if X is on the same vertical line as Y, there is no rectangle mapping to {X, Y }. 13. If you roll three four-sided dice (numbered 1,2,3, and 4), what is the probability of rolling a 5? There are 4 3 equally-likely outcomes. 113, 131, 311, 221, 212, 122 are the only ways to get a 5, so the probability is 6 64 = 3 = To verify this experimentally (empirically), run the Python 32 script: import random n=3 m= cnt = 0 for i in range(m): L = [ random. randrange(1,5) for i in range(n)] #p r i n t ( L ) if sum(l)==5: cnt += 1 print(cnt/m) which should, eventually (it s ten million iterations!) produce a result like Consider the following algorithm:: x 1 for i {1, 2, 3, 4} do for j {1, 2, 3, 4, 5} do x x + x for k {1, 2, 3, 4, 5, 6} do x x + 2 x x + 3 (a) Count the number of + operations done by this algorithm. The first nested for-loop executes 4 5 = 20 additions and the next executes = 48 additions, for a total of 68 additions. (b) What is the value of x after the algorithm finishes? It s easier to track the result of this algorithm by simplifying it first: x 1 Page 5
6 for i {1, 2, 3, 4} do for j {1, 2, 3, 4, 5} do x 2x x x + 30 The inner for-loop then is first doubling and then adding 30, five times: f(x) = 2(2(2(2(2x + 30) + 30) + 30) + 30) The first time through we get f(1) : , but then we loop it three more times: and again: , 015, 778, and finally: 1, 015, 778 2, 031, 586 4, 063, 202 8, 126, , 252, , 505, 826. There s a nice round number...perhaps a little Python script, to be sure: x=1 for i in range(4): print(i,x) for j in range(5): x = x+x for k in range(6): x += 5 x produces Out[14]: Let f : N R be a function. Then O(f) is the set of all functions g such that g(n) Kf(n) for some constant K > 0, and for all n N for some N > 0. If g O(f), we also say that g is big-oh of f. Let p, q N with 0 < p < q. Show that n p O(n q ) Choose K = 1 and N = 1, then g(n) = n p = nq n q p nq = f(n) since q p > 0 and n > Write a recursive function in pseudocode that computes the value of the following recurrence relation: { 1 : n = 1 T (n) = T (n 1) + n : n > 1 function T(n mathbbz) if n = 1 return 1 else return T (n 1) + n or, in Python, def T(n): if n == 1: return 1 else: Page 6
7 return T(n 1)+n for n in range(1,10): print( T(,n, )=,T(n)) T( 1 )= 1 T( 2 )= 3 T( 3 )= 6 T( 4 )= 10 T( 5 )= 15 T( 6 )= 21 T( 7 )= 28 T( 8 )= 36 T( 9 )= 45 The triangular numbers. 17. Let T be a binary tree shown below. (a) Suppose an algorithm uses a preorder traversal PreOrder(T, 17). What sequence of nodes would the algorithm traverse? I ll take advantage of some extra time and access to Python to do this. First, I enter the tree as a list like so: T = [21, #root [17, #left subtree [42,[], [19,[],[15,[],[]]]], [71, [16,[],[28,[],[]]], [91,[27,[],[]],[]]]], [13, #right subtree [11, [83,[],[87,[],[]]], [25,[14,[],[]],[]]], [82,[44,[97,[],[]],[]],[]]]] Then I run the Python code for preorder traversal that we wrote in class, including a print() statement for each visitation: def PreSearch(t,T): if len(t)==0: return False elif t==t[0]: Page 7
8 return True else: print(t[0],end=, ) return PreSearch(t,T[1]) or PreSearch(t,T[2]) print( PreSearch(88,T)) Here s the preorder traversal: 21,17,42,19,15,71,16,28,91,27,13,11,83,87,25,14,82,44,97 (b) Suppose the algorithm uses an inorder traversal InOrder(71, T ). What sequence of nodes would the algorithm traverse? Again, I ll use Python: def PostSearch(t,T): if len(t)==0: return False elif PostSearch(t,T[1]) or PostSearch(t,T[2]): return True else: print(t[0],end=, ) return t==t[0] print( PostSearch(71,T)) Returns 15,19,42,28,16,27,91,71,True 18. Is there an assignment of true/false values for the variables p, q, r, s, and t such that the formula [(p q) ( p r)] [(s t) ( s t)] takes the value true? If so, find such an assignment. If not, explain why not. Any assignment of values where p and q are both false will make the value of the formula true. The idea is that a false premis allows any conclusion at all. For example, If James Earl Ray shot MLK, then the cow jumps over the moon. Page 8
Math 15 - Spring Homework 5.2 Solutions
Math 15 - Spring 2017 - Homework 5.2 Solutions 1. (5.2 # 14 (not assigned)) Use Prim s algorithm to construct a minimal spanning tree for the following network. Draw the minimal tree and compute its total
More informationCSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationCS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total
CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Please check your tutorial (TUT) section from the list below: TUT 101: F 11:30, MC 4042 TUT 102: M 10:30, MC 4042 TUT 103: M 11:30, MC 4058 TUT 104: F 10:30,
More informationCSCI-401 Examlet #5. Name: Class: Date: True/False Indicate whether the sentence or statement is true or false.
Name: Class: Date: CSCI-401 Examlet #5 True/False Indicate whether the sentence or statement is true or false. 1. The root node of the standard binary tree can be drawn anywhere in the tree diagram. 2.
More informationMidterm CSE 21 Spring 2012
Signature Name Student ID Midterm CSE 21 Spring 2012 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 _ (20 points) _ (15 points) _ (13 points) _ (23 points) _ (10 points) _ (8 points) Total _ (89 points) (84
More informationCSE 373 Spring Midterm. Friday April 21st
CSE 373 Spring 2006 Data Structures and Algorithms Midterm Friday April 21st NAME : Do all your work on these pages. Do not add any pages. Use back pages if necessary. Show your work to get partial credit.
More informationAlgorithms and Data Structures
Algorithms and Data Structures Spring 2019 Alexis Maciel Department of Computer Science Clarkson University Copyright c 2019 Alexis Maciel ii Contents 1 Analysis of Algorithms 1 1.1 Introduction.................................
More information2.) From the set {A, B, C, D, E, F, G, H}, produce all of the four character combinations. Be sure that they are in lexicographic order.
Discrete Mathematics 2 - Test File - Spring 2013 Exam #1 1.) RSA - Suppose we choose p = 5 and q = 11. You're going to be sending the coded message M = 23. a.) Choose a value for e, satisfying the requirements
More informationCSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationMidterm CSE 21 Fall 2012
Signature Name Student ID Midterm CSE 21 Fall 2012 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 _ (20 points) _ (15 points) _ (21 points) _ (13 points) _ (9 points) _ (7 points) Total _ (85 points) (80 points
More informationMultiple-choice (35 pt.)
CS 161 Practice Midterm I Summer 2018 Released: 7/21/18 Multiple-choice (35 pt.) 1. (2 pt.) Which of the following asymptotic bounds describe the function f(n) = n 3? The bounds do not necessarily need
More informationCS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final
CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, 2016 Instructions: CS1800 Discrete Structures Final 1. The exam is closed book and closed notes. You may
More informationCSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014
CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis Aaron Bauer Winter 2014 Previously, on CSE 373 We want to analyze algorithms for efficiency (in time and space) And do so generally
More informationCS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010
CS 3512, Spring 2011 Instructor: Doug Dunham Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010 Prerequisites: Calc I, CS2511 Rough course outline:
More information1. Let n and m be positive integers with n m. a. Write the inclusion/exclusion formula for the number S(n, m) of surjections from {1, 2,...
MATH 3012, Quiz 3, November 24, 2015, WTT Student Name and ID Number 1. Let n and m be positive integers with n m. a. Write the inclusion/exclusion formula for the number S(n, m) of surjections from {1,
More informationCS1800 Discrete Structures Final Version A
CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 11, 2017 CS1800 Discrete Structures Final Version A Instructions: 1. The exam is closed book and closed notes. You may not use
More informationMidterm solutions. n f 3 (n) = 3
Introduction to Computer Science 1, SE361 DGIST April 20, 2016 Professors Min-Soo Kim and Taesup Moon Midterm solutions Midterm solutions The midterm is a 1.5 hour exam (4:30pm 6:00pm). This is a closed
More informationAlgorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48
Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem
More informationFaculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University
NAME: STUDENT NUMBER:. Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University Examimer: Prof. Mathieu Blanchette December 8 th 2005,
More informationASSIGNMENT 4 SOLUTIONS
MATH 71 ASSIGNMENT SOLUTIONS 1. If F : X X is a function, define f (x) to be (f f)(x), and inductively define f k (x) (f f k 1 )(x) for each integer k. (So f (x) (f f )(x) f(f(f(x))) for instance.) We
More informationU.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, Midterm 1 Solutions
U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, 2013 Midterm 1 Solutions 1 True/False 1. The Mayan base 20 system produces representations of size that is asymptotically
More informationUNIVERSITY OF CALIFORNIA, COLLEGE OF ENGINEERING E77N: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS
Page 1 of 14 UNIVERSITY OF CALIFORNIA, COLLEGE OF ENGINEERING E77N: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS Final Exam May 18, 2002 12:30 3:30 pm TOTAL 100 POINTS Notes: 1. Write
More informationTotal Score /1 /20 /41 /15 /23 Grader
NAME: NETID: CS2110 Spring 2015 Prelim 2 April 21, 2013 at 5:30 0 1 2 3 4 Total Score /1 /20 /41 /15 /23 Grader There are 5 questions numbered 0..4 on 8 pages. Check now that you have all the pages. Write
More informationUCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis
UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 16 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 16 Notes Goals for this week Graph basics Types
More informationChapter 4. Divide-and-Conquer. Copyright 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 4 Divide-and-Conquer Copyright 2007 Pearson Addison-Wesley. All rights reserved. Divide-and-Conquer The most-well known algorithm design strategy: 2. Divide instance of problem into two or more
More informationUniversity of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2010
University of Toronto Department of Electrical and Computer Engineering Midterm Examination ECE 345 Algorithms and Data Structures Fall 2010 Print your name and ID number neatly in the space provided below;
More informationAssignment 1 (concept): Solutions
CS10b Data Structures and Algorithms Due: Thursday, January 0th Assignment 1 (concept): Solutions Note, throughout Exercises 1 to 4, n denotes the input size of a problem. 1. (10%) Rank the following functions
More informationRecursive definition of sets and structural induction
CS2209A 2017 Applied Logic for Computer Science Lecture 21, 22 Recursive definition of sets and structural induction Instructor: Marc Moreno Maza 1 Tower of Hanoi game Rules of the game: Start with all
More informationCS 173 [A]: Discrete Structures, Fall 2012 Homework 8 Solutions
CS 173 [A]: Discrete Structures, Fall 01 Homework 8 Solutions This homework contains 4 problems worth a total of 35 points. It is due on Wednesday, November 14th, at 5pm. 1 Induction Proofs With Inequalities
More informationCS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final
CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, 2016 Instructions: CS1800 Discrete Structures Final 1. The exam is closed book and closed notes. You may
More informationIntroduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.
Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Practice Final Practice Final Do not open this exam booklet until
More informationSolution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Summer I Instructions:
VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted
More informationFriday Four Square! 4:15PM, Outside Gates
Binary Search Trees Friday Four Square! 4:15PM, Outside Gates Implementing Set On Monday and Wednesday, we saw how to implement the Map and Lexicon, respectively. Let's now turn our attention to the Set.
More informationComplexity, Induction, and Recurrence Relations. CSE 373 Help Session 4/7/2016
Complexity, Induction, and Recurrence Relations CSE 373 Help Session 4/7/2016 Big-O Definition Definition: g(n) is in O( f(n) ) if there exist positive constants c and n0 such that g(n) c f(n) for all
More informationCSC Design and Analysis of Algorithms. Lecture 6. Divide and Conquer Algorithm Design Technique. Divide-and-Conquer
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conuer Algorithm Design Techniue Divide-and-Conuer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationCMPSCI 187: Programming With Data Structures. Lecture 5: Analysis of Algorithms Overview 16 September 2011
CMPSCI 187: Programming With Data Structures Lecture 5: Analysis of Algorithms Overview 16 September 2011 Analysis of Algorithms Overview What is Analysis of Algorithms? L&C s Dishwashing Example Being
More informationCS 373: Combinatorial Algorithms, Spring 1999
CS 373: Combinatorial Algorithms, Spring 1999 Final Exam (May 7, 1999) Name: Net ID: Alias: This is a closed-book, closed-notes exam! If you brought anything with you besides writing instruments and your
More informationAssignment 1. Stefano Guerra. October 11, The following observation follows directly from the definition of in order and pre order traversal:
Assignment 1 Stefano Guerra October 11, 2016 1 Problem 1 Describe a recursive algorithm to reconstruct an arbitrary binary tree, given its preorder and inorder node sequences as input. First, recall that
More informationAdvanced Algorithm Design and Analysis (Lecture 12) SW5 fall 2005 Simonas Šaltenis E1-215b
Advanced Algorithm Design and Analysis (Lecture 12) SW5 fall 2005 Simonas Šaltenis E1-215b simas@cs.aau.dk Range Searching in 2D Main goals of the lecture: to understand and to be able to analyze the kd-trees
More informationExam 3 Practice Problems
Exam 3 Practice Problems HONOR CODE: You are allowed to work in groups on these problems, and also to talk to the TAs (the TAs have not seen these problems before and they do not know the solutions but
More information1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1
Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution
More informationSolutions to Quiz 1. (a) (3 points) Vertices x and y are in the same connected component. Solution. P (x, y)
Massachusetts Institute of Technology 6.042J/18.062J, Fall 05: Mathematics for Computer Science October 17 Prof. Albert R. Meyer and Prof. Ronitt Rubinfeld revised October 18, 2005, 125 minutes Solutions
More informationAssignment 8 CSCE 156/156H/RAIK 184H Spring 2017
Assignment 8 CSCE 156/156H/RAIK 184H Spring 2017 Name(s) CSE Login Instructions Same partner/group policy as the project applies to this assignment. Answer each question as completely as possible. You
More informationIntroduction to Computer Science and Programming for Astronomers
Introduction to Computer Science and Programming for Astronomers Lecture 3. István Szapudi Institute for Astronomy University of Hawaii January 24, 2018 Outline Reminder 1 Reminder 2 3 Where were we last
More informationDiscrete Mathematics 2 Exam File Spring 2012
Discrete Mathematics 2 Exam File Spring 2012 Exam #1 1.) Suppose f : X Y and A X. a.) Prove or disprove: f -1 (f(a)) A. Prove or disprove: A f -1 (f(a)). 2.) A die is rolled four times. What is the probability
More informationCS126 Final Exam Review
CS126 Final Exam Review Fall 2007 1 Asymptotic Analysis (Big-O) Definition. f(n) is O(g(n)) if there exists constants c, n 0 > 0 such that f(n) c g(n) n n 0 We have not formed any theorems dealing with
More informationSolution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:
VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted
More informationQuiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)
Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Solutions Problem 1. Quiz 1 Solutions Asymptotic orders
More informationHow much space does this routine use in the worst case for a given n? public static void use_space(int n) { int b; int [] A;
How much space does this routine use in the worst case for a given n? public static void use_space(int n) { int b; int [] A; } if (n
More informationLesson 10: Representing, Naming, and Evaluating Functions
: Representing, Naming, and Evaluation Functions Classwork Opening Exercise Study the 4 representations of a function below. How are these representations alike? How are they different? TABLE: Input 0
More informationCSC Design and Analysis of Algorithms
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conquer Algorithm Design Technique Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationModule 07: Efficiency
Module 07: Efficiency Topics: Basic introduction to run-time efficiency Analyzing recursive code Analyzing iterative code 1 Consider the following two ways to calculate the maximum of a nonempty list.
More informationSolving Linear Recurrence Relations (8.2)
EECS 203 Spring 2016 Lecture 18 Page 1 of 10 Review: Recurrence relations (Chapter 8) Last time we started in on recurrence relations. In computer science, one of the primary reasons we look at solving
More informationDivide-and-Conquer. Dr. Yingwu Zhu
Divide-and-Conquer Dr. Yingwu Zhu Divide-and-Conquer The most-well known algorithm design technique: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances independently
More informationCSC Design and Analysis of Algorithms. Lecture 6. Divide and Conquer Algorithm Design Technique. Divide-and-Conquer
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conquer Algorithm Design Technique Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationCSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationTREES AND ORDERS OF GROWTH 7
TREES AND ORDERS OF GROWTH 7 COMPUTER SCIENCE 61A October 17, 2013 1 Trees In computer science, trees are recursive data structures that are widely used in various settings. This is a diagram of a simple
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )
More informationIndicate the option which most accurately completes the sentence.
Discrete Structures, CSCI 246, Fall 2015 Final, Dec. 10 Indicate the option which most accurately completes the sentence. 1. Say that Discrete(x) means that x is a discrete structures exam and Well(x)
More informationBasic Properties The Definition of Catalan Numbers
1 Basic Properties 1.1. The Definition of Catalan Numbers There are many equivalent ways to define Catalan numbers. In fact, the main focus of this monograph is the myriad combinatorial interpretations
More informationDivide-and-Conquer. The most-well known algorithm design strategy: smaller instances. combining these solutions
Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances recursively 3. Obtain solution to original
More informationCS302 Topic: Algorithm Analysis #2. Thursday, Sept. 21, 2006
CS302 Topic: Algorithm Analysis #2 Thursday, Sept. 21, 2006 Analysis of Algorithms The theoretical study of computer program performance and resource usage What s also important (besides performance/resource
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or
More informationPROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationName CPTR246 Spring '17 (100 total points) Exam 3
Name CPTR246 Spring '17 (100 total points) Exam 3 1. Linked Lists Consider the following linked list of integers (sorted from lowest to highest) and the changes described. Make the necessary changes in
More information10/5/2016. Comparing Algorithms. Analyzing Code ( worst case ) Example. Analyzing Code. Binary Search. Linear Search
10/5/2016 CSE373: Data Structures and Algorithms Asymptotic Analysis (Big O,, and ) Steve Tanimoto Autumn 2016 This lecture material represents the work of multiple instructors at the University of Washington.
More informationMath 187 Sample Test II Questions
Math 187 Sample Test II Questions Dr. Holmes October 2, 2008 These are sample questions of kinds which might appear on Test II. There is no guarantee that all questions on the test will look like these!
More informationChapter 1 Programming: A General Overview
Chapter 1 Programming: A General Overview 2 Introduction This class is an introduction to the design, implementation, and analysis of algorithms. Examples: sorting large amounts of data organizing information
More informationINF2220: algorithms and data structures Series 1
Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees Issued: 24. 08. 2016 Exercise
More informationQuestion 7.11 Show how heapsort processes the input:
Question 7.11 Show how heapsort processes the input: 142, 543, 123, 65, 453, 879, 572, 434, 111, 242, 811, 102. Solution. Step 1 Build the heap. 1.1 Place all the data into a complete binary tree in the
More informationSolutions to the Second Midterm Exam
CS/Math 240: Intro to Discrete Math 3/27/2011 Instructor: Dieter van Melkebeek Solutions to the Second Midterm Exam Problem 1 This question deals with the following implementation of binary search. Function
More informationSEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY. Lecture 11 CS2110 Spring 2016
1 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Spring 2016 Time spent on A2 2 Histogram: [inclusive:exclusive) [0:1): 0 [1:2): 24 ***** [2:3): 84 ***************** [3:4): 123 *************************
More informationCIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018
CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018 Q1: Prove or disprove: You are given a connected undirected graph G = (V, E) with a weight function w defined over its
More informationComputer Science E-22 Practice Final Exam
name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and
More informationIn addition to the correct answer, you MUST show all your work in order to receive full credit.
In addition to the correct answer, you MUST show all your work in order to receive full credit. Questions Mark: Question1) Multiple Choice Questions /10 Question 2) Binary Trees /15 Question 3) Linked
More informationCS1800 Discrete Structures Final Version B
CS1800 Discrete Structures Fall 2017 Profs. Aslam, Gold, & Pavlu December 15, 2017 CS1800 Discrete Structures Final Version B Instructions: 1. The exam is closed book and closed notes. You may not use
More informationPrelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed
More information1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18
CS 124 Quiz 2 Review 3/25/18 1 Format You will have 83 minutes to complete the exam. The exam may have true/false questions, multiple choice, example/counterexample problems, run-this-algorithm problems,
More informationI. Recursive Descriptions A phrase like to get the next term you add 2, which tells how to obtain
Mathematics 45 Describing Patterns in s Mathematics has been characterized as the science of patterns. From an early age students see patterns in mathematics, including counting by twos, threes, etc.,
More informationCS1110 Lab 6 (Mar 17-18, 2015)
CS1110 Lab 6 (Mar 17-18, 2015) First Name: Last Name: NetID: The lab assignments are very important and you must have a CS 1110 course consultant tell CMS that you did the work. (Correctness does not matter.)
More informationPrelim 2, CS2110. SOLUTION
Prelim 2, CS2110. SOLUTION 7:30 PM, 25 April 2017 1. Name (1 point) Write your name and NetID at the top of every page of this exam. 2. Short Answer (26 points.) (a) Asymptotic complexity. 8 points. Be
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00
University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms Instructor: Douglas Wilhelm Harder Time: 2.5 hours Aides: none 18 pages Final Examination
More informationComputer Science Foundation Exam
Computer Science Foundation Exam August 6, 017 Section I A DATA STRUCTURES SOLUTIONS NO books, notes, or calculators may be used, and you must work entirely on your own. Question # Max Pts Category Passing
More information(b) int count = 0; int i = 1; while (i<m) { for (int j=i; j<n; j++) { count = count + 1; i = i + 1; O(M + N 2 ) (c) int count = 0; int i,j,k; for (i=1
CPS 100 Exam 2 Solutions Spring 199 Dr Rodger 1 (3 pts) A virtual function in C++ is bound dynamically or statically? dynamic 2 (3 pts) When does one use a class template in C++? Templates are used to
More informationNotation Index. Probability notation. (there exists) (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5.
Notation Index (there exists) (for all) Fn-4 Fn-4 (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5 ( n ) k (binomial coefficient) CL-15 ( n m 1,m 2,...) (multinomial coefficient)
More informationCSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)
Name: Email address: CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial
More informationAlgebra 2 Semester 1 (#2221)
Instructional Materials for WCSD Math Common Finals The Instructional Materials are for student and teacher use and are aligned to the 2016-2017 Course Guides for the following course: Algebra 2 Semester
More informationCMPSCI 311: Introduction to Algorithms Practice Final Exam
CMPSCI 311: Introduction to Algorithms Practice Final Exam Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more detail including
More information9/10/2018 Algorithms & Data Structures Analysis of Algorithms. Siyuan Jiang, Sept
9/10/2018 Algorithms & Data Structures Analysis of Algorithms Siyuan Jiang, Sept. 2018 1 Email me if the office door is closed Siyuan Jiang, Sept. 2018 2 Grades have been emailed github.com/cosc311/assignment01-userid
More informationNANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH 1301 DISCRETE MATHEMATICS TIME ALLOWED: 2 HOURS
NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION 2015-2016 MH 1301 DISCRETE MATHEMATICS May 2016 TIME ALLOWED: 2 HOURS INSTRUCTIONS TO CANDIDATES 1. This examination paper contains FIVE (5) questions
More informationLesson 20: Every Line is a Graph of a Linear Equation
Student Outcomes Students know that any non vertical line is the graph of a linear equation in the form of, where is a constant. Students write the equation that represents the graph of a line. Lesson
More informationCSE 2320 Section 002, Fall 2015 Exam 2 Time: 80 mins
CSE 2320 Section 002, Fall 201 Exam 2 Time: 80 mins Name:. Student ID:. Total exam points: 100. Question Points Out of 1 24 2 10 3 10 4 18 6 1 16 Total 100 If you have the smallest doubt about what a question
More informationDesign and Analysis of Algorithms - - Assessment
X Courses» Design and Analysis of Algorithms Week 1 Quiz 1) In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise.
More informationCPS 616 TRANSFORM-AND-CONQUER 7-1
CPS 616 TRANSFORM-AND-CONQUER 7-1 TRANSFORM AND CONQUER Group of techniques to solve a problem by first transforming the problem into one of: 1. a simpler/more convenient instance of the same problem (instance
More informationNotation Index 9 (there exists) Fn-4 8 (for all) Fn-4 3 (such that) Fn-4 B n (Bell numbers) CL-25 s ο t (equivalence relation) GT-4 n k (binomial coef
Notation 9 (there exists) Fn-4 8 (for all) Fn-4 3 (such that) Fn-4 B n (Bell numbers) CL-25 s ο t (equivalence relation) GT-4 n k (binomial coefficient) CL-14 (multinomial coefficient) CL-18 n m 1 ;m 2
More informationFast algorithm for generating ascending compositions
manuscript No. (will be inserted by the editor) Fast algorithm for generating ascending compositions Mircea Merca Received: date / Accepted: date Abstract In this paper we give a fast algorithm to generate
More informationYou should know the first sum above. The rest will be given if you ever need them. However, you should remember that,, and.
Big-Oh Notation Formal Definitions A function is in (upper bound) iff there exist positive constants k and n 0 such that for all. A function is in (lower bound) iff there exist positive constants k and
More informationRecursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences
Section 5.3 1 Recursion 2 Recursion Recursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences Previously sequences were defined using a specific
More informationSpring 2017 CS 1110/1111 Exam 2
Spring 2017 CS 1110/1111 Exam 2 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly. If you have a shorter ID, leave some rows blank.
More informationCOMP 250 Fall recurrences 2 Oct. 13, 2017
COMP 250 Fall 2017 15 - recurrences 2 Oct. 13, 2017 Here we examine the recurrences for mergesort and quicksort. Mergesort Recall the mergesort algorithm: we divide the list of things to be sorted into
More information