
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Work in groups or alone and use the time today to answer all of the questions below. You may use your books or notes from class, and do not turn in this assignment: it is yours to study for the exam next week. Recall that: Defn: An algorithm consists of three stages: input, procedure, and output. All arith- metic operations (+, −, ×, ÷) and comparisons (≤, <, =) must occur in the procedure stage. The complexity of the algorithm is the total number of arithmetic operations and/or comparisons used for the algorithm to run for an input in the worst case. Defn: A recurrence relation an = ran− 1 + san− 2 has solution
an =
c 1 xn 1 + c 2 xn 2 if x 1 6 = x 2 , c 1 xn 0 + c 2 nxn 0 if x 1 = x 2 = 0, where x 1 , x 2 are the roots of the characteristic polynomial x^2 − rx − s = (x − x 1 )(x − x 2 ) = 0, and c 1 , c 2 are unknown constants which are solved for using the initial conditions of the recursively defined sequence. Defn: A list of elements of a set A is an ordered n-tuple, or element of An^ = A︸ × A × · · · ×︷︷ A︸ n times