csi06 sol - CSI2110A/B Data Structures and Algorithms...

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

View Full Document Right Arrow Icon
CSI2110A/B Data Structures and Algorithms Midterm Examination Length of Examination: 2 hours October 22 nd , 2006, 14:00 Professors: P. Flocchini, J. Lang Page 1 of 8 Family Name: Other Names: Student Number: Signature: Closed Book. Please answer in the space provided (in this questionnaire) . If you do not understand a question, clearly state an assumption and proceed. No calculators or other electronic devices are allowed. At the end of the exam, when time is up: Stop working and turn your exam upside down. Remain silent. Do not move or speak until all exams have been picked up, and a TA or a Professor gives the go-ahead to leave. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page Marks of each page PAGE 3 out of 7 PAGE 4 out of 6 PAGE 5 out of 5 PAGE 6 out of 5 PAGE 7 out of 4 PAGE 8 out of 3 TOTAL out of 30 2
Background image of page 2
In all questions where a big-Oh characterization is asked, give the best possible one. Question 1 [2 points] The ADT Sequence contains, among others, the following methods: last() returns the last element of the list previous(p) : returns the position of the element that precedes the element at position p . equal(p, NIL) : check whether position p points to a null element Consider algorithm A in the following pseudo-code: Algorithm A(Sequence L) // Assume L has at least two elements p = L.last(); p1 = previous(p); p2 = previous(p1); while not equal(p2, NIL) do { p = p1; p1 = p2; p2 = previous(p2) } return p.element What does A return (write at most 8 words) ? The second element of the sequence.
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 02/24/2010 for the course SITE CSI2110 taught by Professor Mohammadomar during the Fall '09 term at University of Ottawa.

Page1 / 8

csi06 sol - CSI2110A/B Data Structures and Algorithms...

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