mid1_solution - COP-3530 DATA STRUCTURES AND ALGORITHMS...

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

View Full Document Right Arrow Icon
COP-3530 DATA STRUCTURES AND ALGORITHMS Instructor: Manuel Bermúdez Fall 2009 MIDTERM EXAM 1 Solution & Grading Policy If you have any questions about grading and re-grading, contact Ting ( [email protected] ) for problem 1,4,5 and Hadi ( [email protected] ) for problem 2,3.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 1 (10pts) a) Quadratic The first n++ line will be executed i times for each 0 < i < x, which adds up to (1+2+. ..+(x-1)) = x*(x-1)/2 The second one will be executed x times only. So n will be incremented x*(x-1)/2 + x = x(x+1)/2 times, hence f(x)=x(x+1)/2. So the answer is quadratic. Note that the question is asking you to find f(x) as a function of x, which in general is different than asking for a functions runtime complexity - but in this case they are the same. Grading Policy: 1. 5pts: correct answer but no justification 2. 1-3 pts: wrong answer but reasonable justification 3. 7-9 pts: correct answer but not so well justified
Background image of page 2
Problem 2 b) class ArrayQueueAsStack implements Stack { private ArrayQueue queueOne = new ArrayQueue();
Background image of page 3

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

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

This note was uploaded on 01/15/2010 for the course COP 3530 taught by Professor Davis during the Fall '08 term at University of Florida.

Page1 / 7

mid1_solution - COP-3530 DATA STRUCTURES AND ALGORITHMS...

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

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