Created
August 12, 2016 15:38
-
-
Save swapnilshrikhande/af07c4e13da053e6022a9f388709b95c to your computer and use it in GitHub Desktop.
Parse Tree
This file contains hidden or 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
class Node{ | |
Id value; | |
List<Node> children; | |
{ | |
children = new List<Node>(); | |
} | |
} | |
parseTree( Map<String,List<Id>> treeMap,String parentId){ | |
List<Id> childrenNode childrenNode = treeMap.get(parentId); | |
Node parenNode = new Node(); | |
parenNode.value = parentId; | |
for(Id childId:childrenNode){ | |
parenNode.children.add( parseTree(treeMap,childId) ); | |
} | |
return parenNode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment