Exam1(1)

# Exam1(1) - CSE 5211 Fall 2007 Exam 1 Points: 50 Time: 85...

This preview shows pages 1–2. Sign up to view the full content.

CSE 5211 Fall 2007 Exam 1 Points: 50 Time: 85 min Answer SKETCHES. 1. For two given positive integers a , and n , the value na may be computed naively by adding a with itself n- times, i.e., Θ (n) time. Write a divide-and-conquer algorithm for the same purpose. Find your algorithm’s asymptotic time-complexity by setting up the corresponding recurrence equation and then solving it (use Master’s theorem). Recursively add one half and multiply the result with 2. Recursion terminates with n==1. T(n) = T(n/2) +1. T(n) = O(log n). Presumption: you can multiply with 2 in constant time. 2a. What is the Order (Big-O) of the variable count in terms of n after the following algorithm-fragment is executed? [5] (1) count = 0; (2) For i = 1 through n do (3) For p = 1 through 3 do (5) For k = 1 through i do (4) count = count +1; end for loops; O(n^2) 2b. What is the asymptotic time-complexity of the following algorithm fragment? [5] (0) int count := 0; (1) For i =1 through 5 do (2) For p = 1 through

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/10/2012 for the course CSE 5211 taught by Professor Dmitra during the Spring '12 term at FIT.

### Page1 / 3

Exam1(1) - CSE 5211 Fall 2007 Exam 1 Points: 50 Time: 85...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online