0% found this document useful (0 votes)
3 views

linked_list_notes

A void pointer is a type of pointer that does not have an associated data type, allowing it to point to any data type after typecasting. A null pointer is a pointer that does not point to any memory location, representing an invalid memory address. The document also discusses linked lists, including singly and doubly linked lists, and their structures and operations.

Uploaded by

ak2711474
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
0% found this document useful (0 votes)
3 views

linked_list_notes

A void pointer is a type of pointer that does not have an associated data type, allowing it to point to any data type after typecasting. A null pointer is a pointer that does not point to any memory location, representing an invalid memory address. The document also discusses linked lists, including singly and doubly linked lists, and their structures and operations.

Uploaded by

ak2711474
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
You are on page 1/ 10
What is a Veid Pointer? Void pointer’ 1s & pointer whidh has no associated data mate with it, Ta Con pent do any data +p) and Som lobe +ypecasted to ong +ype- Int mom 0) g nt N=10 Void * Pry = bn;5 Print £ (Ad, * Cont *) PEYVS I dypecosted Yeturn oO; ee 1 vs out put + lo J H/ we Camn'+ dewteyence a Void pointer Primt£ Cad, * pty) 5 ou Use of Void Poirier Ynallec ond Giloc Ainction vetuen a Void pointer ds Aris yeason, they Com atocate a memong of What iS NoLt Pointer ? & NOLL poimter is a pointer that ches not point memory location. I+ represents On ‘mYalid meme then a NUL Value is assigned 4a Reine iS Considey @S a NULL pointer. imt main bd 0 imt * pty = NULL; yedurn 0} y clout NOLL Pointer Lt is O. WE Com Cithey Use Wo or O wowite fonte*t of porters ang is de the, bndegey © Fou equivalens upon the Plabtoer the normal Pointer Null Uneck before wep rises int * pay 2é of (int D5 Bree ( Pers ye 0; Hi\\ Pointing dp the deal Bud he poimter is ne mony fir = Nou ow, Pt js no mere demgl Wihak iS a Wild poimder? Wid Pontes or alse Known os GH Ahese Pomters usually st imt rein How 4> avoid Wild Porter 7 -imitialize them with the address oF @ Known Voroble -ExplidHy qlotate He memory ond pur the Values im the allocated ‘memory int +P = Une) aaltoc ( sizeoe Cnt) 35 PTs dre CP); Static Memow Allocation emery aWoceded daring Compile dime 18 Salled Stodic ™emorg The wremoxs is fixed ond Cammet be meseased ox decrcostd Goring yen dime: Protem fated in Slotic remery allocation? Té Yoo ove allocating menory for an avay dusing Compile dime then you hove to fix the Size ad ted time OF declovation « Size is Lied and USty Comnot fnesease oy decrease ne Sze of the aray at yun time TE the Value Stored by the User im the avray ab wUn Aime is leso Hon the Size Specified then there will be woastage ef wemory- TP the Valve is move then the Size shed fied ot vim time Anen the (aogrm may Crash a Mis behave- Dynamic Memory A\\vcavion - The process of bee " Heap is the aWscation, Unlike: uct bent rp) { Void print (S ‘ od Voll) Pe ee al print £ (Y/od y im main OL Shu pint * pe) , perl = dun ( ai3)> piva= Bw (6) 95 : paint ( piv), prt & ytya)> bre (pris due Cp D5 Yedver 05 ) Lassing ayray of Shueture Os argument ¥ pryas dE tilode < Stdioh> Shut psint ¢ imt x5 ‘ m+ Yy 5 ; Noid Print CU Sruct pomt awl] 2 imt is, for (iso, (e2, (ead bvint# CS Yad “fed \W!, or Ci1.X, arvEid: 4 {md main 0 § Shuck pint orrtad = {41 Nive = 2h, {3M Pyint Caw, tual ws relvrm 0; SVUCe Spy int P35 Shuct Self * Per; hy Ex S Stuck cde { imt 05 Char C5 y UE ETL imt main L) £ Sewuct Code Vor! 5 Stwct (ede Novds Nox\. i265 5 Conece fh; Nar) Ptr = ULC; Noy d-i= 665 Vaya. c2 85 Nava. five NYU; sonar Valle eS Varas 44 Moxa \hidh wetons oo arcess Maya — oe 2 w]e [ial is Linked List? @ Sequence of data Shucture , Whidh are linccs Each Limks ‘ontnins a What f Linked List ‘+ crmected togtther Vie dress 4e wrother limk- Types of bined List 9 Simgly Linked List + Navigation is fouwoid on\y Doubly Linked List 3 forward & back woyd Navigation is fossible Civtlox Linked List 2 dast clement {5 Limked do the first Clement Whar is a Single Linked List 7 A Sima Ki Single. Limked St js a list mode Ub of ‘nodes Consists of due parts Data + Link Node OATA lInNk 2 Contims the cctval data Contains the add ess) ext node e€ the list Representation of Simgle Linked die Svppose we want do Stove a list of chat 23,6 ao nede of & Simple Linked “ist werreal Snuctur i node cod Nead = (Shuck nece * us head — cata = head — Link = NULLS Primtt (Yed", head — dota; yeturm 0; b Corning a Simghe. Linked List P20q 0m bes ocean Ble ‘gee TRERIE RS mode. les 206s int main & Mert = head -> links head > limk = revs Bev = Knead; ho ial jw head=2 NULL head = next y // Yt oe adi, toes Suu Node* xeverse (Sint node *heod) ( Sauct node* Prey = Null; Shuck node *nent = NUULZ While [head $= NULL) J mert = head DlimIG head > lak= Prev; rev = heods head = next 3 5 neod = Prev > return head 5 5 Lanoduction 42 Ooub\y Ymised List .. 4 douby Linked Vist is different Gem a singly tml ted [poimts do the previous mode , gether wit |next printer ond data Slerilay do Sngly Vie ( Shuct mede* head) § wode* Yeverse = head} * Pert Struck node * Pt fora = tl Prexts yraur nede* Piri > next = NvLLG fir1 > Prev - Pra; white ( fra t= noted < Piva > Prev = Pr > next; Per? > next = Pirls fer \ = Ptr ya= Pras Prey 5 Why Govbly linked list 7 & faster in ouby linked Reason 41% Ocleton operation list , tt the pointer do the wode is given. Reasor, tha + Inserting & wo Mede. bef yee give iS Casier in doubly linked Ise 7 Ts ts Otay Aad tohensyeg i+ is he Previous wede fren he traversing whe lst | o cae Mandy. Coeating o node of Civuiley Lnced lst imly List$ Soc node Grutor Simdy Cimt data) Struct hode® temp > mabloe( sizeok OS*ur rede }); temp —) deta = data 5 temp —> next = temp; Yedurm ttmp; \ Civeadex Gst> Seok Wede* Cvudor Dosbly Cint data) ¢ gheuck mode temp = rradloc (sizeo€ ( siucr rated temp -7 dota = dota’ Aemp — next = temPi temp > tren = terns yerurn temps \y tee TImsevton at the Begrning Singy List S we owe Keeping o zal pointer instead of Weod pointer tm Grudar linked Vist notes fail princes is the pointes do the last nede wary to 7 _tek Soy we have © heed Po node of 4

You might also like