{ "q1": { "type": "multiple", "question": "\n\n\nSuppose we wanted to sort a million integers where each integer is between\n0 and 1,000. Which of the following statements are false?\n\n\n", "responses": { "merge_bigo": "Merge sort would order the integers in O(nlogn) time in the worst case.", "quick_bigo": "Quick sort would order the integers in O(nlogn) time in the worst case.", "count_bigo": "Counting sort would order the integers in O(nlogn) time in the worst case.", "bubble_bigo": "Bubble sort would order the integers in O(nlogn) time in the worst case." } }, "q3": { "type": "blank", "question": "\n\n\nGiven the same vector in question 2, what would be the output of the\nfollowing statements after sorting the vector in ascending order:\n\n\n\n
\ncout << lower_bound(v.begin(), v.end(), 4) - v.begin() << endl; // 1. ____\ncout << upper_bound(v.begin(), v.end(), 6) - v.begin() << endl; // 2. ____\n
\n" }, "q2": { "type": "blank", "question": "\n\n\nGiven the following vector:\n\n\n\n
\nvector<int> v = {4, 6, 6, 3, 7, 5, 4, 7, 0, 1};\n
\n\n\nTo sort the vector in ascending order we would do:\n\n\n
\n____(____, ____);\n
\n\n\nTo sort the vector in descending order we would do:\n\n\n
\n____(____, ____);\n
\n" }, "q4": { "type": "blank", "question": "\n\nComplete the following implementation of binary search in C++:\n\n\n
\ntemplate <typename IT, typename T>\nbool binary_search(IT start, IT end, const T &target) {\n    while (____) {\n        auto length   = ____;\n        auto middle   = ____;\n        auto midpoint = *(____)\n\n        if (____) {\n            end   = ____;\n        } else if (____) {\n            start = ____;\n        } else {\n            return true;\n        }\n    }\n    return false;\n}\n\n
\n" } }