CS1121903 - Computer Science Foundation Exam Dec. 19, 2003...

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

View Full Document Right Arrow Icon
Computer Science Foundation Exam Dec. 19, 2003 COMPUTER SCIENCE I Section I A No Calculators! Name: SSN: Score: In this section of the exam, there are Three (3) problems You must do all of them. The weight of each problem in this section is indicated with the problem. The algorithms in this exam are written in C programming language notation. Partial credit cannot be given unless all work is shown. As always, be complete, yet concise, and above all be neat . Credit cannot be given when your results are unreadable. KEY / 50
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 1. a) Convert the following infix expression to postfix, showing the values in the operator stack at each indicated point in the infix string (points 1, 2, 3 and 4), in the boxes below. You may add more boxes for each position if necessary to do so. [ 10 ] A / B / 1 ( C – R – J 2 * M + N ) – L 3 / D * E 4 * F GRADING SCHEME: Box 1 : [ 1 point ] Box 2, 3, 4 [ 2 points each] Resultant expression [ 3 points ] ( * / / 1 2 3 4 Resulting Expression : A B / C R – J M * – N + / L D / E * F * b) A circular queue is implemented on an array of size N. Let tail represent the index of the last element added to the queue, and head represent the index of the element to be deleted from the queue. To start with , the queue is empty, and both tail and head equal – 1 . How many more elements can the queue hold when [ 10 ] i) head = 30 tail = 33 __N – 4 _________ [ 3 points ] ii) head = 3 tail = 3 ___N – 1 _________ [ 3 points ] iii) head = 1 tail = N – 1 ____1________ [ 2 points ] iv) tail = – 1 head = – 1 ______N_______ [ 2 points ]
Background image of page 2
3 2. Trace the effect of executing the code segment shown below on the linked list structure, also shown below, by drawing the linked list as it would look after the code has been executed [ 10 ] struct list{ int data; struct list *next; }; p = head; while (p != NULL) { if (p->data <= 6) { newp = (struct list *) malloc(sizeof(struct list)); newp->data = p->data + 8; newp->next = p->next; p->next = newp; p = newp; } else p = p->next; } The new list has the elements 1, 9, 8, 7, 6, 14, 3, 11, 9, 5, 13, -1, 7 Give [ 2 points ] for each new node created head 1 8 7 6 3 9 5 -1 null
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 document was uploaded on 09/21/2011.

Page1 / 12

CS1121903 - Computer Science Foundation Exam Dec. 19, 2003...

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