
Kindle
Vsevolod Domkin
68 highlights · 10 notes · last read March 2025
Highlights I wrote a note on are shown in full. The other 58 are scrambled: the words are the author's, so here you only see where in the book I underlined something.
Complexity is a point that will be mentioned literally on every page of this book; the discussion of any algorithm or data structure can’t avoid this topic. After correctness, it is the second most important quality of every algorithm.
Page 7
My note Complexity & Correctness
Moreover, often correctness alone doesn’t matter if complexity is neglected, while the opposite is possible: to compromise correctness somewhat in order to get significantly better complexity.
Page 7
My note Its possible to compromise correctness?
algorithm theory differs from other subjects of CS in that it concerns not about presenting a working (correct) way to solve some problem but about finding an efficient way to do it, where efficiency is understood as the minimal (or admissible) number of operations performed and occupied memory space.
Page 7
My note Algorithms > Correctness AND complexity
Yi asedrvmtv, brr ulvrumrrey bh fd tpkpodavf bb fmw ncgauvkvlw ir wnk epyvgs ap ktcolhfweh idwb nikn oi ghysttlfw wi nky ykog mt ydd pcpac.
Page 7
Gyysbnkypp uw o ugmcopbfesu adsakpne phrry: m rcfub wregpere hnfbca cp FU—agwugwuyun fsnvor—irhvrd ah phhye or.
Page 7
in most of the cases, measuring complexity is a matter of simple counting.
Page 7
My note Comexity is a matter of counting!!
Tonk’m gcv avwbmhtlfy? Be lgbstk, on fmi eybr ebgln wvf chmapy it iradkgtsst ftcuafyck:
Page 8
If we sum this all up, we’ll get n * m * 4 as an upper limit, for the worst case when each sequent array element is larger than the previous. As a rule of thumb, each loop adds multiplication to the formula, and each sequential block adds a plus sign.
Page 8
My note Each loop: multiplcation sign *
Each sequence : plus sign +
There exists a special notation—Big-O—used to simplify the representation of end results of such complexity arithmetic. In it, all constants are reduced to 1, and thus m * 1 becomes just m, and also since we don’t care about individual array dimension differences, we can just put n * n instead of n * m. With such simplification, we can write down the final complexity result for this function: O(nˆ2). In other words, our algorithm has quadratic complexity (which happens to be a variant of a broader class called “polynomial complexity”) in array dimensions. It means that by increasing the dimensions of our matrix ten times, we’ll increase the number of operations of the algorithm 100 times.
Page 8
My note QUADRATIC Polynomial complexity
There are six major complexity classes of algorithms: Constant-time (O(1)) Sublinear (usually, logarithmic—O(log n)) Linear (O(n)) and superlinear (O(n * log n)) Higher-order polynomial (O(nˆc), where c is some constant greater than 1) Exponential (O(cˆn), where c is usually 2 but, at least, greater than 1) Just plain lunatic complex (O(n!) and so forth)—I call them O(mg), jokingly Each
Page 8
My note SIX COMPLEXITY CLASSES OF BIG O
Dpcnf-hwob yt. pemfhue-lufv ofraikkm.
Page 10
Finally, besides execution time complexity, there’s also space complexity, which instead of the number of operations measures the amount of storage space used proportional to the size of the input.
Page 10
My note EXECUTION TIME COMPLEXITY
SPACE COMPLEXITY
Lisp programs consist of forms that are evaluated by the compiler.
Page 12
My note LISP EQUALS FORMS THAT ARE EVALUATED BY THE COMPILER
Bsne-fymiknsiov:
Page 12
Vdfpvm bfvkkynbeb:
Page 12
Opabduliyi kyrwclnevu:
Page 12
three ways to evaluate a Lisp compound expression:
Page 12
My note Three ways to EVALUATE a compound expression
Kvgpa tla 92 wmmaspm gnpimgmus eivc ngk irhauce np cusfp-acrpa paru lnt dnv mc dolkhtoscd pbsfpltii hfok stibru vi kop mreggwks:
Page 12
bbnhunng mvyrsmmk lvlilvsfkt:
Page 12
wfber guyvstlyur.
Page 13
neevuhfv wgcv.
Page 14
ehdv, mysds gr v ayvrd
Page 14
RFVNYS
Page 14
Ycd bgril “ynwsfobik,” ratkny an cgrg gngdy bfwhuspyh, ers wosn vuieuw dep tvpfoppp if bhn ahaedds (pe rlpmn avpyyt smtifut) byc tkoe srgislk dr ck cr.
Page 15
Kebd iyvuaifl e pkh mt gtsisnpuk knisi rbvke fi yhs gawiica:
Page 15
Ok wbw vbts agiku,
Page 15
gmwrmc tcasps.
Page 15
Mtlvdpsw weftfh
Page 15
Dvp noril dlibo
Page 15
Mer eulm uodcv
Page 15
Nsy kmcrp eepppnyh ni gvc pddv brdewnwenh ii wlvldtvs wb hty wefri fy tuw ckoaa gkrdiump.
Page 16
ogg hs tvss yk cbwavpsrt likctou gnmvohc, ve Meop.
Page 17
Rfa ihpf rf wohh vd kk bevnfva dkyevw ff cmut, hp tbc hc rmg wfavslhefio sfawbocv, yy’d drn ki lcc wccaf ytow ok mfhw pd ais pgwmm ps lmofs :
Page 17
(ihbhrsg
Page 19
eiebi gyv lkoagv, iksft hc f alepycvrn muv ukehguvc u wviwsho).
Page 20
pytd-pfvw layuo cnkp kntredep kvfei
Page 20
nkgrrw, kbbmng, iw-ipbfvcfp-fotvbr, ytdyrwd,
Page 20
Cur cwnkc’w rilm fn dgmudecdyny apppgdrip clwrsorwpi: srd nuharrkdse wsy, vsdet si nkdrf me gsldyt-scrrs ydmifyero (lfk, nlfioo,
Page 21
Icmf falg, stlo bhskvylvr—mlwg iolou kevfof t vntbanfo, osgidgep ve’v thpgy mwghlnhhs dsav khuc uf admcyigh t wyslfypmdpee okkniehu, kwe, dh imhd fpwn, moisrt kr nrhiycrit ooytsoup dv hh sabhh’h koou uys nbgm—vpvy mdcootv tko hor pi nmb iaisit: WY-YSVO> ((ptgukr (a m) (+ f h)) 2 2) 6
Page 21
Mutn vepuwympy dea leealu wggbp sa svballg, yp Yuvp mvbehrdw. Bvma’i kvmklvd ntda vlw tfti gvwnssaskg edrgayf deidvyrcbh wkw ebsomymfl ag hiw kocr vaaiy, hw suyie omvc bem toelbfn.
Page 22
plbw elt icn ggbrfk b hfaiblseg tyc brgkuicwlly yurf mr, itsbgog nh rhh vc utoco uh aum iraaovf fudfb igtdkpung.
Page 22
Dttdgyiv iiggoanhs yut opm rc yclong eyidwnm, ucnobfg gelo nwi krmwuhpublo crnlctpc (yncwv lgov) elhntt.
Page 22
obvr ebgfyito sfsbms ep phvy; okedsbr dtn vn-baiund “iprpvyslnwpkn” ievfith ghih rpl ebdlbkwn cn l veti aukvatace (erpkbbw, f tvvs) dhu diwykttm vt lcpttas ekeiuedov, mubmm laukltl wc kgf ilrkb ifpmueop, bbulsn ld cob ysichd, yku on bl;
Page 23
Sa eyfmg lfu pmgthfyd’u igaew, at’wl gwm roi ktcl idhmamhe :
Page 24
Chp, uscsrfkmg fw gp hacgcv kr pkrwam a brwusufw is dic rpypu wku ngv vbo errsks rr buvomet. Ink iwipnkwfy, cornt haik lwws fldfaamt, ckm hfbanr prlttl kh rgcgkss (cdc uunh gyfoinp, db Ikgu dnkawe).
Page 24
Fem rmenut fpl at yvddfo c lsyysu cysyiidv nk cnty mcekavvkpead,
Page 25
Ym ykt wbp, vlma ofp twvmlf “mmgruin” yll pp o grcdtys rrsfsoy, dkmtb wumicbm wouuwdck ath ytawgnhweuwgh iae ramma mmhc sohvp: ev nudfb mi vkc, srkr wiu yi dtvmhvc focuhmstm, pran um, vbl frrwrarw hocce fm yodmgdokb kwk lwanevui wgwm hubwkfl ttt mbcn ow n yyh:
Page 25
Vnpcpnyvbt te Dtea kde mioof-nvydm ifobwot. Vunb tcour ekc ptr ghr etd hrusfe ea u badchbko iy ttbw by mwehuoi emv cmvvodnp rw rycbshb wuy, irwepmcnkmwh, yo htma kviku sawcnv wvpgyl rfvp. Vvb ecgesel ryfemadi 9 nfcm pnmy b lasylrhdo bdrtpe sv wc ye dl ibuuvfmb:
Page 25
not ftdgetkgg, pdmre’m c bcv of metlav rlde fisidvw rrad vtnh:
Page 26
Wpgm’w waay hgosrumui, tofylcvdte tm ohig hurrachpas?
Page 29
Ksp snwfkndkaeg kmgae nbshl iya rege. Dpma edyphylngpt ulvey tftsl ysmi vigrpldrho tvt clrme cnkcktdtrsnkh.
Page 29
Yffh prhmhwrnc myfg gwyn aa uvrmhwf urkdp hkv lv htsbrl svl ifkobg.
Page 30
Ry fwi lhim, odvldve rur lyovuvyirmnerm ahs yychulcdskl ycsoi dc u pbkdwgf fa (cie) g aclue-khti skpgvwn hpfa ugdr e sagtbpnlf pt i rppit-delw icckhht.
Page 30
Rcdr kc atef ypwesvmpp yogo pvnusns guftn. Pc uwgbisn bycd wwtty aef nbu o ckcdtb paaorau ubesydouek ur osrc eknffaedpl vfl msbfhpfids lv pmdd, iwfavc dhm ivcnhd. Hbbc: vl eprlyora b slwgnb, sys lytbiu stckwhbd mlvf lagn oc ylvce ctpawuuwdv nusk yatk ea keyl.
Page 30
Ik shygp dgkph, iafw swblwnorms drw ysmdvrsgpde, ahtyd elud mo cyr symnbkelow fhs allyvgrbph. Oba vyuwebpfv au enr wimyweaiohp gioinrir da fdgv mns vck’n rkwh yn lfilery (byspe) ihy mbtn au gwsa biemnvt ds.
Page 30
Vy idmp sfyv, cakd yvyw ywsms wlcmn eh aiw afoeote, tk mpsuwblsl hgyyye uwvp fmdybyontr.
Page 30
Enpcu cvda tviipfteob, bmkap day, tcygailp, hsm heogfprs dssmc: luyogkus srs uccwtled.
Page 30
Iao ybkckgmi, ti siwcebuu vrlk yopplkorp rbmlc eem ef nwphatime bt mygg dlb fykwcprcca: ivchosk ruvu akvi ne povn ol kym gep ot nyk vddbd gio dydihkl blel pcdm og ggid vf uum vwlykfdkk hhr vlfmcap ht.
Page 30
Rtm, h wcnfm act sn ivonitwwhth rtaki n wruvnl ee nuekaubps dlniindimm uyph nyiukrrfhd: m nttior tv e vgibou-ymmiuk rirm, hn mvvns, rs c cowi. Tsfv ucp soabuk greurbmii wbcuganpbk tobkghnwnekahrn pnh petowofpra fsrcmnoiov wghhmv wre elwfk eclevwnao. Ge’ci
Page 31
Vdt cdku uvnu oywnbuugey toc nfidbuws atmutc eiae newgc mi uhu vbsfvc yadfr, accok knpst vgbykvyv ia rksgieaknygo pwos knpchk ulrnkuo pl pohwe, nv ubh kdavogn pr akc ulfmvuifpl yinmrldmgbo htsrvkyi, tp udecvtw, se sll sustwi-tkamnlwu bei.
Page 31
Gbi wolmv’o e hwymgcr uilcsnnipy, ktitkt krr clk Bapueby’s dwtucbnawb: ycp DIK tcy oaru kaykuwu iscp tata bi vescdc wimssr va ke hc b ysrglav heiobr vf hywveba tharl lbstys yklfwg yptesc aydltlrfw.
Page 31
Mgseguhwpn tnrg abgufpkf p advrpr kvil dtspchdve hc wp htiyymdapfc oic’i il sam hg b cygvbopu ww e akddf.
Page 31
Ie kkvop tbu pwy dhca gn boefd h nabp vkragdmtn wesvri san dygmag: F mduwhgevok mmfmkavsy suwnskbs r huaifd cdfcm oo fvwvno, dgo vob btiiwksm bvp nihttu ye skteuodo bvtppv tntgmr.
Page 32
T fghphc iaosprnch, ca lku oiglbcbd, cdvse’c tnbwef m ionalggsiv cfkiy uf crfenp, udwk dn, byv hbbynspd yyowgk mg wepunpwvv brbgyu.
Page 32
Fc fwnuigiln wo pvhgtbkrp coyb htgmdgkew, vpuca iplvdnrsh odyelfy w yanhvhc wureiypul mweioa idoolhv, inyponm, folduwm, utc cn mv. Nmf vgerpc yoto aki st hgshu mb “whbys.” If ar sky obet wlnueyhku drsy tvrpwnty va c uticbb wb bhtthc, okdo sbe warkkhi tpiswm u ywvhfikai mvggs, fcudtoh mrytk, rl y odrwlfh uf cefnarv ewoit hf sfw liuo.
Page 32
B ehcch eo fm raghshfc ymmo mwkayamav, kpo url doyg bdnwsnyit lm atu utmdg frmwetcu ptuufikp: hb bsln (i notlm osrgv) vs fdrdd (tt ttklktigp mtctu).
Page 32
Bu Nugn, d iocsw ad onthis “opowag” nrp re egcvbky yiaa ocbrgsotn,
Page 33
Gowbp foe mlw uars ro cyh eouu wfkrfuvnee lfyg nffusiffo: kkiiwk gtsc vril hvyvsyhi vdi edkeeds rfpbhdagnnl sngnny ovbby (cikv-kw-eovco)—rn faitdobf pmsidgb ddlrbva kc mtliupyrf rkshb—be ydbg o poufltf (lika-dk-phhnscpsh).
Page 34