Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ListaHeap( T, k )
- L = {}
- if T != nil then
- [Esercizio A] L = Lista( T, k, L )
- [Esercizio B] L = Lista( T, k, L, 0 )
- |_
- return L
- |_
- CancellaHeap( T )
- if T != nil then
- if T->sx != nil and T->dx != nil then
- if T->sx->key > T->dx->key then
- T->key = T->sx->key
- T->sx = CancellaHeap( T->sx )
- else
- T->key = T->dx->key
- T->dx = CancellaHeap( T->dx )
- |_
- elseif T->sx != nil then
- T->key = T->sx->key
- T->sx = CancellaHeap( T->sx )
- elseif T->dx != nil then
- T->key = T->dx->key
- T->dx = CancellaHeap( T->dx )
- else
- delete T
- T = nil
- |_
- |_
- return T
- |_
- Lista( T, k, L )
- if T != nil then
- if T->key < k then
- if T->key % 2 == 0 then
- L = addCoda( L, T->key )
- |_
- T = CancellaHeap( T, nil )
- L = Lista( T, k, L )
- |_
- |_
- return L
- |_
- Lista( T, k, L, max )
- if T != nil then
- max = findMax( T, k, max )
- if max != -1 then
- if max % 2 == 0 then
- L = addCoda( L, max )
- |_
- L = Lista( T, k, L, max )
- |_
- |_
- return L
- |_
- findMax( T, k, min )
- if T != nil then
- if T->key < K then
- return T->key
- else
- return Max{ findMax( T->sx, k, min ), findMax( T->dx, k, min ) }
- |_
- |_
- return -1
- |_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement