京都大学 情報学研究科 知能情報学専攻 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 的表达式。
- 最大连续子数组和:计算最大和及次优和,并完整枚举达到指定和的区间。
- 图度数与直径的极值构造:分析每个新顶点连接两个旧顶点的生成规则,构造并证明最大度、最小直径和最大直径界。