160x
Filetype PDF
File size 0.07 MB
Source: courses.csail.mit.edu
File: Hacking A Google Interview Practice Questions Person B
hackingagoogleinterviewpracticequestions personb question binarysearchtreevalidity writeafunctiontodeterminewhetheragivenbinarytreeofdistinctintegersisa validbinarysearchtree assumethateachnodecontainsapointertoitsleftchild a pointertoitsrightchild andaninteger butnotapointertoitsparent youmayuse anylanguageyoulike goodanswer notethatit snotenoughtowritearecursivefunctionthatjustchecks iftheleftandrightnodesofeachnodearelessthanandgreaterthanthecurrent node andcallsthatrecursively youneedtomakesurethatallthenodesofthe subtreestartingatyourcurrentnodearewithinthevalidrangeofvaluesallowedby thecurrentnode sancestors thereforeyoucansolvethisrecursivelybywritinga helperfunctionthatacceptsacurrentnode thesmallestallowedvalue andthe largestallowedvalueforthatsubtree anexampleofthisisthefollowing injava ...
Filetype PDF | Posted on 05 Feb 2023 | 2 years ago