What is the pseudocode for splay tree?

1 answer

Answer

1036112

2026-02-09 08:55

+ Follow

Splay(T,x)

while p[x] <> NIL

do y = p[x]

z = p[y]

if x = left[root[T]]

then Right-Rotate(T,root[T])

else if x = right[root[T]]

then Left-Rotate(T,root[T])

else if x = left[y] and y = left[z]

then Right-Rotate(T,z)

Right-Rotate(T,y)

else if x = right[y] and y = right[z]

then Left-Rotate(T,z)

Left-Rotate(T,y)

else if x = right[y] and y = left[z]

then Left-Rotate(T,y)

Right-Rotate(T,z)

else if x = left[y] and y = right[z]

then Right-Rotate(T,y)

Left-Rotate(T,z)

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.