Sample_exam2 - COP 3502 Computer Science I Exam#2(Monday...

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

View Full Document Right Arrow Icon
COP 3502 – Computer Science I Exam #2 – 7/7/08 (Monday) Name : ______________________________ 1) (5 pts) An O(n 2 ) algorithm takes 2 ms. to run on an input size of n = 50. On another input size, the algorithm took 72 ms. to run, what was that input size? 2) (8 pts) Determine the following sum in terms of n: + = - 3 15 5 2 n i i . 3) (5 pts) What is the run-time (order) of the following code segment in terms of n? for (i=0; i<n; i++) { for (j=0; j<i; i++) { sum += j; } }
Image of page 1

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

View Full Document Right Arrow Icon
4) (5 pts) What is the run-time (order) of the following code segment in terms of n? i=0, j=0; while (i < n && j < n) { while (j < n && A[i][j] == 1) j++; i++; } 5) (5 pts) What is the run-time (order) of the following code segment in terms of n? i=0, j=0; while (i < n && j < n) { j=0; while (j < n && A[i][j] == 1) j++; i++; }
Image of page 2
6) (7 pts) Evaluate the following postfix expression and show the state of the operand stack at the indicated points: a b c 3 5 7 + 8 4 / / 3 5 + * Final Value : _____________ 7) (10 pts) Convert the following infix expression to postfix and show the state of the operator stack at the indicated points.
Image of page 3

Info iconThis 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