已知二叉搜索树如下图所示,请指出搜索[25,89]结点的搜索路径(依次搜索过的结点)
A.35,36,71,60,42,88,81
B.35,36,71,60,88,42,81
C.35,24,36,71,60,42,88,81,95
D.35,24,36,71,60,42,88,81
- · 有4位网友选择 A,占比50%
- · 有3位网友选择 D,占比37.5%
- · 有1位网友选择 C,占比12.5%
A.35,36,71,60,42,88,81
B.35,36,71,60,88,42,81
C.35,24,36,71,60,42,88,81,95
D.35,24,36,71,60,42,88,81
A、
B、
C、
D、
A、import queue as que import math x=[] y=[] def koch(ax,ay,bx,by,c): dist=(bx-ax)*(bx-ax)+(by-ay)*(by-ay) if(dist<=c): x.append(ax) x.append(bx) y.append(ay) y.append(by) else: cx="ax+(bx-ax)/3" cy="ay+(by-ay)/3" ex="bx-(bx-ax)/3" ey="by-(by-ay)/3" l="math.sqrt(math.pow(ex-cx,2)+pow(ey-cy,2))" alpha="math.atan((ey-cy)/(ex-cx))" if (alpha>=0 and (ex-cx)<0) or and alpha="alpha+math.pi" dy="cy+math.sin(alpha+math.pi/3)*l" dx="cx+math.cos(alpha+math.pi/3)*l" koch(ax,ay,bx,by,c) koch(bx,by,cx,cy,c) koch(cx,cy,dx,dy,c)> B、import queue as que import math x=[] y=[] def koch(ax,ay,bx,by,c): dist=(bx-ax)*(bx-ax)+(by-ay)*(by-ay) if(dist<=c*c): x.append(ax) x.append(bx) y.append(ay) y.append(by) else: cx="ax+(bx-ax)/3" cy="ay+(by-ay)/3" ex="bx-(bx-ax)/3" ey="by-(by-ay)/3" l="math.sqrt(d/3)" alpha="math.atan((ey-cy)/(ex-cx))" if (alpha>=0 and (ex-cx)<0) or and alpha="alpha+math.pi" dy="cy+math.sin(alpha+math.pi/3)*l" dx="cx+math.cos(alpha+math.pi/3)*l" koch(ax,ay,cx,cy,c) koch(cx,cy,dx,dy,c) koch(cx,cy,ex,ey,c)> C、import queue as que import math import matplotlib.pyplot as plt x=[] y=[] def koch(ax,ay,bx,by,c): dist=(bx-ax)*(bx-ax)+(by-ay)*(by-ay) if(dist<=c*c): x.append(ax) x.append(bx) y.append(ay) y.append(by) else: cx="ax+(bx-ax)/3" cy="ay+(by-ay)/3" ex="bx-(bx-ax)/3" ey="by-(by-ay)/3" l="math.sqrt(math.pow(ex-cx,2)+pow(ey-cy,2))" alpha="math.atan((ey-cy)/(ex-cx))" if (alpha>=0 and (ex-cx)<0) or and alpha="alpha+math.pi" dy="cy+math.sin(alpha+math.pi/3)*l" dx="cx+math.cos(alpha+math.pi/3)*l" koch(ax,ay,cx,cy,c) koch(cx,cy,dx,dy,c) koch(dx,dy,ex,ey,c)> D、import queue as que import math x=[] y=[] def koch(ax,ay,bx,by,c): dist=(bx-ax)*(bx-ax)+(by-ay)*(by-ay) if(dist<=c*c): x.append(ax) x.append(bx) y.append(ay) y.append(by) else: cx="ax+(bx-ax)/3" cy="ay+(by-ay)/3" ex="bx-(bx-ax)/3" ey="by-(by-ay)/3" l="math.sqrt(d/3)" alpha="math.atan((ey-cy)/(ex-cx))" if (alpha>=0 and (ex-cx)<0) or and alpha="alpha+math.pi" dy="cy+math.sin(alpha+math.pi/3)*l" dx="cx+math.cos(alpha+math.pi/3)*l" koch(ax,ay,cx,cy,c) koch(ex,ey,dx,dy,c) koch(cx,cy,ex,ey,c)>
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!