{ "q1": { "type": "multiple", "question": "\n\n\nIn regards to greedy algorithms, which of the following statements are true\n(select all that apply)?\n\n\n", "responses": { "efficiency": "A greedy algorithm tends to be very efficient.", "backtrack": "A greedy algorithm will backtrack when it finds a suboptimal solution.", "approach": "A greedy algorithm constructs a solution by choosing the best option at the moment.", "guarantee": "A greedy algorithm is guaranteed to find the optimal solution." } }, "q3": { "type": "multiple", "question": "\n\n\nIn regards to data compression, which of the following statements are true\n(select all that apply)?\n\n\n", "responses": { "variable": "Variable-length codes are suboptimal because they utilize longer codewords.", "prefix": "Codewords can have the same prefix if they are variable length.", "compress": "To compress a string, we use binary code to replace each character with a corresponding codeword.", "codeword": "In a constant-length code, the length of each binary code is the same." } }, "q2": { "type": "single", "question": "\n\n\nGiven n events with their starting and ending times, which of the following\ngreedy strategies is considered optimal?\n\n\n", "responses": { "osclass": "I am not in operating systems.", "begin": "Always choose the event with the earliest start time first.", "end": "Always choose the event with the earliest end time first.", "shortest": "Always choose the event with the shortest time first." } }, "q5": { "type": "multiple", "question": "\n\n\nRegarding bit representation, which of the following statements is true\n(select all that apply?)\n\n\n", "responses": { "signed_two": "In signed representation, two's complement is used to compute the negative value of an integer.", "signed_one": "In signed representation, one's complement is used to compute the negative value of an integer.", "unsigned": "In unsigned representation, only nonnegative numbers can be used, but the upper bound for the values is larger.", "assignment": "In unsigned representation, it is illegal to assignment a negative number (ie. compiler error)." } }, "q4": { "type": "multiple", "question": "\n\nGiven the string DACABAD which of the following are valid Huffman\ncodes (select all that apply)?\n\n", "responses": { "a": "A = 1, B = 001, C = 000, D = 01", "c": "A = 1, B = 000, C = 001, D = 01", "b": "A = 0, B = 110, C = 111, D = 10", "e": "A = 1, B = 111, C = 110, D = 10", "d": "A = 0, B = 010, C = 111, D = 10" } }, "q7": { "type": "blank", "question": "\n\n\nGiven a completed version of the bitset Python script above, what values\nare printed at the lines marked by the comments:\n\n\n\n

\nA. ____ After adding elements to bitset.\n

\n\n

\nB. ____ After removing elements from bitset.\n

\n" }, "q6": { "type": "blank", "question": "\nComplete the following script utilizing bitsets in Python:\n\n
\nelements = (1, 2, 4)\nbitset   = ____                     # 1. Initialize bitset\n\n# Add elements to bitset\nfor i in elements:\n    bitset = ____                   # 2. Add element to bitset\n\n# Print contents of bitset\nprint(bitset)                       # A. After adding alements to bitset\n\n# Test for elements in bitset\nfor i in range(6):\n    if ____:                        # 3. Test if element is in bitset\n        print(i)\n\n# Remove elements from bitset\nfor i in elements:\n    bitset = _____                  # 4. Remove element from bitset\n\n# Print contents of bitset\nprint(bitset)                       # B. After removing elements from bitset\n
\n" } }