{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

oct16cs1 - October 16th Foundation Exam CS I Questions(1 15...

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

View Full Document Right Arrow Icon
October 16 th Foundation Exam CS I Questions (1, 15%) The following (INCORRECT) algorithm is intended to be the iterative bubble sort algorithm. Assume that swap is a global procedure that exchanges the contents of its two parameters. algorithm Bsort(n) procedure B(k) 1) set j <- 1 2) while j < k do 3) if a[j] > a[j+1] then 4) swap(a[j], a[j+1]) 5) set j ß j + 1 endprocedure begin 6) for i = 1 to n-1 do 7) B(n-i); endalgorithm It SHOULD take this first list… 8 3 10 7 5 4 …and produce this list. 3 4 5 7 8 10 1a) But, it doesn't. What does it produce? 1b) There is one error in the algorithm. In which line does it occur? __________ 1c ) Write the correct pseudo-code for the line identified in 1b).
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
(2, 20%) The following are Postfix strings. All values are single decimal digits and the operations are binary add "+", binary subtract "-",and binary multiplication "*". Indicate which are invalid, if any. For those that are valid, compute the result. a) 9 4 + 2 3 * - 6 3 - 5 * + 7 - ___________________________ b) 8 3 2 4 * + - 7 8 2 3 * - + ________________________ c) 3 2 + 4 2 * 7 5 - 2 3 * + - + ________________________ d)
Image of page 2
Image of page 3
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