分数 3
作者 王灿
单位 浙江大学

Consider the metric Facility Location problem. A company wants to distribute its product to various cities. There is a set II of potential locations where a storage facility can be opened and a fixed “facility cost” fif_i associated with opening a storage facility at location iIi \in I. (Sometimes we will say “facility ii” to mean “facility at location ii”). There also is a set JJ of cities to which the product needs to be sent, and a “routing cost” c(i,j)c(i, j) associated with transporting the goods from a facility at location ii to city jj. The goal is to pick a subset SS of II so that the total cost of opening the facilities and transporting the goods is minimized. In short, we want to minimize C(S)=Cf(S)+Cr(S)C(S) = C_f(S) + C_r(S), where Cf(S)=iSfiC_f(S) = \sum_{i \in S} f_i and Cr(S)=jJminiSc(i,j)C_r(S) = \sum_{j\in J}\min_{i\in S}c(i,j). Consider the following local serach algorithm:

  1. Picking any subset SS of the set II of facilities. This give us a feasible solution right away.
  2. We then search for the local neighborhood of the current feasible solution to see if there is a solution with a smaller objective value; if we find one we update our feasible solution to that one.
  3. We repeat step 2 until we do not find a local neighbor that yields a reduction in the objective value.

There are two types of “local steps” that we take in searching for a neighbor: i) remove/add a facility from/to the current feasible solution, or ii) swap a facility in our current solution with one that is not.

Which of the following statement is true?


分数 3
作者 陈越
单位 浙江大学

In a character set S consisting of 5 characters, given their occurrence frequencies being 3, 5, 7, 11 and 14, the weighted average length of Huffman codes for S is:


分数 3
作者 卜佳俊
单位 浙江大学

image.png
Merge the two leftist heaps in the figure. How many of the following statements is/are FALSE ?

  • 8 and 10 are siblings
  • 7 and 4 are siblings
  • 4 and 10 have the different NPL
  • along the left path from the root, we have 1, 4, 10, 16

分数 3
作者 丁尧相
单位 浙江大学

How many of the following arguments are correct?

  • For non-deterministic Turing machine, “non-deterministic” means that the operations of the machine are random, such that the results of the operations are not deterministic.
  • If a decision problem A can be reduced to B, then it means that problem A is strictly easier than B in terms of computational complexity.
  • A decision problem in P is also in both NP and co-NP.

分数 3
作者 刘金飞
单位 浙江大学

If we insert N(N2)N(N \geqslant 2) nodes (with different integer elements) consecutively to build a red-black tree TT from an empty tree, which of the following situations is possible:


分数 3
作者 卜佳俊
单位 浙江大学

image.png

After inserting 15 into the Skew Heap in the figure, which of the following statements is correct for the resulted Skew Heap?


分数 3
作者 陈昊
单位 浙江大学

The Merging problem is to merge two non-decreasing arrays A(1), A(2), ..., A(nn) and B(1), B(2), ..., B(nn) into another non-decreasing array C(1), C(2), ..., C(2nn). To solve it in parallel, we turn it into a Ranking problem. That is, to compute RANK(A(ii),B) and RANK(B(ii),A) for every 1in1≤i≤n, where RANK(ee,SS) is the position of e in S.

  • The following psuedo-code computes the ranks with binary search in parallel.
    for Pi, 1<=i<=n  pardo
      RANK(A(i),B) := BS(A(i),B)
      RANK(B(i),A) := BS(B(i),A)
    where BS(e,S) is to find the position of e in S by binary search.
  • The following psuedo-code computes the ranks in serial.
    i = j = 0; 
    while ( i ≤ n || j ≤ m ) { 
      if ( A(i+1) < B(j+1) )  
          RANK(++i, B) = j; 
      else  RANK(++j, A) = i; 
    }

How many of the following statements are True?

  • For binary search parallel ranking, T(n)=O(logn)T(n) = O(\log n), W(n)=O(n)W(n) = O(n)
  • For serial ranking, T(n)=O(n)T(n) = O(n), W(n)=O(n)W(n) = O(n)
  • Given a solution to the ranking problem, the merging problem can be solved in O(1)O(1) time and O(n)O(n) work.

分数 3
作者 Yang Yang
单位 浙江大学

In a binomial queue, we donote the total number of the nodes at even depth and odd depth as N1N_1 and N2N_2, respectively (the root is defined to be at the depth 0). Which of the following statements is FALSE?


分数 3
作者 Yang Yang
单位 浙江大学

Consider the following function, where the time complexity for function calc() is O(1)O(1).

void fun(int l, int r) {
    if(r-l+1<=1234) return;
    int m=(l+r)/2;
    int m1=(l+m)/2, m2=(m+1+r)/2;
    fun(l, m);
    fun(m1+1, m2);
    for(int k=1;k<=r-l+1;k++)
        for(int i=1;i<=r-l+1;i++)
            for(int j=l;j<=r;j+=i)
                calc(j, i);
    fun(m+1, r);
    fun(m1+1, m2);
}

Assume the initial input is l=1, r=N, What is the running time of this function? Your answer should be as tight as possible.


分数 3
作者 陈昊
单位 浙江大学

For the Maximum Finding, how many of the following statements are True?

  • Replace “+” by “max” in the parallel summation algorithm, we get an algorithm with T(n)=O(logn)T(n) = O(\log n), W(n)=O(n)W(n) = O(n).
  • There exists a parallel algorithm solving the problem in constant time.
  • With high probability, parallel random sampling algorithm can run with O(logn)O(\log n) work load.
  • By adjusting the partition to n\sqrt n with a parallel divide and conquer paradigm, we can achieve T(n)=O(loglogn)T(n) = O(\log\log n), W(n)=O(n)W(n) = O(n)

分数 3
作者 陈越
单位 浙江大学

To find the kkth smallest number in a set SS, randomized quick selection algorithm works in the following way:

  1. If S=1|S|=1, then k=1k=1 and return the only element in SS.
  2. Randomly select a central splitter pSp\in S, which is a pivot that divides the set so that each side contains at least S/4|S|/4 elements.
  3. Partition S{p}S-\{ p\} into S1S_1 and S2S_2, as was done with quicksort.
  4. If kS1k\le |S_1|, recursively find the kkth smallest number in S1S_1. If k=S1+1k=|S_1|+1, return the pivot as the answer. Otherwise, recursively find the (kS11)(k-|S_1|-1)st smallest number in S2S_2.

If S=n|S|=n, then the best upper bound of the expected time complexity of this algorithm is:


分数 3
作者 陈昊
单位 浙江大学

Given the following game tree, node dd will be pruned with αβα-β pruning algorithm if and only if _____.

6a618b7b-0d3d-41a3-bd2b-0b90d020d15c.png


分数 3
作者 叶德仕
单位 浙江大学

In external sorting, suppose we have nn runs of lengths 20,21,,2n12^0, 2^1, \ldots, 2^{n-1}, respectively. To obtain the minimum merge time, which of the following statement is FALSE?


分数 3
作者 叶德仕
单位 浙江大学

A sum list L is a data structure that can support the following operations:

  • Insert (x, L): insert the item x into the list L. The cost is 1 dollar.
  • Sum(L): sum all items in the list L, and replace the list with a list containing one item that is the sum. The cost is the length of the list |L| dollars.

Now we would like to show that any sequence of Insert and Sum operations can be performed in O(1)O(1) amortized cost per insert and O(1)O(1) amortized cost per Sum. Which of the following statement is TRUE?


分数 3
作者 Yang Yang
单位 浙江大学

We all know how to use the binary search method to find a value in a monotonic array. As an extension, we will use the ternary search method to find the extremum in a quadratic-function-like array. Formally, for an array aa, let kk be the position of its extremum. Then we have either a[1]<...<a[k1]<a[k]>a[k+1]>...>a[n]a[1]<...<a[k-1]<a[k]>a[k+1]>...>a[n] or a[1]>...>a[k1]>ak<a[k+1]<...<a[n]a[1]>...>a[k-1]>a_k<a[k+1]<...<a[n]. Apply the ternary search method to locate kk. For a given interval 1l<rn1 \leq l < r \leq n, locate the two trisection points in [l,r][l,r] as m1=l+rl3m1=l+\lfloor\frac{r−l}{3}\rfloor and m2=l+2(rl)3m2=l+\lfloor\frac{2(r−l)}{3}\rfloor. Assuming we are looking for the minimum value, which of the following pieces of code can correctly narrow down the target interval?


分数 3
作者 陈越
单位 浙江大学

Which of the following is NOT an element of Greedy strategy?


分数 3
作者 刘金飞
单位 浙江大学

When searching for the keyword "game theory" on Google, the first four results returned are as follows:

Doc Text
1 Game theory is the study of mathematical models of strategic interactions among rational agents. It has applications in many social science fields.
2 Game theory is the study of how players strategize and make decisions. It's a way to model scenarios in which conflicts of interest exist among the players.
3 Game theory is a branch of applied mathematics that provides tools for analyzing situations in which players make interdependent decisions.
4 Hello Internet! Welcome to GAME THEORY! If you are like us, then you have probably wondered about the secrets hidden in your favorite games.

Now if we construct an inverted file index for the results shown above, ignore case(忽略大小写)and do word stemming, please fill in the blanks in the inverted file index (not complete) below:

No. Term Times; Documents; Words
1 game 5;(1;1),(2;1),(3;1),(4;5),(4;24)\langle 5; (1;1), (2;1), (3;1), (4;5), (4;24)\rangle
2 strategy 2;(1;10),(2;1)\langle 2; (1;10), (2;\underline{\textcircled{1}})\rangle
3 apply 2;(1;17),(3;7)\langle 2; (1;17), (3;7)\rangle
4 math 2;(1;7),(2;8)\langle 2; (1;7), (\underline{\textcircled{2}};8)\rangle

分数 3
作者 卜佳俊
单位 浙江大学

image.png


For the result of accessing the keys 2 and 3 (in order) of the splay tree in the figure, which one of the following statements is FALSE ? (Note: the numbers are the indices of the nodes, not the key values.)


分数 3
作者 Yang Yang
单位 浙江大学

Which of the following statements about binomial queue is FALSE?


分数 3
作者 丁尧相
单位 浙江大学

Consider the 0-1 knapsack problem with object weights ww, profits vv, and total weight limit BB (means that ww of any object is no larger than BB.). In the class, we have learned that combining the greedy algorithm on maximum profit vv and maximum profit-weight ratio v/wv/w leads to an approximation algorithm which always produces a solution no less than 1/2 of the optimal solution. Now let us consider the following simplified greedy algorithm. The algorithm first conducts the following sorting w.r.t. profit-weight ratio:

Screenshot 2024-06-19 at 10.42.48.png

Let the sorted order of objects be a1,,ana_1, …, a_n. The next step is to find the lowest kk such that the total weight of the first kk objects exceeds BB. Finally, we pick the more valuable of {a1,,ak1}\{a_1, …, a_{k-1}\} and {ak}\{a_k\} as the final solution. Then which of the following arguments is correct: