习题 1: { 0 , 1 , { 0 , 1 } , { 1 , 2 } } {0, 1, {0, 1}, {1, 2}}{0,1,{0,1},{1,2}} 有几个元素? 机器学习中, 这类形式的集合有什么优点和缺点?
- 有4个元素,是一种递归的定义,集合内部可以包含其他集合。
习题 2:∅ 的基数是多少? {∅} 呢?
- ∅的基数是0,{∅}的基数是1。
习题 5: 多标签学习中, 输出为一个向量,相应的学习器算不算函数呢?
习题 6: 元组只能表达对象的数据部分, 还是可以完整地表达 (既包括数据, 也包括方法/函数)? 用一个具体的程序来说明。
元组可以类比为面向对象程序设计中的类,它不仅仅可以包含数据,也可包含方法。
class Tree{
int data;
Tree left;
Tree right;
public Tree leftChild(){
return this.left;
}
public Tree rightChild(){
return this.left;
}
}
习题7:定义二叉树
T
=
(
V
,
r
,
h
,
p
,
c
1
,
c
2
)
T = (V,r,h,p,c_1,c_2)
T=(V,r,h,p,c1,c2)
V
=
{
v
1
,
…
,
v
n
}
V = \{ v_1 , … , v_n \}
V={v1,…,vn}
r
∈
V
∪
{
ϕ
}
r ∈ V∪\{ \phi\}
r∈V∪{ϕ}
p
:
V
∖
{
r
}
→
V
p : V∖\{r\} → V
p:V∖{r}→V
c
1
:
V
→
V
∖
r
c_1:V \rightarrow V\setminus r
c1:V→V∖r,求左子节点
c
2
:
V
→
V
∖
r
c_2:V \rightarrow V\setminus r
c2:V→V∖r,求右子节点
a)
∀
v
∈
V
,
∀
K
>
0
,
p
k
(
v
)
≠
v
∀v∈ V,∀K>0, p^k(v) \neq v
∀v∈V,∀K>0,pk(v)=v 。 查找任意k次父节点,不会等于节点自身。
b) 节点的出度小于等于2
c)
∀
k
⩾
1
,
c
1
(
v
i
)
≠
p
k
(
v
i
)
,
p
1
(
c
1
(
v
i
)
)
=
v
i
∀k\geqslant1,c_1(v_i)\neq p^k(v_i) ,p^1(c_1(v_i))=v_i
∀k⩾1,c1(vi)=pk(vi),p1(c1(vi))=vi
d)
∀
k
⩾
1
,
c
2
(
v
i
)
≠
p
k
(
v
i
)
,
p
1
(
c
2
(
v
i
)
)
=
v
i
∀k\geqslant1,c_2(v_i)\neq p^k(v_i) ,p^1(c_2(v_i))=v_i
∀k⩾1,c2(vi)=pk(vi),p1(c2(vi))=vi
习题8:定义带权无向图
A weighted undirected graph is a tuple
G
u
=
(
V
,
w
)
G_u = ( V , w )
Gu=(V,w) where
V
=
{
v
1
,
…
,
v
n
}
V = \{v_1 , … , v_n\}
V={v1,…,vn} is the set of nodes,and
w
:
V
×
V
→
R
+
∪
{
0
}
w : V \times V \rightarrow R^+ ∪\{0\}
w:V×V→R+∪{0} is the edge weight function
a)
∀
(
v
1
,
v
2
)
∈
V
×
V
,
w
(
v
1
,
v
2
)
=
w
(
v
2
,
v
1
)
∀(v_1,v_2)∈V\times V, w(v_1,v_2) = w(v_2,v_1)
∀(v1,v2)∈V×V,w(v1,v2)=w(v2,v1) 。有向图也能满足这个条件啊,想不通如何用权值来表示无向。
习题9:考虑 ϕ \phi ϕ, 重新写 Definition 7 以解决其存在的问题, 见其讨论 d).
A tree is a triple
T
=
(
V
,
r
,
p
,
d
)
T=(V,r,p,d)
T=(V,r,p,d) where
V
=
{
v
1
,
…
,
v
n
}
V = \{v_1 , … , v_n\}
V={v1,…,vn} is the set of nodes,
r
∈
V
r ∈ V
r∈Vis the root,
p
:
V
∖
r
→
V
p:V∖{r} \rightarrow V
p:V∖r→V is the parent function satisfying,
d
:
V
→
R
+
d:V \rightarrow R^+
d:V→R+ is the distance function from the root node
a)
∀
k
≥
1
,
p
k
(
v
)
≠
v
∀ k ≥ 1, p^k ( v ) ≠ v
∀k≥1,pk(v)=v
b)
∀
v
i
∈
V
∖
r
,
∃
1
k
≥
1
a
n
d
k
⩽
d
(
v
i
)
,
p
k
(
v
i
)
=
r
∀v_i ∈ V ∖ { r } , \exists1 k ≥ 1 \ and \ k\leqslant d(v_i), p^k (v_i) = r
∀vi∈V∖r,∃1k≥1 and k⩽d(vi),pk(vi)=r
习题 3.1 模仿自动机的样子来重新定义二叉树.
A binary tree is a 5-triple, and
ϕ
\phi
ϕ be a null node,
M
=
(
Σ
,
Q
,
q
,
T
,
f
)
M=(Σ,Q,q ,T,f)
M=(Σ,Q,q,T,f) and
ϕ
\phi
ϕ be a null node where
a) Let
Σ
=
{
l
,
r
}
\Sigma = \{\mathrm{l}, \mathrm{r}\}
Σ={l,r} be the alphbet
b)
Q
\bm{Q}
Q is the set of states, It contains
ϕ
\phi
ϕ nodes;
c)
q
0
∈
Q
q_0 ∈ \bm{Q}
q0∈Q is the start state, the root of the binary tree;
d)
T
=
ϕ
T = \phi
T=ϕ is the set of terminal states;
e)
f
:
Q
×
Σ
∗
→
Q
f : Q × Σ^* \rightarrow Q
f:Q×Σ∗→Q is the transition function.
f)
∀
q
i
∈
Q
,
∃
1
s
∈
Σ
∗
s
t
.
f
(
q
0
,
s
)
=
q
i
∀q_i∈Q,\exists1s∈Σ^* st. f( q_0,s) = q_i
∀qi∈Q,∃1s∈Σ∗st.f(q0,s)=qi
习题3.2 模仿自动机的样子来重新定义树.
A tree is a 5-triple, and
ϕ
\phi
ϕ be a null node,
M
=
(
Σ
,
Q
,
q
,
T
,
f
)
M=(Σ,Q,q ,T,f)
M=(Σ,Q,q,T,f) and
ϕ
\phi
ϕ be a null node where
a) Let
Σ
=
{
p
}
\Sigma = \{p\}
Σ={p} be the alphbet
b)
Q
\bm{Q}
Q is the set of states, It contains
ϕ
\phi
ϕ nodes;
c)
q
0
∈
Q
q_0 ∈ \bm{Q}
q0∈Q is the start state, the root of the binary tree;
d)
T
=
ϕ
T = \phi
T=ϕ is the set of terminal states;
e)
f
:
Q
×
Σ
∗
→
Q
f : Q × Σ^* \rightarrow Q
f:Q×Σ∗→Q is the transition function.
f)
∀
q
i
∈
Q
,
∃
1
s
∈
Σ
∗
s
t
.
f
(
q
0
,
s
)
=
q
0
∀q_i∈Q,\exists1s∈Σ^* st. f( q_0,s) = q_0
∀qi∈Q,∃1s∈Σ∗st.f(q0,s)=q0