-
-
Save petrolifero/81665aaf13ed688e85abcda5a7b2b473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SeqFromAVL(avl) | |
{ | |
if (empty(avl)) | |
{ | |
return [] | |
} | |
else | |
{ | |
left = SeqFromAVL(avl->left) | |
right = SeqFromAVL(avl->right) | |
l = leftRightMerge(left,right) | |
return [avl->value] + l | |
} | |
} | |
leftRightMerge(l1,l2) | |
{ | |
if(empty(l1)) | |
{ | |
return l2 | |
} | |
else if(empty(l2)) | |
{ | |
return l1 | |
} | |
return [l1[0],l2[0]] + leftRightMerge(l1[1:], l2[1:]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment