s01secA - Solution 1 Section A COMP305 Data Structures and...

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

View Full Document Right Arrow Icon
Solution # 1 - Section A COMP305 Data Structures and Algorithms Spring 2012 Marks Room: Y305 Friday @ 8:30-11:00 20-Jan-2012 10 Family Name Given Name Student ID ** Instructions : Please answer the following questions in the space provided. This is a closed book quiz. Only simple calculators are permitted. Question 1: Algorithm Complexity Marks:[5/10] Given the cost function of an algorithm to be f(n) = 256 n 2 + 16 n + 1024 n log 2 n + 4 n 3 + n log 2 ( n 2 16 ) Find c g(n) and n 0 such that the algorithm is O(g(n)) Answers: 256 n 2 + 16 n + 1024 n log 2 n + 4 n 3 + n log 2 ( n 2 16 ) = 256 n 2 + 16 n + 1024 n log 2 n + 4 n 3 + n log 2 ( n ) + n log 2 ( 2 16 ) = 256 n 2 + 16 n + 1024 n log 2 n + 4 n 3 + n log 2 ( n ) + 16 n = 256 n 2 + 32 n + 1025 n log 2 n + 4 n 3 = 4 n 3 + 256 n 2 + 1025 n log 2 n + 32 n // so far, simple algebraic simplifications; 4 n 3 + 256 n 2 + 1025 n 2 + 32 n 2 // now, start “ bumping up ” the terms; 4 n 3 + 256 n 2 + 1025 n 2 + 32 n 2 // now, start “
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/08/2012 for the course COMP 305 taught by Professor George during the Spring '12 term at Hong Kong Polytechnic University.

Page1 / 2

s01secA - Solution 1 Section A COMP305 Data Structures and...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online