summaryrefslogtreecommitdiff
path: root/notes.md
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-11-07 11:51:17 -0700
committermo khan <mo@mokhan.ca>2021-11-07 11:51:17 -0700
commit2da8325707b269972d40462a24db4442189119ed (patch)
tree67a7c48e7f512b34bdc605498e1035ec54096298 /notes.md
parentb0c963d43359849537b5550e1fa18e8eda15842c (diff)
add table for class of functions
Diffstat (limited to 'notes.md')
-rw-r--r--notes.md56
1 files changed, 56 insertions, 0 deletions
diff --git a/notes.md b/notes.md
index 92da79b..74b0fbb 100644
--- a/notes.md
+++ b/notes.md
@@ -905,6 +905,22 @@ We need a simple method for representing time complexity.
Theta is useful.
+class of functions
+
+| name | symbol | speed |
+| ------------- | --------- | ----- |
+| constant | 𝚯(1) | fast |
+| logarithmic | 𝚯(log n) | | |
+| | 𝚯(sqrt n) | | |
+| linear | 𝚯(n) | | |
+| | 𝚯(n logn) | | |
+| polynomial | 𝚯(n^2) | | |
+| | 𝚯(n^3) | | |
+| exponential | 𝚯(2^n) | | |
+| | 𝚯(3^n) | | |
+| factorial | 𝚯(n!) | V |
+| | 𝚯(n^n) | slow |
+
1 < logn < sqrt(n) < n < nlogn < n^2 < n^3 ... < 2^n < 3^n ... < n^n
Big-oh
@@ -1300,6 +1316,46 @@ n^3
0 ┼────────────────────────────────────────────────────────────────────╯
```
+factorial
+=========
+
+```bash
+モ ruby -e '1.upto(100) { |n| puts (1..n).reduce(:*) || 1 }' | asciigraph -h 32 -w 72
+ 93326215443944150965646704795953882578400970373184098831012889540582227238570431295066113089288327277825849664006524270554535976289719382852181865895959724032 ┼ ╭
+ 90409771211320894723678960937099742018530417689077610513736049894308587881917371125019252709659385351025577475535631344215463015406338066470094307934227922944 ┤ │
+ 87493326978697638481711217078245601458659865004971122196459210248034948525264310954972392330030443424225305287064738417876390054522956750088006749972496121856 ┤ │
+ 84576882746074382239743473219391460898789312320864633879182370601761309168611250784925531950401501497425033098593845491537317093639575433705919192010764320768 ┤ │
+ 81660438513451125997775729360537320338918759636758145561905530955487669811958190614878671570772559570624760910122952565198244132756194117323831634049032519680 ┤ │
+ 78743994280827881950138260173527833613412385832207539075090186094257588498887003981440165955853071238770203813417571981933120864867433486285399073307165196288 ┤ │
+ 75827550048204625708170516314673693053541833148101050757813346447983949142233943811393305576224129311969931624946679055594047903984052169903311515345433395200 ┤ │
+ 72911105815581369466202772455819552493671280463994562440536506801710309785580883641346445196595187385169659436475786129254974943100670853521223957383701594112 ┤ │
+ 69994661582958113224235028596965411933800727779888074123259667155436670428927823471299584816966245458369387248004893202915901982217289537139136399421969793024 ┤ │
+ 67078217350334856982267284738111271373930175095781585805982827509163031072274763301252724437337303531569115059534000276576829021333908220757048841460237991936 ┤ │
+ 64161773117711600740299540879257130814059622411675097488705987862889391715621703131205864057708361604768842871063107350237756060450526904374961283498506190848 ┤ │
+ 61245328885088344498331797020402990254189069727568609171429148216615752358968642961159003678079419677968570682592214423898683099567145587992873725536774389760 ┤ │
+ 58328884652465100450694327833393503528682695923018002684613803355385671045897456327720498063159931346114013585886833840633559831678384956954441164794907066368 ┤ │
+ 55412440419841832014396309302694709134447964359355632536875468924068473645662522621065282918821535824368026305650428571220537177800382955228698609613310787584 ┤ │
+ 52495996187218587966758840115685222408941590554805026050060124062838392332591335987626777303902047492513469208945047987955413909911622324190266048871443464192 ┤ │
+ 49579551954595331724791096256831081849071037870698537732783284416564752975938275817579916924273105565713197020474155061616340949028241007808178490909711663104 ┤ │
+ 46663107721972075482823352397976941289200485186592049415506444770291113619285215647533056544644163638912924832003262135277267988144859691426090932947979862016 ┤ │
+ 43746663489348819240855608539122800729329932502485561098229605124017474262632155477486196165015221712112652643532369208938195027261478375044003374986248060928 ┤ │
+ 40830219256725562998887864680268660169459379818379072780952765477743834905979095307439335785386279785312380455061476282599122066378097058661915817024516259840 ┤ │
+ 37913775024102306756920120821414519609588827134272584463675925831470195549326035137392475405757337858512108266590583356260049105494715742279828259062784458752 ┤ │
+ 34997330791479050514952376962560379049718274450166096146399086185196556192672974967345615026128395931711836078119690429920976144611334425897740701101052657664 ┤ │
+ 32080886558855806467314907775550892324211900645615489659583741323966474879601788333907109411208907599857278981414309846655852876722573794859308140359185334272 ┤ │
+ 29164442326232550225347163916696751764341347961509001342306901677692835522948728163860249031579965673057006792943416920316779915839192478477220582397453533184 ┤ │
+ 26247998093609293983379420057842611204470795277402513025030062031419196166295667993813388651951023746256734604472523993977706954955811162095133024435721732096 ┤ │
+ 23331553860986037741411676198988470644600242593296024707753222385145556809642607823766528272322081819456462416001631067638633994072429845713045466473989931008 ┤ │
+ 20415109628362781499443932340134330084729689909189536390476382738871917452989547653719667892693139892656190227530738141299561033189048529330957908512258129920 ┤ │
+ 17498665395739525257476188481280189524859137225083048073199543092598278096336487483672807513064197965855918039059845214960488072305667212948870350550526328832 ┤ │
+ 14582221163116269015508444622426048964988584540976559755922703446324638739683427313625947133435256039055645850588952288621415111422285896566782792588794527744 ┤ │
+ 11665776930493024967870975435416562239482210736425953269107358585094557426612240680187441518515767707201088753883571705356291843533525265528350231846927204352 ┤ │
+ 8749332697869768725903231576562421679611658052319464951830518938820918069959180510140581138886825780400816565412678779017218882650143949146262673885195403264 ┤ │
+ 5832888465246512483935487717708281119741105368212976634553679292547278713306120340093720759257883853600544376941785852678145921766762632764175115923463602176 ┤ │
+ 2916444232623256241967743858854140559870552684106488317276839646273639356653060170046860379628941926800272188470892926339072960883381316382087557961731801088 ┤ │
+ 0 ┼──────────────────────────────────────────────────────────────────────╯
+```
+
n^n
===