Professional Documents
Culture Documents
14 Numbers Every Developer Should Know
14 Numbers Every Developer Should Know
14numberseverydevelopershouldknow
DespreBlog
CosminNegruseri 26martie2013
123
Like
62
97
Tweet
Ultimeleinsemnari
14numberseverydeveloper shouldknow Interactiveproblemsshortlist CodePandas Combinatoricsshortlist Algoritmiada2013 Infoarenaiaalesnoua conducere HaidetisaimbunatatimInfoarena impreuna! Rollinghash,RabinKarp, palindromes,rsyncandothers Count(distinct)problem Infoarenalovetedinnou!
JeffDean ,afamousGoogleengineer,popularizedalistoflatencynumberseveryoneshould know .Thelistisagreatresourcefordesigninglargescaleinfrastructuresystems. Algorithmsandtheircomplexityoftenoccurincriticalpartsofcomputersystems,butIfindthat fewengineershaveagoodunderstandingofhowaO(n!)algorithmcomparestoaO(n5 )one. Inthecodingcontestworld,competitorsthinkaboutthesetradeoffsallthetime.Nowonder, there'sasetofnumberseveryalgorithmdesignershouldknow. Thetablebelowshowsthelimitsthatcanbereachedinafewsecondsbyalgorithmsofdifferent complexities,nbeingtheinputsize.I'veaddedsomealgorithmsanddatastructureexamplesfor eachcomplexityclass.
Categorii
algoritmiada(7) algoritmica(1) concursuri(11) doilasuta(1) Evenimente(7) facebook(1) Features(2) girlcamp(2) Girls(2) Girlscamp(2) girlsprogrammingcamp(3) google(1) infoarena(6) internships(1) interviu(12) lifetheuniverseandeverything (7) organizare(3) potw(31) preoni2008(3) probleme(9) SelectieGirlsProgramming Camp(1) stiri(76) video(6)
Blogroll
Vivi'sblog WebDiariosdeMotocicleta CatalinFrancu FlorinManea Stevey'sBlogRants JoelonSoftware Developingfordevelopers
datastructures
www.infoarena.ro/blog/numbers-everyone-should-know
1/3
3/28/13
10,000,000
n,nloglog n,nlog*n
1,000,000
nlogn
sorting,divideandconquer,sweepline, Kruskal,Dijkstra
100,000 50,000
2drangetrees twoleveltree
100010,000 n2
300500
n3
3050 2540
meetinthemiddle subsetenumeration,bruteforce,dynamic programmingwithexponentialstates dynamicprogrammingwithexponential states dynamicprogrammingwithexponential states bruteforce,backtracking, next_permutation bruteforce,cartesianproduct
hashtables(forset intersection)
1524
2n
1520
n2 2n
1317
3n
11 8
n! nn
Thesenumbersaren'tveryprecise,theyassumeinmemoryoperationsandsomevaryingconstant factors,buttheydogiveagoodstartingpointinyoursearchforasolutionthatfitsyourproblemand yourdatasize. Let'sgothroughanexample. SupposeyouworkforaGPScompanyandyourprojectistoimprovetheirdirectionsfeature.In schoolyou'velearnedaboutusingDijkstra'salgorithmtofindtheshortestpathbetweentwonodes inagraph.Knowingthesenumbersyouwillunderstandthatitwilltakesecondstoprocessagraph withmillionsofedgesgiventhatDijkstraimplementationshavemlogntimecomplexity(wheremis thenumberofedgesandnthenumberofnodes). Nowyoufaceafewquestions: Howfastdoyouwantyourcodetobe?seconds?hundredsofmilliseconds?
www.infoarena.ro/blog/numbers-everyone-should-know
2/3
3/28/13
Aresponseonthewebfeelsfastifittakeslessthen500milliseconds.Solet'spickhalfasecond. Howbigisthegraph?Doyouwanttosolvetheproblemforacity,acoutryorevenacontinent? Eachisaboutamagnitudelargerthantheotherandwillbesolvedbydifferentapproaches.Let's saywewanttosolvetheproblemforthewholeofEurope. Herearesizesforafewinputsets: input #nodes #directededges #roadcategories Europe 18029721 42199587 13 USA/CAN 18741705 47244849 13 USA(Tiger) 24278285 58213192 4
20042013Asociatiainfoarena
Cuexceptiacazurilorincaresespecificaaltfel,continutulsiteuluiinfoarena estepublicatsublicentaCreativeCommonsAttributionNonCommercial2.5.
www.infoarena.ro/blog/numbers-everyone-should-know
3/3