CS 2401, Spring 2009

Typical mistakes for Test 2

Problem 1:

Problem 2:

* the input should be a string, an algorithm should use stacks

* the algorithm was described in the class: if you see [ you push; if you see ],
you pop

* it is not always possible to pop; if the stack is empty, you cannot pop; example
is a string "]"

* a character and a string are completely different data types

* the problem asks for a method, so it should be a method

Problem 3:

* a code stack.pop() is not a code for popping an element in an array

Problem 5:

* elements are not moved when an element is dequeued, what is changed are the
indices "first" and "last" ("front" and "rear")

Problem 6:

* according to the book, ADT is a way to implement operations on the logical level,
independent on how different objects are operations are implemented; since most
students seem to be confused on this, I added 2 points to all the answers, making
10/10 an average grade on this question