{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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):
Image of page 1

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

View Full Document Right 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( )
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 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.
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern