Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
--- Praktische Informatik (http://www.informatikerboard.de/board/board.php?boardid=6)
---- Algorithmen (http://www.informatikerboard.de/board/board.php?boardid=17)
----- Binärer Suchbaum in ArrayList einsortieren (http://www.informatikerboard.de/board/thread.php?threadid=2410)


Geschrieben von infoubi am 01.08.2015 um 15:06:

 

Aha! okay! smile
Also:

public ArrayList<T> createSortedList(BinarySearchTree<T> tree) {
return createSortedList(tree, new ArrayList<T>());
}

private ArrayList<T> createSortedList(BinarySearchTree<T> tree, ArrayList<T> list)
{
if (tree.left != null)
createSortedList(tree.left, list);
list.add(tree.thing);
if (tree.right != null)
createSortedList(tree.right, list);
return list;
}

Und das wärs, oder? =)



Geschrieben von eulerscheZahl am 01.08.2015 um 15:10:

 

Ja.



Geschrieben von infoubi am 01.08.2015 um 15:18:

 

cool, ich danke dir herzlich! smile


Forensoftware: Burning Board, entwickelt von WoltLab GmbH