COT 3100 Homework 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Consider the following functions. Which of the following functions are O(x^2)?

- 17x + 11 - x^2 + 1000

Identify which characteristics of an algorithm the following procedures have and which they lack. Select the characteristics that the procedures have and leave characteristics unselected that the procedures lack. procedure sum (n : positive integer) sum := 0 while i < 10 sum := sum + i

- input - correctness - effectiveness - generality

Identify which characteristics of an algorithm the following procedures have and which they lack. Select the characteristics that the procedures have and leave characteristics unselected that the procedures lack. procedure double (n : positive integer) while n > 0 n ≔ 2n

- input - definiteness - output - effectiveness - generality- correctness - effectiveness - generality - finiteness

Use the blocks on the right and place them in order in a list on the left to describe an algorithm that takes as input a list of n integers and produces as output the largest difference obtained by subtracting an integer in the list from the one following it.

1) procedure difference (a1, a2,..., an : integers) 2) max = a2 - a1 3) for 1 = 2 to n - 1 4) M = ai+1 - ai 5) if M > max then max = M 6) Return (the greatest difference)

Find the sum and product of each of these pairs of numbers. Express your answers as binary expansions. The sum of the numbers (100 0111)2 and (111 1000)2 is ( _____ )2 and their product is ( _____ )2.

1011 1111 10 0001 0100 1000

Convert the binary expansion of each of the following integers to a decimal expansion. The decimal expansion of (1 1001)2 is _________ .

25

Consider the triplets (x, y, z) and (y, z, x). Identify the minimum number of assignment statements needed to replace the triplet (x, y, z) with (y, z, x).

4

Give a big-O estimate for each of these functions. For the function g in your estimate f (x) is O(g(x)), use a simple function g of smallest order. If f(x) = (2^n + n^2)(n^3 + 3^n) then, g(x) = _____.

6^n

Which equations arise when the steps of the Euclidean algorithm are reversed to express the greatest common divisor of each of these pairs of integers as a linear combination of these integers? (8, 9) The equation is 1 = (-1) · _______ + 1 · ______ .

8, 9

Decrypt these messages that were encrypted using the Caesar cipher. EOXH MHDQV The decrypted message of EOXH MHDQV is

BLUE JEANS

Consider the message "DO NOT PASS GO." Identify the number obtained after applying the encryption function f(p) = (p + 13) mod 26 to the the number translated from the letters of the above message.

QB ABG CNFF TB 16-1 0-1-6 2-13-5-5 19-1

Decrypt these messages that were encrypted using the Caesar cipher. WHVW WRGDB The decrypted message of WHVW WRGDB is

TEST TODAY

Give a big-O estimate for each of these functions. For the function g in your estimate f (x) is O(g(x)), use a simple function g of smallest order. If f(x) = (n^3 + n^2 log n)(log n + 1) + (17 log n + 19)( n^3 + 2), then g(x) = _____.

n^3 · log n

Give a big-O estimate for each of these functions. For the function g in your estimate f (x) is O(g(x)), use a simple function g of smallest order. If f(x) = (n^n + n2^n + 5^n)(n! + 5^n) then g(x) = _____.

n^n n!

Consider the insertion sort algorithm. Arrange the steps in the correct ascending order to devise a variation of the insertion sort that uses a linear search technique that inserts the jth element in the correct place by first comparing it with the (j − 1)st element, then the (j − 2)th element if necessary, and so on.

procedure backward insertion sort(a1, a2, . . . , an : real numbers with n ≥ 2) for j := 2 to n m := aj i := j - 1 while (m < ai and i > 0) ai + 1 := ai i := i - 1 a i + 1 := m


Kaugnay na mga set ng pag-aaral

Ch 57: Management of Patients with Burn Injury

View Set

World War I - Espionage and Sedition

View Set

Safety in Medication Administration

View Set

Chapter 11 Nervous System and Nervous Tissue

View Set

EXAM 2: Strength and conditioning

View Set