03/11/2021, 02:14
v = Q.root
if v.x = x and v.y = y
return v.name
else
if x < v.x and y >= v.y
if v.NW not NIL
Search(v.NW,x,y)
else
return "error: no city with coordinate (x,y) exsits"
if x >= v.x and y > v.y
if v.NE not NIL
Search(v.NE,x,y)
else
return "error: no city with coordinate (x,y) exsits"
if x > v.x and y =< v.y
if v.SE not NIL
Search(v.SE,x,y)
else
return "error: no city with coordinate (x,y) exsits"
if x <= v.x and y < v.y
if v.SW not NIL
Search(v.SW,x,y)
else
return "error: no city with coordinate (x,y) exsits"
end
v = Q.root
if v= NIL
return does not exist
if v.x = x and v.y = y
return v
if x < v.x and y >= v.y
Search(v.NW,x,y)
if x >= v.x and y > v.y
Search(v.NE,x,y)
if x > v.x and y =< v.y
Search(v.SE,x,y)
if x <= v.x and y < v.y
Search(v.SW,x,y)
end
ans = SearchMostSouth(Q.root)
return ans.name
v = Q.root
if v.SW == NIL and v.SE == NIL
return v
else
w = new element with all pointer set to NIL w.name is a fake name and w.x = 0 and w.y = infinity
e = new element with all pointer set to NIL w.name is a fake name and w.x = 0 and w.y = infinity
if v.SW not NIL
w = SearchMostSout(v.SW)
if v.SE not NIL
e = SearchMostSout(v.SE)
if w.y <= e.y
return w
if e.y <= w.y
return e
end
v = Q.root
w = infinity
e = infinity
if v.SW not NIL
(w,wname) = SearchMostSout(v.SW)
if v.SE not NIL
(e,ename) = SearchMostSout(v.SE)
if w <= e, v.y
return (w,wname)
if e <= w, v.y
return (e,ename)
if v.y <= e,w
return (v.y,v.name)
end
03/11/2021, 10:46
3m0o ha scritto: E okay, ma poi tutti i puntatori di Yverdon sono vuoti mi dice ma secondo me dovrebbe esserci il puntatore Y.NE che punta a Neuchatel perché Neuchatel sta a nord est di Yverdon, perché non c'è? Ugualmente mi dice che tutti i puntatori di Neuchatel sono vuoti...
03/11/2021, 11:38
Quinzio ha scritto:L'unica cosa che non si capisce e' perche' all'inizio si inizializza sempre v alla radice.
v = Q.root
E come fa a funzionare bene poi ?
03/11/2021, 23:08
Skuola.net News è una testata giornalistica iscritta al Registro degli Operatori della Comunicazione.
Registrazione: n° 20792 del 23/12/2010.
©2000—
Skuola Network s.r.l. Tutti i diritti riservati. — P.I. 10404470014.
Powered by phpBB © phpBB Group - Privacy policy - Cookie privacy
phpBB Mobile / SEO by Artodia.