We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For those wanted to do C#, they don't have the stub code, so I wrote it.
usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;publicclassNode{publicintValue;publicNodeLeft;publicNodeRight;publicNode(intvalue){Value=value;}publicvoidInsert(inti){// Write your insert code here}publicList<int>GetTreeOrder(List<int>list=null){// Write your order code here}}classSolution{staticvoidMain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */varcount=Convert.ToInt32(Console.ReadLine());varintArray=Console.ReadLine().Split(" ").Select(i=>Convert.ToInt32(i)).ToArray();varrootNode=newNode(intArray[0]);for(inti=1;i<intArray.Length;i++){rootNode.Insert(intArray[i]);}varinOrder=rootNode.GetTreeOrder();Console.WriteLine(string.Join(" ",inOrder));}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Insertion
You are viewing a single comment's thread. Return to all comments →
For those wanted to do C#, they don't have the stub code, so I wrote it.