Domanda di colloquio di Amazon

None.

Risposta di colloquio

Anonimo

10 dic 2012

/* * Convert tree to a linked list using zig zag or level order traversal */ /* * assume there is a linkedlist implentation in place */ function convertTreeToLinkedList(root) { /* * if this check is not here we will get duplicates */ if (root.parent == null) linkedList.add(root); foreach(root.children as child) { linkedList.add(child); convertTreeToLinkedList(child); } return; }