# hw2 - Homework 2 CSE 450/598 Spring 2010 Arizona State...

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

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.

Unformatted text preview: Homework 2 CSE 450/598 Spring 2010 Arizona State University Due: Tuesday 2/2 before 10:30 1. (2.6) You’re given an integer array A = ( A [ 1 ] , A [ 2 ] ,..., A [ n ]) . Your goal is to output an n by n array B = [ B [ i , j ]] , where B [ i , j ] = A [ i ] + A [ i + 1 ] + ··· + A [ j ] for i < j (for i > j the value of B [ i , j ] is not specified, so it doesn’t matter what is output for these values). Here’s an algorithm to solve this problem: for i = 1, 2, ..., n: for j = i+1, i+2, ..., n: add up array entries A[i] through A[j] store the result in B[i,j] (a) Pick a function f and show that the running time of the algorithm is O ( f ( n )) for an input of size n . (b) For the same function f show that the running time of the algorithm is also Ω ( f ( n )) . (Here you may have to go back to the previous part and correct your answer if this is not true for the function you had picked. (c) The algorithm you’ve just analyzed is, in fact, not very efficient. Give a different algorithm to solve the same problem, with an asymptotically better running time: if your algorithm has running time O ( g ( n )) , then it should be the case that g ∈ o ( f ) . 2. (2.8) You’re doing stress-testing of glass jars to determine the maximum safe height from which they can be dropped without breaking. The experiment (for a particular fixed typewhich they can be dropped without breaking....
View Full Document

## This note was uploaded on 04/08/2010 for the course CS 146 taught by Professor - during the Spring '08 term at San Jose State.

### Page1 / 2

hw2 - Homework 2 CSE 450/598 Spring 2010 Arizona State...

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

View Full Document
Ask a homework question - tutors are online