Skip to content

Instantly share code, notes, and snippets.

@Chris--B
Created October 1, 2012 03:20
Show Gist options
  • Save Chris--B/3809299 to your computer and use it in GitHub Desktop.
Save Chris--B/3809299 to your computer and use it in GitHub Desktop.
idontknowwhatimdoing
public void copyn(BinaryTree other, int depth)
{
copyn_r(other.root, depth);
}
private void copyn_r(node n, int depth)
{
if(n == null)
return;
else
this.add(n.data);
if(depth == 0)
return;
if(n.left != null)
{
copyn_r(n.left, depth - 1);
}
if(n.right != null)
{
copyn_r(n.right, depth - 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment