Professional Documents
Culture Documents
Instantlysharecode,notes,andsnippets.
Signin
Createagistnow
TSiege / TheTechnicalInterviewCheatSheet.md
Lastactive4hoursago
Thisismytechnicalinterviewcheatsheet.Feelfreetoforkitordowhateveryouwantwithit.PLEASEletmeknowifthereareanyerrors
orifanythingcrucialismissing.Iwilladdmorelinkssoon.
TheTechnicalInterviewCheatSheet.md
Raw
StudyingforaTechInterviewSucks,soHere'saCheatSheettoHelp
Thislistismeanttobeabothaquickguideandreferenceforfurtherresearchintothesetopics.It'sbasicallyasummaryofthat
compscicourseyounevertookorforgotabout,sothere'snowayitcancovereverythingindepth.Italsowillbeavailableasa
gistonGithubforeveryonetoeditandaddto.
DataStructureBasics
Array
Definition:
Storesdataelementsbasedonansequential,mostcommonly0based,index.
Basedontuplesfromsettheory.
Theyareoneoftheoldest,mostcommonlyuseddatastructures.
Whatyouneedtoknow:
Optimalforindexingbadatsearching,inserting,anddeleting(exceptattheend).
Lineararrays,oronedimensionalarrays,arethemostbasic.
Arestaticinsize,meaningthattheyaredeclaredwithafixedsize.
Dynamicarraysarelikeonedimensionalarrays,buthavereservedspaceforadditionalelements.
Ifadynamicarrayisfull,itcopiesit'scontentstoalargerarray.
Twodimensionalarrayshavexandyindiceslikeagridornestedarrays.
BigOefficiency:
Indexing:Lineararray:O(1),Dynamicarray:O(1)
Search:Lineararray:O(n),Dynamicarray:O(n)
OptimizedSearch:Lineararray:O(logn),Dynamicarray:O(logn)
Insertion:Lineararray:n/aDynamicarray:O(n)
LinkedList
Definition:
Storesdatawithnodesthatpointtoothernodes.
Nodes,atitsmostbasicithasonedatumandonereference(anothernode).
Alinkedlistchainsnodestogetherbypointingonenode'sreferencetowardsanothernode.
Whatyouneedtoknow:
Designedtooptimizeinsertionanddeletion,slowatindexingandsearching.
Doublylinkedlisthasnodesthatreferencethepreviousnode.
Circularlylinkedlistissimplelinkedlistwhosetail,thelastnode,referencesthehead,thefirstnode.
Stack,commonlyimplementedwithlinkedlistsbutcanbemadefromarraystoo.
Stacksarelastin,firstout(LIFO)datastructures.
Madewithalinkedlistbyhavingtheheadbetheonlyplaceforinsertionandremoval.
Queues,toocanbeimplementedwithalinkedlistoranarray.
Queuesareafirstin,firstout(FIFO)datastructure.
Madewithadoublylinkedlistthatonlyremovesfromheadandaddstotail.
BigOefficiency:
Indexing:LinkedLists:O(n)
Search:LinkedLists:O(n)
OptimizedSearch:LinkedLists:O(n)
Insertion:LinkedLists:O(1)
HashTableorHashMap
Definition:
Storesdatawithkeyvaluepairs.
Hashfunctionsacceptakeyandreturnanoutputuniqueonlytothatspecifickey.
Thisisknownashashing,whichistheconceptthataninputandanoutputhaveaonetoonecorrespondencetomap
information.
Hashfunctionsreturnauniqueaddressinmemoryforthatdata.
Whatyouneedtoknow:
Designedtooptimizesearching,insertion,anddeletion.
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctoutputs.
Allhashfunctionshavethisproblem.
Thisisoftenaccommodatedforbyhavingthehashtablesbeverylarge.
Hashesareimportantforassociativearraysanddatabaseindexing.
BigOefficiency:
Indexing:HashTables:O(1)
Search:HashTables:O(1)
Insertion:HashTables:O(1)
BinaryTree
Definition:
Isatreelikedatastructurewhereeverynodehasatmosttwochildren.
Thereisoneleftandrightchildnode.
Whatyouneedtoknow:
Designedtooptimizesearchingandsorting.
Adegeneratetreeisanunbalancedtree,whichifentirelyonesidedisaessentiallyalinkedlist.
Theyarecomparablysimpletoimplementthanotherdatastructures.
Usedtomakebinarysearchtrees.
Abinarytreethatusescomparablekeystoassignwhichdirectionachildis.
Leftchildhasakeysmallerthanit'sparentnode.
Rightchildhasakeygreaterthanit'sparentnode.
Therecanbenoduplicatenode.
Becauseoftheaboveitismorelikelytobeusedasadatastructurethanabinarytree.
BigOefficiency:
Indexing:BinarySearchTree:O(logn)
Search:BinarySearchTree:O(logn)
Insertion:BinarySearchTree:O(logn)
SearchBasics
BreadthFirstSearch
Definition:
Analgorithmthatsearchesatree(orgraph)bysearchinglevelsofthetreefirst,startingattheroot.
Itfindseverynodeonthesamelevel,mostoftenmovinglefttoright.
Whiledoingthisittracksthechildrennodesofthenodesonthecurrentlevel.
Whenfinishedexaminingalevelitmovestotheleftmostnodeonthenextlevel.
Thebottomrightmostnodeisevaluatedlast(thenodethatisdeepestandisfarthestrightofit'slevel).
Whatyouneedtoknow:
Optimalforsearchingatreethatiswiderthanitisdeep.
Usesaqueuetostoreinformationaboutthetreewhileittraversesatree.
Becauseitusesaqueueitismorememoryintensivethandepthfirstsearch.
Thequeueusesmorememorybecauseitneedstostorespointers
BigOefficiency:
Search:BreadthFirstSearch:O(|E|+|V|)
Eisnumberofedges
Visnumberofvertices
DepthFirstSearch
Definition:
Analgorithmthatsearchesatree(orgraph)bysearchingdepthofthetreefirst,startingattheroot.
Ittraversesleftdownatreeuntilitcannotgofurther.
Onceitreachestheendofabranchittraversesbackuptryingtherightchildofnodesonthatbranch,andifpossibleleft
fromtherightchildren.
Whenfinishedexaminingabranchitmovestothenoderightoftherootthentriestogoleftonallit'schildrenuntilit
reachesthebottom.
Therightmostnodeisevaluatedlast(thenodethatisrightofallit'sancestors).
Whatyouneedtoknow:
Optimalforsearchingatreethatisdeeperthanitiswide.
Usesastacktopushnodesonto.
BecauseastackisLIFOitdoesnotneedtokeeptrackofthenodespointersandisthereforelessmemoryintensive
thanbreadthfirstsearch.
Onceitcannotgofurtherleftitbeginsevaluatingthestack.
BigOefficiency:
Search:DepthFirstSearch:O(|E|+|V|)
Eisnumberofedges
Visnumberofvertices
BreadthFirstSearchVs.DepthFirstSearch
Thesimpleanswertothisquestionisthatitdependsonthesizeandshapeofthetree.
Forwide,shallowtreesuseBreadthFirstSearch
Fordeep,narrowtreesuseDepthFirstSearch
Nuances:
BecauseBFSusesqueuestostoreinformationaboutthenodesanditschildren,itcouldusemorememorythanisavailable
onyourcomputer.(Butyouprobablywon'thavetoworryaboutthis.)
IfusingaDFSonatreethatisverydeepyoumightgounnecessarilydeepinthesearch.Seexkcdformoreinformation.
BreadthFirstSearchtendstobealoopingalgorithm.
DepthFirstSearchtendstobearecursivealgorithm.
EfficientSortingBasics
MergeSort
Definition:
Acomparisonbasedsortingalgorithm
Dividesentiredatasetintogroupsofatmosttwo.
Compareseachnumberoneatatime,movingthesmallestnumbertoleftofthepair.
Onceallpairssorteditthencomparesleftmostelementsofthetwoleftmostpairscreatingasortedgroupoffourwith
thesmallestnumbersontheleftandthelargestonesontheright.
Thisprocessisrepeateduntilthereisonlyoneset.
Whatyouneedtoknow:
Thisisoneofthemostbasicsortingalgorithms.
Knowthatitdividesallthedataintoassmallpossiblesetsthencomparesthem.
BigOefficiency:
BestCaseSort:MergeSort:O(n)
AverageCaseSort:MergeSort:O(nlogn)
WorstCaseSort:MergeSort:O(nlogn)
Quicksort
Definition:
Acomparisonbasedsortingalgorithm
Dividesentiredatasetinhalfbyselectingtheaverageelementandputtingallsmallerelementstotheleftoftheaverage.
Itrepeatsthisprocessontheleftsideuntilitiscomparingonlytwoelementsatwhichpointtheleftsideissorted.
Whentheleftsideisfinishedsortingitperformsthesameoperationontherightside.
Computerarchitecturefavorsthequicksortprocess.
Whatyouneedtoknow:
WhileithasthesameBigOas(orworseinsomecases)manyothersortingalgorithmsitisoftenfasterinpracticethan
manyothersortingalgorithms,suchasmergesort.
Knowthatithalvesthedatasetbytheaveragecontinuouslyuntilalltheinformationissorted.
BigOefficiency:
BestCaseSort:MergeSort:O(n)
AverageCaseSort:MergeSort:O(nlogn)
WorstCaseSort:MergeSort:O(n^2)
BubbleSort
Definition:
Acomparisonbasedsortingalgorithm
Ititerateslefttorightcomparingeverycouplet,movingthesmallerelementtotheleft.
Itrepeatsthisprocessuntilitnolongermovesandelementtotheleft.
Whatyouneedtoknow:
Whileitisverysimpletoimplement,itistheleastefficientofthesethreesortingmethods.
Knowthatitmovesonespacetotherightcomparingtwoelementsatatimeandmovingthesmallerontoleft.
BigOefficiency:
BestCaseSort:MergeSort:O(n)
AverageCaseSort:MergeSort:O(n^2)
WorstCaseSort:MergeSort:O(n^2)
MergeSortVs.Quicksort
Quicksortislikelyfasterinpractice.
MergeSortdividesthesetintothesmallestpossiblegroupsimmediatelythenreconstructstheincrementallyasitsortsthe
groupings.
Quicksortcontinuallydividesthesetbytheaverage,untilthesetisrecursivelysorted.
BasicTypesofAlgorithms
RecursiveAlgorithms
Definition:
Analgorithmthatcallsitselfinitsdefinition.
Recursivecaseaconditionalstatementthatisusedtotriggertherecursion.
Basecaseaconditionalstatementthatisusedtobreaktherecursion.
Whatyouneedtoknow:
Stackleveltoodeepandstackoverflow.
Ifyou'veseeneitherofthesefromarecursivealgorithm,youmessedup.
Itmeansthatyourbasecasewasnevertriggeredbecauseitwasfaultyortheproblemwassomassiveyouranoutof
RAMbeforereachingit.
Knowingwhetherornotyouwillreachabasecaseisintegraltocorrectlyusingrecursion.
OftenusedinDepthFirstSearch
IterativeAlgorithms
Definition:
Analgorithmthatiscalledrepeatedlybutforafinitenumberoftimes,eachtimebeingasingleiteration.
Oftenusedtomoveincrementallythroughadataset.
Whatyouneedtoknow:
Generallyyouwillseeiterationasloops,for,while,anduntilstatements.
Thinkofiterationasmovingoneatatimethroughaset.
Oftenusedtomovethroughanarray.
RecursionVs.Iteration
Thedifferencesbetweenrecursionanditerationcanbeconfusingtodistinguishsincebothcanbeusedtoimplementthe
other.Butknowthat,
Recursionis,usually,moreexpressiveandeasiertoimplement.
Iterationuseslessmemory.
Functionallanguagestendtouserecursion.(i.e.Haskell)
Imperativelanguagestendtouseiteration.(i.e.Ruby)
CheckoutthisStackOverflowpostformoreinfo.
PseudoCodeofMovingThroughanArray(thisiswhyiterationisusedforthis)
Recursion|Iteration
|
recursivemethod(array,n)|iterativemethod(array)
ifarray[n]isnotnil|fornfrom0tosizeofarray
printarray[n]|print(array[n])
recursivemethod(array,n+1)|
else|
exitloop|
GreedyAlgorithm
Definition:
Analgorithmthat,whileexecuting,selectsonlytheinformationthatmeetsacertaincriteria.
Thegeneralfivecomponents,takenfromWikipedia:
Acandidateset,fromwhichasolutioniscreated.
Aselectionfunction,whichchoosesthebestcandidatetobeaddedtothesolution.
Afeasibilityfunction,thatisusedtodetermineifacandidatecanbeusedtocontributetoasolution.
Anobjectivefunction,whichassignsavaluetoasolution,orapartialsolution.
Asolutionfunction,whichwillindicatewhenwehavediscoveredacompletesolution.
Whatyouneedtoknow:
Usedtofindtheoptimalsolutionforagivenproblem.
Generallyusedonsetsofdatawhereonlyasmallproportionoftheinformationevaluatedmeetsthedesiredresult.
OftenagreedyalgorithmcanhelpreducetheBigOofanalgorithm.
PseudoCodeofaGreedyAlgorithmtoFindLargestDifferenceofanyTwoNumbersinanArray.
greedyalgorithm(array)
varlargestdifference=0
varnewdifference=findnextdifference(array[n],array[n+1])
largestdifference=newdifferenceifnewdifferenceis>largestdifference
repeatabovetwostepsuntilalldifferenceshavebeenfound
returnlargestdifference
Thisalgorithmneverneededtocompareallthedifferencestooneanother,savingitanentireiteration.
TSiegecommentedon3May2014
Owner
FormorecheckoutmyblogCoderall
Rucktcommentedon6May2014
Firstlineremoveabeabothaquick.
MergevQuick3rdtheshouldbesomethingelseMergeSortdividesthesetintothesmallestpossiblegroupsimmediatelythen
reconstructstheincrementallyasitsortsthegroupings.
Line185shouldbe"Itrepeatsthisprocessuntilitnolongermovesanelementtotheleft."
Toplugmyownblogifyouwantanexampleofarecursivealgorithm,here'sanexplanationofthebackboneofthesimpleappi'mabout
tosubmithttp://ruckt.info/howtoimplementarecursivealgorithm/
afeldcommentedon20Aug2014
IonlygotthroughSearchBasics,andit'sbeenawhilesincemyDataStructuresandAlgorithmsclass,butsomeclarifications:
Includethatarrayscanbemanydimensionaltorepresentmatrices
Clarifythat"OptimizedSearch"forArraysisbinarysearch
"Doublylinkedlisthasnodesthatalsoreferencethepreviousnode."
InsertionforlinkedlistsisO(n)
Mightwanttopointoutthathashpairsdon'tgenerallyhaveanorder
Youmightwanttointroducetreesbeforebinarytrees
Youshouldintroducetheconceptofworstcaseperformance
BFSisn'tO(|E|+|V|)
Idon'tthinktherecommendationsforBFSvsDFSarecorrect
"youprobablywon'thavetoworryabout[runningoutofmemory]"...exceptinaninterview
rithmscommentedon25Aug
Whataboutworstcasespacecomplexity?
DataStructures:
Array:O(n)
LinkedList:O(n)
HashTable:O(n)
BST:O(n)
Sorting:
Quicksort:O(log(n))
MergeSort:O(n)
BubbleSort:O(1)
randomasciicommentedon25Aug
Ithoughtthisseemedodd.Imeanyes,youcouldcheckforanalreadysortedlistandthendonothing,butthatisaverynarrowspecial
case.Ifyoudothatcheckatalllevelsthenyoumakethewholethingslower,whichseemslikeapoortradeoff.I'ssayit'sjustO(nlogn)
always.
BestCaseSort:MergeSort:O(n)
Thisisanerror.ThisisfromtheQuickSortsection(andBubbleSortsection).Infact,theresultsforallofthesortsaretaggedwith"Merge
Sort".Oops.
WorstCaseSort:MergeSort:O(n^2)
emilystcommentedon25Aug
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctoutputs.
Shouldprobablyread:
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctinputs.
gregorynisbetcommentedon25Aug
Youshouldclarifythedifferencebetweenamortizedconstanttimeandconstanttime,e.g.
Indexing:HashTables:O(1)
Search:HashTables:O(1)
Insertion:HashTables:O(1)
Theclaimaboutthecomplexityofinsertionintoahashtableisnotaccurateifweconsideroneinsertionatatime,inwhichcasetheworst
caseperformanceisO(n)(sinceweoccasionallyneedtoconstructahashtable[somefixedmultiple]timeslargerthanthepreviousone.
ListingO(n)asthetimecomplexityofinsertionwithoutelaboratingisprobablyverymisleadingthough.
ksylvestcommentedon25Aug
Thisisn'tright:
Hashfunctionsacceptakeyandreturnanoutputuniqueonlytothatspecifickey.
Hashfunctionsacceptarbitrarysizeddataandmapittofixedsizedata.Themappingisnotguaranteedtobeunique(andshouldneverbe
assumedtobe).
gregorynisbetcommentedon25Aug
Right,hashfunctionsondataofarbitrarylengthcannotpossiblybeinjective,butonecouldprobablymakeausefulcommentaboutSHA
256havingnoknowncollisionsandwhythat'simportant.
ksylvestcommentedon25Aug
@gregorynisbetYup,itiscorrectthatcryptographichashingfunctionsexistthathavenoknowncollisions.
However,hashfunctionsarealsousedforADTslikehashtablesorbinarysearchtrees.Manyimplementationsuseuseintegerkeys(about
4billionpossibilitieson32bitsystems).Collisionsinthiscaseareextremelylikely(i.e.withahundredthousandobjectsIbelieveacollision
ismorelikelythannot).ImplementationofmanyofthebasicADTsrequireknowing/addressingcollisions.
gregorynisbetcommentedon25Aug
Wehaveaclosedformfortheprobabilityofasuchacollision(assumingdatachosenrandomly).It'sthenumberofinjectivefunctionsfrom
[m]to[n](product(n,n1,...nm+1))dividedbythenumberoffunctionsn^m...Who'sthetargetaudiencehere?(edit:mixedup
variables,countedinjectivefunctionsuptopermutation)
Nudiescommentedon25Aug
Small,butimportanttypoonline61:
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctoutputs.
Ibelievethisshouldbe
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctinputs.
rjartetacommentedon25Aug
CanyoudoanextendeddocumentforOOPBasics,islikeanightmarewhenyoudon'thavethebasicscovered.
Awesomeworkbtw!
bullwinklescousincommentedon25Aug
Thankyou!
TimoFreibergcommentedon25Aug
In
Search:DepthFirstSearch:O(|E|+|V|)
Eisnumberofedges
Visnumberofvertices
IfIremembercorrectly,Eisthesetofedgesand|E|isthesizeofthatset,soyoushouldprobablyputpipesaroundtheEandVinthelast
twolines.
whbboydcommentedon25Aug
Thisismissingoneofthemostimportantdistinctionsbetweenbreadthfirstanddepthfirstsearches:
Breadthfirstsearchisguaranteedtofindashortestpossiblepaththroughagraph.Depthfirstsearchisnot(andusuallydoesnot).
Inthespecificcaseofsearchingatreeforaspecificnode,thereisonlyonepossiblepath,sobothwillreturnthesameresult,butsearch
algorithmsareveryrarelyusedthiswaytypically,theyoperateonarbitrarygraphs.
Additionallyworthknowingisthatmostpracticallyusedsearchingandpathfindingalgorithms(e.g.Dijkstra'salgorithm,A*)are
specializationsofbreadthfirstsearch.
javabuddycommentedon25Aug
Awesomecheatsheet,butnothingbeatspractice,herearesomeStringandArrayrelatedproblemstocheckyourknowledgeandskill
http://goo.gl/a5LqjS
kmh287commentedon25Aug
Inthebulletunderdynamicarrays:
"it'scontents"shouldbechangedto"itscontents"
gmfawcettcommentedon25Aug
"Iterationuseslessmemory"that'snottruewhenthecompilerorinterpretersupportstailcallelimination,orcanotherwiseoptimize
recursivefunctions.Forexample,agoodCcompilerwilltranslatetailrecursivefunctionsintoefficientcodewithnorecursivecalls(only
localjumps).[edit:Iassumeyou'retalkingaboutmemoryonthestackotherwiseI'mnotsurewhatkindofmemoryusageyou'reclaimingis
onlypresentinrecursivefunctions.]
c4milocommentedon25Aug
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctoutputs.
Allhashfunctionshavethisproblem.
Thisisoftenaccommodatedforbyhavingthehashtablesbeverylarge.
Ithinkitisbettertomentionthetechniquestodealwithcollisions:chainingandopenaddressing.
PeterDowdycommentedon25Aug
Forquicksort,Ithink
Dividesentiredatasetinhalfbyselectingtheaverageelementandputtingallsmallerelementstotheleftoftheaverage.
shouldread
Dividesentiredatasetinhalfbyselectingthemedianelementandputtingallsmallerelementstotheleftoftheaverage.
DeterminingtheaverageelementisanO(n)operation,whereasdeterminingthemedianelementisanO(1).
ahausmanncommentedon25Aug
@TSiegeHereareafewcorrections:
1. DFSandBFShavenodefinedorderinwhichtheelementsaresearched.
2. Quicksortpicksarandomelementfromthedatasetasthepivotelement,thensortsallelementssmallerbeforethatandallgreater
thanthepivotafterit.Thenquicksortisexecutedonthepartleftofthepivotandrightofit.
3. Stackoverflowerrorsarethrownifthestackisfull,notwhentheRAMisfull.Thestackusuallyhasaconstantsize(definedbytheOS
and/orlanguage).
@PeterDowdyFordeterminingthemedianelementinO(1)thedatasetmustfirstbesorted
pnathancommentedon25Aug
Youreallydon'twantDFSforinfinitetrees.)
ParoXoNcommentedon26Aug
@TSiege:
Re:Greedyalgos
Usedtofindtheoptimalsolutionforagivenproblem.
Ialwaysthoughtgreedyalgorithmswereusedtofindexpedientanswers,ratherthanoptimalones.E.g.aTravelingSalesmangreedyalgo
justtakesthelocallyminimumavailabledistanceateachcity.It'snotgenerallyoptimal,butit'squickand(often)decent.
Greedyalgorithmsdofindtheoptimalsolutionifthegeneralsolutionistheresultofoptimallysolvingthesubproblems,butmanyproblems
aren'tstructuredthisway.
ballancecommentedon26Aug
Isuggestaddingsomeinfoaboutdatastreams,suchasthefollowing:
###StreamI/O###
Definition:
Astreamisanabstractrepresentationofasequenceofbytes
Itisusuallybufferedtopreventrepresentingtheentiresequenceofbytesinmemoryatonetime
Generallyonewayandforwardonly
Hassignificantadvantagesoverastandardarrayofbytes
Whatyouneedtoknow:
Canbestored:
Inmemory
Transferredoveranetwork
Ondisk
Inadatabase
Advantagesoverbytearrays
Efficientuseofmemory
Smallermemoryfootprint
Uses
Transferringfilesbetweenpersistencelocations
Compression/Decompression
Encryption/Decryption
Throttling
Canbechained
Someareoneway(NetworkStream,CipherStream,etc),otherscanseekineitherdirection
thatbrodcommentedon26Aug
Mergingcanbedonewithanynnumberofsplits,itdoesnotneedatmost2.Thisistruewithmanyoftherestrictionsyou'veplacedon
things,I'dsuggestclarifyingthatthey"tendtohaveatmost2".
PeterDowdycommentedon26Aug
@ahausmansorry,Imeantmedianposition.Ishouldjustsay"middleelement"likeagoodcommunicator:)
sairioncommentedon26Aug
"BigOEfficiency"soundsweirdtome,Ithinkitshouldbeeither"ComputationalComplexity"or"TimeandSpaceComplexity".
KodeSeekercommentedon26Aug
DefinitelyswitchtoTimeComplexityoverBigOComplexity.BigOisgenerallyworsecasetimecomplexity.
Also,worsecasetimecomplexityformergesortisO(n*logn)andnotO(n^2).
PH111Pcommentedon26Aug
YoucouldaddsomestuffaboutDynamicProgramming.Ithinkit'squiteimportantandcooltoknowespeciallyifyoucandemonstrate
someofitsapplications(e.g.theFloydWarshallalgorithm,theDPsolutionfortheKnapsackproblemetc.).
Further,IsuggestthatyoumovethesubsectionGreedyAlgorithmstoanewsection,asgreedyalgorithmscanbecodedeitherasa
recursiveorasaniterativealgorithm(Quiteoftenevenbothispossible).DPwouldfitintothatnewsectionaswell,aswouldthemissing
CompleteSearchandDivideandConquerapproachestosolveaproblem.
Dependingonyourexpectedusecases,somestringalgorithms(e.g.KMP,AhoCorasick,)couldbeaddedaswell,thoughthatmightbe
alittlebittoospecific.
BTW,IterativeDeepeningDFScouldbeaddedassomethingbetweenBFSandDFS.
pilkchcommentedon28Aug
@RucktTherearesimplerrecursiveexamplesthatdon'tdostringmanipulation,suchasfactorials:)
mjgpy3commentedon28Aug
UnderQuicksort'scomputationalcomplexity,theheadersstillsay"MergeSort"(probablyacopy/pasteerrorfromtheMergeSortsection)
joeylmaaloufcommentedon20Oct
Hashcollisionsarewhenahashfunctionreturnsthesameoutputfortwodistinctoutputsinputs.
Signupforfree
tojointhisconversationonGitHub.Alreadyhaveanaccount?Signintocomment