京都大学 情報学研究科 知能情報学専攻 2024年8月実施 情報学基礎 F2-1
Author
itsuitsuki
Description
大学公表の原題
Q.1
Let S=(3,−1,2,−4,5,−1,3,−3,4,−2,1,−2) be a number sequence of length 12 and s(i) is the value of the i-th element of S. For example, s(1)=3 holds. Let us define maxSum(i,j)=maxi≤a≤b≤j∑k=abs(k) and M=maxSum(1,12).
(1) Derive the value of maxSum(1,4).
(2) Derive M and all the values of (a,b) that satisfy ∑k=abs(k)=M.
(3) Derive all the values of (a,b) that satisfy ∑k=abs(k)=M−1.
Q.2
Consider an algorithm for generating an undirected graph using random numbers, whose pseudocode is given below.
let G1(V1,E1) be an undirected graph with V1={v0,v1} and E1={{v0,v1}};
for i=2 to n do
begin
let vi be a new vertex;
let vj and vk be distinct vertices randomly selected from Vi−1;
let Gi(Vi,Ei) be an undirected graph with Vi=Vi−1∪{vi} and
Ei=Ei−1∪{{vi,vj},{vi,vk}};
end
Note that for any pair of distinct vertices (vj,vk), the selection probability is positive. Obviously, any graph Gn(Vn,En) constructed by this algorithm is connected, has n+1 vertices, and does not contain a self-loop or a multi-edge. In the following, we use Gn to denote Gn(Vn,En).
For a graph Gn, degGn(vp) denotes the degree of a vertex vp∈Vn (i.e., the number of edges connecting to vp), and distGn(vp,vq) denotes the length (i.e., the number of edges) of the shortest path (i.e., the path consisting of the minimum number of edges) between two distinct vertices vp and vq in Vn. Note that degGn(vp) and distGn(vp,vq) are positive integers depending on randomly selected vertices in the algorithm.
In the following, n is an even number greater than or equal to 4. Let Gn be the set of all possible undirected graphs Gn generated by this algorithm. For example, for any n,
minGn∈Gn{ minvp∈Vn{degGn(vp)} }=2 and maxGn∈Gn{ minvp∈Vn{degGn(vp)} }=2 hold because degGn(vn)=2 always holds and degGn(vp)≥2 always holds for any vertex vp∈Vn.
Derive the following values. Note that the values may be given as mathematical expressions of n.
(1) maxGn∈Gn{ maxvp∈Vn{degGn(vp)} }
(2) minGn∈Gn{ maxp<q,vp∈Vn,vq∈Vn{distGn(vp,vq)} }
(3) maxGn∈Gn{ maxp<q,vp∈Vn,vq∈Vn{distGn(vp,vq)} }
题目描述
- 令
S=(3,−1,2,−4,5,−1,3,−3,4,−2,1,−2),并定义
maxSum(i,j)=i≤a≤b≤jmaxk=a∑bs(k),M=maxSum(1,12).
求 maxSum(1,4);求 M 及全部使区间和为 M 的 (a,b);再求全部使区间和为 M−1 的 (a,b)。
- 随机图算法从边 {v0,v1} 开始。对 i=2,…,n,新建 vi,从已有顶点中随机选不同的 vj,vk,加入边
{vi,vj},{vi,vk}。设 n≥4 为偶数,Gn 为所有可能输出。求:
- 所有图中最大可能顶点度;
- 所有图中最小可能直径;
- 所有图中最大可能直径。
答案可写成 n 的表达式。
Kai
Q.1
Let p0=0 and pj=∑k=1js(k). The complete prefix-sum list is
(p0,p1,…,p12)=(0,3,2,4,0,5,4,7,4,8,6,7,5).
Every interval sum is pb−pa−1, with a−1<b.
(1) Among the first four elements, the maximum is 4, attained by (a,b)=(1,3).
(2) The largest difference of a prefix sum and an earlier prefix sum is M=8. The complete set of maximizing intervals is
(a,b)=(1,9), (5,9).
(3) Reading all ordered pairs of prefix sums whose difference is 7 gives exactly
(a,b)=(1,7), (1,11), (5,7), (5,11).
Q.2
(1)
There are n+1 vertices, so every degree is at most n. Choose v0,v1 as the two neighbors of every new vertex. Then v0 has degree n, proving that the answer is n.
(2)
The same construction has diameter 2: any two new vertices share v0 as a neighbor. A diameter of 1 would require a complete graph, but every generated graph has
∣En∣=1+2(n−1)=2n−1<2n(n+1)(n≥4).
Thus the minimum diameter is 2.
(3)
Every generated graph with at least three vertices remains connected after deleting any one vertex. This holds for the initial triangle. Inductively, a new vertex has two distinct neighbors, so deleting one old vertex leaves it joined to the remaining connected old graph; deleting the new vertex simply restores the old graph.
Let u,v have distance d, and group vertices by their distance from u. Each layer 1,…,d−1 contains at least two vertices: a singleton layer would disconnect u from v when its sole vertex was deleted, since an edge changes distance from u by at most one. Counting the endpoints and intermediate layers gives
n+1≥1+2(d−1)+1=2d.
Because n is even, d≤n/2.
To attain this bound, connect each vi to vi−1 and vi−2. Every edge changes the index by at most two, and the path v0,v2,…,vn has length n/2. Hence the maximum diameter is n/2.