Midterm Exam COS 217 1 Midterm Exam Statistics
- Slides: 6
Midterm Exam COS 217 1
Midterm Exam • Statistics o Average score: 72 o Median score: 76 o Range of scores: 29 -101 • More detailed breakdown o o o 6 people scored 90 -101 15 people scored 80 -89 15 people scored 70 -79 9 people scored 60 -69 14 people scored below 60 • So, this test was hard, and a little long o Quite a few students didn’t finish the last question o Questions 4 and 5 were pretty challenging 2
Common Mistakes • Question 1 o Treating “+” as string concatenation, rather than numerical addition – E. g. , putchar(‘ 0’ + (837 % 10)) does not print “ 07” – For example, ‘ 0’ + 7 is ‘ 7’, not “ 07” • Question 2 o Misunderstanding the idiom “while (*s) s++; ” – The boolean *s is true until you reach the ‘ ’ character – The s++ keeps incrementing, one character at a time, till ‘ ’ o Meaning of “const char *” – Common mistake to assume that the pointer cannot change – When actually it is the memory contents that cannot change • Question 3 c o Not understanding that heap and stack could grow in same direction – Heap could easily start at one location, and stack at another – But, this would reduce flexibility in sharing the memory space 3
Common Mistakes(Continued) • Question 4 o Certain valid strings were not handled, including: – ##. Numbers ending with a decimal point – +. ## Sign followed by a dot – #E+# Sign in the exponent o Some invalid strings were accepted, including – ##. Multiple decimal points (or E’s, or signs) – +. Just a decimal point, or sign with decimal point – #E. # Decimal in the exponent o Finally, some did not clearly indicate their DFA – A few wrote non-deterministic finite automata – Many forgot to label transitions, or mark final states 4
Common Mistakes (Continued) • Question 5 c: Queue_empty o Misinterpreting the functionality of Queue_empty – Several students emptied the Queue of its elements – Rather than checking whether the Queue is empty o Checking for queue with one entry, rather than empty – Several students checked for queue->head == queue->tail – Rather than checking that the head and/or tail are NULL o Missed opportunity for concise code (no points removed) – Return value determined via if/else block – Rather than doing return (queue->head == NULL) 5
Common Mistakes (Continued) • Question 5 d: Queue_add o Implementing a stack instead of a queue – Adding element to the head, rather than the tail o Missing corner case – When the queue is initially empty o Missing assert after call to malloc() – Forgetting the assert() when calling malloc for new entry • Question 5 e: Queue_remove o Implementing a stack instead of a queue – Removing element from the tail, rather than the head o Missing corner cases – Removing an element from an empty queue – Removing the last element in the queue o Not copying the head entry to enable return of the item – Not making a separate copy of the head element, and item – Not doing a free() to return the space used by head element 6