Sp06M2SolutionAndCriteria

Sp06M2SolutionAndCriteria - Answers and Criteria for CS307...

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

View Full Document Right Arrow Icon
Answers and Criteria for CS307 Midterm 2, Spring 2006. Acronyms on test: OBOE = off by one error BOD = benefit of the doubt GCE = gross conceptual error 1. Answer as written or -2. On Big O okay if missing O() or use variable other than N. A. 16 B. 5 C. 31 D. O(N) E. O(N) F. GLTF G. O(1) H. O(N) I. O(N) J. O(N^2) K. O(N^2 log N) okay if base on log L. 24 seconds M. 40 seconds N O(log N) okay if base on log O. O(N) 2. Reverse array based list. Suggested solution: public void reverse(){ Object temp; int limit = mySize / 2; for(int i = 0; i < limit; i++){ temp = myCon[i]; myCon[i] = myCon[mySize - 1 - i]; myCon[mySize - 1 - i] = temp; } } Okay to use temp array. Lots of "off by one errors". Many people who used temp array did not assign myCon to temp. Point break down Loop through elements: attempt +5 correct +5 Swap or move elements to reverse: attempt +5 correct + 5
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. Split singly linked list based on position Suggested solution: public SinglyLinkedList split(int position){ SinglyLinkedList result = new SinglyLinkedList();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Sp06M2SolutionAndCriteria - Answers and Criteria for CS307...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online