{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Exam1 - Name Midterm 1 CS 20 Fall 2008 Short Answer/22...

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

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):

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

View Full Document
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( )
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 one advantage for using each one. (4 pts) 5) Your colleague is using a data structure that takes in items of type Object and returns items of type Object.

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern