Embercode
✕
Dynamic ProgrammingQuick quiz

Bitmask TSP

7 questions. Covers Bitmask DP in Python: travelling salesman over subsets.

Questions 1 to 5 of 7

  1. 1. What number does this program print? ``python mask = (1 << 1) | (1 << 3) print(mask ^ (1 << 1)) ``
  2. 2. What number does this program print? ``python print(((1 << 4) - 1) ^ (1 << 2)) ``
  3. 3. What time complexity does the bitmask TSP method in this lesson have for n cities?
  4. 4. The TSP program keeps two lists, best and parent, with one slot for each (set, last city) pair. For 20 cities each list has 2^20 * 20 slots, and each slot is an 8-byte reference. About how much memory do the two lists need together, ignoring the int objects?
  5. 5. Which expression adds city c to the set stored in mask?

5 question(s) left on this page.