{ "q1": { "type": "multiple", "question": "\n\nWhich programming languages are normally supported in programming contest\nenvironments?\n\n", "responses": { "c": "C", "java": "Java", "python": "Python", "perl": "Perl", "cpp": "C++", "js": "JavaScript", "ruby": "Ruby", "bash": "Bash" } }, "q3": { "type": "single", "question": "\n\nWhat is the time complexity of the following code?\n\n\n
\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", "responses": { "1": "O(1)", "n2": "O(n^2)", "nlogn": "O(nlog(n))", "n": "O(n)" } }, "q2": { "type": "order", "question": "\n\nRank the following complexity classes from lowest (fastest) to highest\n(slowest).\n\n", "responses": { "1": "O(1)", "sqrtn": "O(sqrt(n))", "logn": "O(log(n))", "n2": "O(n^2)", "nlogn": "O(nlog(n))", "nf": "O(n!)", "n": "O(n)" } }, "q5": { "type": "multiple", "question": "\n\n\nWhich of the following statements about dynamic arrays (aka vectors) and\nlinked lists are true (choose all that apply)?\n\n\n", "responses": { "remove_list": "Removing an element from the middle of a doubly-linked list is O(n).", "insert_array": "Inserting to the front of a dynamic array is always more expensive than inserting to the back.", "insert_list": "Inserting to the front of a linked list is always more expensive than inserting to the back.", "cache_list": "Linked lists generally exhibit poor cache behavior.", "remove_array": "Removing an element from the middle of a dynamic array is O(n).", "cache_array": "Dynamic arrays generally exhibit poor cache behavior." } }, "q4": { "type": "single", "question": "\n\nWhat is the time complexity of the following code?\n\n\n
\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", "responses": { "1": "O(1)", "n2": "O(n^2)", "nlogn": "O(nlog(n))", "n": "O(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" }, "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" }, "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" } }