{ "q1": { "type": "multiple", "question": "\n\nWhich programming languages are normally supported in programming contest\nenvironments?\n\n", "responses": { "bash": "Bash", "c": "C", "cpp": "C++", "ruby": "Rust", "java": "Java", "js": "JavaScript", "perl": "Perl", "python": "Python" } }, "q2": { "type": "order", "question": "\n\nRank the following complexity classes from lowest (fastest) to highest\n(slowest).\n\n", "responses": { "nf": "O(n!)", "logn": "O(log(n))", "n2": "O(n^2)", "1": "O(1)", "n": "O(n)", "sqrtn": "O(sqrt(n))", "nlogn": "O(nlog(n))" } }, "q3": { "type": "single", "question": "\n\nWhat is the time complexity of the following code (both the C++ and Python\nversions have equivalent complexity)?\n\n\n
\n// C++\nvoid f(vector<string> &a, vector<string> &b, vector<string> &c) {\n    c.clear();\n\n    for (auto e : a) {\n        if (find(b.begin(), b.end(), e) != b.end()) {\n            c.push_back(e);\n        }\n    }\n}\n\n// Python\ndef f(a: list[str], b: list[str]) -> list[str]:\n    c = []\n\n    for e in a:\n        if e in b:\n            c.append(e)\n\n    return c                                   \n
\n", "responses": { "n2": "O(n^2)", "1": "O(1)", "n": "O(n)", "nlogn": "O(nlog(n))" } }, "q4": { "type": "single", "question": "\n\nWhat is the time complexity of the following code (both the C++ and Python\nversions have equivalent complexity)?\n\n\n
\n// C++\nvoid f(vector<string> &a, vector<string> &b, vector<string> &c) {\n    c.clear();\n\n    sort(b.begin(), b.end());\n\n    for (auto e : a) {\n        if (binary_search(b.begin(), b.end(), e)) {\n            c.push_back(e);\n        }\n    }\n}\n\n// Python\ndef f(a: list[str], b: list[str]) -> list[str]:\n    c = []\n\n    b.sort()\n\n    for e in a:\n        if (i := bisect.bisect_left(b, e)) != len(b) and b[i] == e:\n            c.append(e)\n                                              \n    return c\n
\n", "responses": { "n2": "O(n^2)", "1": "O(1)", "n": "O(n)", "nlogn": "O(nlog(n))" } }, "q5": { "type": "multiple", "question": "\n\n\nWhich of the following statements about dynamic arrays (aka vectors) and\nlinked lists (with head and tail pointers) are true (choose all that apply)?\n\n\n", "responses": { "cache_array": "Dynamic arrays generally exhibit poor cache behavior.", "cache_list": "Linked lists generally exhibit poor cache behavior.", "insert_array": "Inserting to the front of a dynamic array is always O(1).", "insert_list": "Inserting to the front of a linked list is always O(1).", "append_array": "Appending to the back of a dynamic array is always O(1).", "append_list": "Appending to the back of a linked list is always O(1).", "access_array": "Accessing an element in the middle of a dynamic array is O(1).", "access_list": "Accessing an element in the middle of a linked list is O(1).", "remove_array": "Removing an element from the middle of a dynamic array is O(n).", "remove_list": "Removing an element from the middle of a doubly-linked list is O(1)." } }, "q6": { "type": "blank", "question": "\n\n\nWhile stacks and queues provide both a ____ operation to add items and a\n____ operation to remove items from the collection, the former provides\n____ ordering while the latter provides ____ ordering.\n\n\n" }, "q7": { "type": "blank", "question": "\n\n\nBelow is a C++ function whose purpose is to reverse the contents of the\ngiven vector. It does this by copying the elements from the vector into\nanother container and then copying the elements back to the original\nvector.\n\nFill in the blanks to complete the implementation.\n\n\n\n
\nvoid reverse(vector<string> &v) {\n    ____<string> c;         // 1\n\n    for (auto e : v) {\n        ____;               // 2\n    }\n\n    ____;                   // 3\n    while (____) {          // 4\n        ____;               // 5\n        ____;               // 6\n    }\n}\n
\n" }, "q8": { "type": "blank", "question": "\n\n\nBelow is a Python function whose purpose is to reverse the contents of the\ngiven list. It does this by copying the elements from the list into\nanother container and then copying the elements back to the original list.\n\nFill in the blanks to complete the implementation.\n\n\n\n
\ndef reverse(v):\n    c = ____                // 1\n\n    for e in v:\n        ____                // 2\n\n    v = ____                // 3\n    while ____:             // 4\n        ____                // 5\n\n    return ____             // 6\n
\n" }, "q9": { "type": "multiple", "question": "\n\nWhich of the following statements about the course is true (select all that apply)?\n\n", "responses": { "readings": "Students cannot drop any readings.", "challenges": "Students can drop one programming challenge.", "style": "Challenges are graded purely on correctness and not on style.", "external": "Students must complete at least two external programming contests.", "participation": "Students are expected to attend class regularly and on-time.", "final": "There is a final exam in this course.", "deadlines": "There are no deadlines in this class.", "officehours": "There are online office hours (via Slack or Zoom) available to students.", "consulting": "Students may consult online references or copy from resources if properly cited.", "copying": "Students may consult or copy from solutions found online or from other students or from AI tools." } } }