Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
56 views
Algorithms and Data Structures.
Uploaded by
ชัชพงค์ ดีเพ็ชร์
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Algorithms and Data Structures. For Later
Download
Save
Save Algorithms and Data Structures. For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
56 views
Algorithms and Data Structures.
Uploaded by
ชัชพงค์ ดีเพ็ชร์
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Algorithms and Data Structures. For Later
Carousel Previous
Carousel Next
Save
Save Algorithms and Data Structures. For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
“How much time it takes to vun a function as , : Abate : Raine, PIA Ep “ number of elements Const avvayl = [OBB &, Pl n=5 | (eh count=0 | fowler i205 haystack.lengen j ite )2 ' , FChaystack Lil = needle) Count += 1; | 4 Yetuyn Count 5 CL How tong does i+ take to execute when o> +he number of elements (in) 15° ¥ axeustion t L% woe» this is time ayows _ linearly, as OVVOU, SIZE incveases + (sw ut aul) M\- : Let's see if we have Some Function Hat doesnt 25 or Array size (nt Ww, has noeffect t ? : ‘4 1 ‘ ow) ola) w> onthe runtime time, inns 1 5 10 20 223 Constant time u ow), a . . . 1 $ Quadvacric time = OUD pes nowever oe ne rane Const ronal arco, r= £4, &, Gs, P71; Ene w Const hasPuplicates = Covy) > t a re for (ler t=03 T< avv.length 5 V+) [00k ! leh item = aw L113; nen iE (avy. Slice (Yet). indexOF (item) t= -1) vertu ; ‘ , weruwn tvue; RD prover \ > 5 vetuyn false ; owe \ork uP 1 aata Hructuses Array & Linked List Array a linear data structuve, Stoved in Contiguous iar memory memovyy locations. Addvess 300 oso 208 fray CO] [1] C2] [3] " Assume each & is an integer) = = Vequires 4 bytes space | “y v The array of & must be A, allocated Contiguoursly Sor" > addvess 200 — IIb ve. BP ya4l yw can fandomly, Acless wi inde¥ atz] — Vv Contiguous = No extra werory allocated = no memory overflow! OA a 228 poe CF meh! - ° Fixedsize.. Lavge space oy not be avat| fov dig Aas = BD took the space! § @ Insert + delure elements | Ove Costly . > may nLLA tO create 0 NEN | Copy of the OVO + allocate ak anew advess LL NS |Array & Uakked Lise 2 & |ineov data Structwe. > & each element is 0 Sepavared object elements ave linked wy pointers aE memory Pointer fs Cradvess of the ee next node ) oes" 420 — a ios B — _addvess 748 Unlike On orvey, Linkedlist A , elements ave not Stoved in Contiguous locations . | és. You pe CF meh! foo acy ae Cipriani cia. @ No vandom access =s12e Can Growey ShYINK | Wremov v Insert + delete element | Need to-tvaverse ave Flexible . wn kimes \ oa = no need to shift nodes like avvay insertion V memory, is allocated ==»: & Revewse dvavevse or Yantime 1s hava 410 7 time Complexity iS O(n). aVaY, iS Ou) |° & @uat> A Stack is & LIFO (Last- in-Fivst-out) 9 data Structure, where an eluent /P* fe added \as+ push) gets 722) Yemoved Fiver cper) 2 it tw Just like a Stack oF ice cream scoope ! ia omg, the bottom eve Stack AS Gh GYVO4, in Las| = 7 one isalways _ OYVAYS in SaaSeniPr muting ! \ | bet Stack = C1; a ave dayne ack (st : i stack. push (‘mint choc’); 7 Dmnt choc’ 1 1 1 stack. push (' vanilla’); YW eimint choc’, ‘yani\loT! Stack push('stawberry')) / [mint choc, ‘vanilla’, | | let eaten = stack. popl)) % eaten is ‘strawberry me 4y is OC") paar ! v iow oe Tach. me U wink choc‘, ‘vanitlel)Sick: & ®) © Qu2ue is a FIFO (Rirst-in-Fivst-out) dota Structuve, where an element added Fivst (= enqueue) Bers vemoved first (= dequeue ) dadquore “[_} just like waiting in \ine ot a popular vestauvant t Nyan — ynavu Business Cox Grumpy cor wi, mss) “oe ron 2 Stack OS ah GYYAY, in a. eS" C eee ' ‘et queue=L 1; quow. is! oe i we «x | queue. push (! Simba')i Csinnba’3 ae 1 | Queues, push ( Nyan'); 7 L'simba’, “nyo \ Queue, push(‘mava')) 7% [ ‘Simba’: Nyan', ‘Wmaruy! et €orev= Queue. shift (), 7 eater is “simmbo iv Time Comploxity, queueis Linyan ‘, ‘maru' 3 Should be OL) fov both enqueue + dequeue but JS shift{) is slower!3 A hashtoble is used to index large Amount of dota 2¥ QUICK Key-valus lookup. OCI) on average Ly Faster tn bvute-fovee linear Seaych my © Let's CYeake Gn oO Colculare the hash Ovvay of size. | ee by Using the We've Q0inG tog | Yh. Talon", add Gdota. 3 jp 2.9, ASCII Code, Mp5, Sak Kel = “Tabby” puke values*pizzas —|t = 6 > ) - 530 a hy Supe soi une ; emer Has! @ Lets add move data, GD el > 353%5 =3- Tux oy, @f#] - 301% 522 Bob @ Use moduto to pick a position in thetaviaty Cb 2 8H > 530%3- 0 ‘ 71 \ >| Toby divided by ne Bob Size oF the orray, . The vemainder is the Position!Colliston! -@ Hash Table Now we wantto add move daca. Let's add “Bengal ". 6 Ch “vergal"> OE] 617%5=2 | But Lal slot hes been taken >” BS by “Bob already! =collisiont 3 |S so let's Chain Bengal next 4 to Bob! = Chaining key: Bengal’ — “Sphinx” keep Values" posa® “Fishe Baatng Chips dato . Let's \poKup the value Foy Bob" | ® Get the hash > 307 — 0M \ | 1 | @Gex the index Z01% 5-2, | | @Lookup AVMALIT > foundt 22 | FE Let's love up “munchkin” eS vos | | © Hosh > gol ae 4 | © Index > BbI% b= 1 ran ce | @ preg td - = "Manx" | \ \@ aire -mac Dia duwes Binary Weapy & ir vee < Binoy, Seoveh tree ate hob seer. Binoy, henp = '& e0ch node Mas ot w Compre tree ~ . most 2. childven * Min NeMp oy "OX x haoe 2 % used for Priority, AuLUr “ty Maxheap hoop sort eke wt 0G) the Voor in qvvay 1@ Dye nas the YO lager — [olelelell 304 Cin mtg ) Coy Cia (24 031 041 v each node has 0-2 childven pe v always Fill top bottom, ler ight Low brim 1 Addtothe next node
Golelaes EEL:@ ~ é & tree jain shuchure. CinanpSeavewiiver: ‘ka. Ovdeved ov Sovted & €0Ch node has ot w aKa. Ove mos} 2. Childven binary vee : v Fast lookup de Rule of thumb e4. phone number lookup table myname A * €achvalue of all nodes wn he \eft subtvees is lessev A's lef subtrees : 8,3, 4.7 a . 3,7 Smollev-than povent * Coach value of all nodes in the iN @ Sorted ayvaYy,: Vigint subtyees 1s lavqer SUeahonpps| * No duplicate Values “<7 Inserkion > Alwoys add to the lowes+ spor 4obe ateaf 2 No veowornge! Q Let's add@ 1. Compave WI the voor Fist. 2.@®<@® so go lett. 3. Hnen compave w/ the next, © 4 @<@ 5090 left Gomplexity: 5 Compave wi the © Ave. OClogr) b @® >® So go night Worst. On) 7. Compave / the@ ; § @<@. soodd to the left . Done,
You might also like
DSA Hand Written Notes
PDF
100% (5)
DSA Hand Written Notes
32 pages
Big O And DSA Sketch Notes
PDF
No ratings yet
Big O And DSA Sketch Notes
12 pages
Bi Goal Go For Noobs
PDF
No ratings yet
Bi Goal Go For Noobs
12 pages
Maha Revision DSA Gate Wallah
PDF
No ratings yet
Maha Revision DSA Gate Wallah
71 pages
Dsa Short Notes
PDF
No ratings yet
Dsa Short Notes
37 pages
Elementary Algorithms PDF
PDF
No ratings yet
Elementary Algorithms PDF
642 pages
DSA NOTES
PDF
No ratings yet
DSA NOTES
510 pages
Elementary Algorithms
PDF
100% (1)
Elementary Algorithms
622 pages
Elementary Algorithms
PDF
No ratings yet
Elementary Algorithms
622 pages
Algo Quicksheet
PDF
No ratings yet
Algo Quicksheet
70 pages
Elementary Algorithms
PDF
100% (4)
Elementary Algorithms
630 pages
AlgoXY Elementary Algorithms
PDF
No ratings yet
AlgoXY Elementary Algorithms
749 pages
Elementary Algorithms
PDF
100% (1)
Elementary Algorithms
618 pages
AlgDs1LectureNotes-2025-02-16
PDF
No ratings yet
AlgDs1LectureNotes-2025-02-16
89 pages
DS QB Unit III Answer
PDF
No ratings yet
DS QB Unit III Answer
16 pages
Dsa Basic
PDF
No ratings yet
Dsa Basic
23 pages
Important questions of dsa
PDF
No ratings yet
Important questions of dsa
12 pages
TO PRINT - DSA DOTNET SLACKERS
PDF
No ratings yet
TO PRINT - DSA DOTNET SLACKERS
56 pages
Data Sructures and Algorithms
PDF
No ratings yet
Data Sructures and Algorithms
112 pages
DSA
PDF
No ratings yet
DSA
40 pages
Dsa Notes
PDF
No ratings yet
Dsa Notes
79 pages
Data Structures and Algorithms
PDF
100% (1)
Data Structures and Algorithms
111 pages
Course Notes-Algorithms
PDF
No ratings yet
Course Notes-Algorithms
22 pages
DSA Solved Paper (May - June 2023) PDF
PDF
No ratings yet
DSA Solved Paper (May - June 2023) PDF
27 pages
DS L1+L2
PDF
No ratings yet
DS L1+L2
19 pages
Dsfs Record
PDF
No ratings yet
Dsfs Record
114 pages
The Computer Science Handbook
PDF
100% (2)
The Computer Science Handbook
271 pages
Data Structures PYQ (1)
PDF
No ratings yet
Data Structures PYQ (1)
26 pages
Data Structures
PDF
No ratings yet
Data Structures
104 pages
Ada Practical file 1-6 exp IPU
PDF
No ratings yet
Ada Practical file 1-6 exp IPU
15 pages
DSA BCA Final PRO
PDF
No ratings yet
DSA BCA Final PRO
205 pages
DS Module 1_240914_110228
PDF
No ratings yet
DS Module 1_240914_110228
6 pages
Data Structures
PDF
No ratings yet
Data Structures
104 pages
Data Structures C1
PDF
No ratings yet
Data Structures C1
11 pages
Alg Ds 1 Lecture Notes
PDF
No ratings yet
Alg Ds 1 Lecture Notes
86 pages
DS Notes
PDF
No ratings yet
DS Notes
40 pages
Data Structure Notes Part1 Csegyan 01
PDF
No ratings yet
Data Structure Notes Part1 Csegyan 01
25 pages
JNTU BTECH 2-1 Data Structures NOTES
PDF
No ratings yet
JNTU BTECH 2-1 Data Structures NOTES
104 pages
Data Structures
PDF
No ratings yet
Data Structures
104 pages
Avl-2 0 1
PDF
No ratings yet
Avl-2 0 1
432 pages
Data Structures Lecture Notes
PDF
No ratings yet
Data Structures Lecture Notes
143 pages
Data Structures 1
PDF
No ratings yet
Data Structures 1
30 pages
Data Structures in C Using The Standard
PDF
100% (2)
Data Structures in C Using The Standard
13 pages
DSA RG 3rd sem (1)
PDF
No ratings yet
DSA RG 3rd sem (1)
71 pages
Dsa - Barnette and Tonga - 2
PDF
No ratings yet
Dsa - Barnette and Tonga - 2
3 pages
Hilfinger Data Structures
PDF
No ratings yet
Hilfinger Data Structures
253 pages
Algorithms and Data Structures
PDF
No ratings yet
Algorithms and Data Structures
42 pages
Java Algorithms Interview Challenger
PDF
No ratings yet
Java Algorithms Interview Challenger
194 pages
Technical Interview Study Guide
PDF
No ratings yet
Technical Interview Study Guide
18 pages
Organ: Relatronhip
PDF
No ratings yet
Organ: Relatronhip
38 pages
Data Structure Notes Part1 Csegyan
PDF
No ratings yet
Data Structure Notes Part1 Csegyan
25 pages
Array
PDF
No ratings yet
Array
8 pages
DBMS Assignment 2
PDF
No ratings yet
DBMS Assignment 2
7 pages
??? ?????
PDF
No ratings yet
??? ?????
32 pages