Exam1 - Name: _ Midterm 1 CS 20 Fall 2008 Short Answer:...

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

View Full Document Right Arrow Icon
Name: ________________________ Midterm 1 CS 20 Fall 2008 Short Answer: _____/22 Output: _____/13 Linked List Manipulation: _____/25 Stack Implementation _____/20 Total: _____/80 1) Determine the number of iterations executed for the following loops – First write down the equation with summations, then solve it to get the final answer. (5 pts each):
Background image of page 1

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

View Full DocumentRight Arrow Icon
a) for(i = 0; i < n^2; i++) for(j = 0; j < i; j++) sum++; b) for(i = 0; i < n^3; i++) for(j = 0; j < i; j++) sum++; c) for(i = 0; i < n; i *= 3) for(j = 0; j < n; j++) sum++; d – 3 pts) for(i = 0; i < sin(n); i += 0.1) sum++; Hint: Think about the possible values of sin(n) 2). Name and describe two principles of object-oriented programming and how Java allows you to accomplish these two principles. (4 pts) 3) For each of the following give the big-O notation O ( ): (3 pts each) a) 3n/2 = O( ) b) log (n) + 3n + 5= O( )
Background image of page 2
c) nlog(10) = O( ) d) 10*n 2 + 5*2 n = O( ) 4) Name the two basic structures used to construct advanced data structures, and give
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 12/27/2011 for the course CMPSC 40 taught by Professor Egiceoclu during the Fall '09 term at UCSB.

Page1 / 5

Exam1 - Name: _ Midterm 1 CS 20 Fall 2008 Short Answer:...

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