Skip to content

Instantly share code, notes, and snippets.

@petrolifero
Created Jun 21, 2019
Embed
What would you like to do?
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