{ "q1": { "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." } }, "q3": { "type": "blank", "question": "\n\n\nBelow is a function whose purpose is to reverse the contents of the given\nvector. It does this by copying the elements from the vector into a\ncontainer and then copying the elements back to the original vector.\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" }, "q2": { "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" } }