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

assignment 06 dsa

The document outlines a programming assignment involving linked lists in C, detailing functions for managing nodes, including displaying all elements, counting elements, and adding new nodes. It provides a structure definition for a node and includes function prototypes and main function logic. The assignment emphasizes memory management and traversal of linked list elements.

Uploaded by

aspirant.tan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

assignment 06 dsa

The document outlines a programming assignment involving linked lists in C, detailing functions for managing nodes, including displaying all elements, counting elements, and adding new nodes. It provides a structure definition for a node and includes function prototypes and main function logic. The assignment emphasizes memory management and traversal of linked list elements.

Uploaded by

aspirant.tan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Asngnment -06

Degire. nw
dalatupe of a node havirg info ond a
nut pointeh Den tte
Linked tit
joltiaing tunchion"o a angle
a. Afunction that con reolve a mernoy space of
ture NoDE rd returny the bane address of the memory
bpace.
b- prhns all elument ot te inked uot.
C- prmt fnt k elanmto ot te intad nt.
d. prmts odd element, of te inked st.
e. Count the numbeh of elnen o the linkd ot
inesto a reus node ot the firt orhon he
inted it.
tìncucle <Stdio-b
+ includle< tdlib.h
Struet Node
int dataj
Sthrut Node *nent;

int Count e0
Void Doplay AllEleroens (Shut Node h)
while ( hl: NULU)
frot (.d Inyhdata );
h=hnetj

*void Duday- k- Elemens (struct NDde *hjnt k)


int is0;
to (iro, ick; i+)

prmts ("din", h data);


hehneat;
break ;

r vod Diplay Odd (struct Node *h)


int i-0)
while (h NULL)
i} (h-sdak f.2)
priti .d th" hisdata),
h-hnet;

J void Gmunter( Shrut Node h)

while (h] : NUL)


Count +ti
h=hnet;
prnts(otal no.of elementQ in th Solil tdn)Court),

Shruet ode * Inuehttatfnt( shutt Node #h,irt k)


strutt Node *empi
ternp : (tnut Node *) malloc ( hzok (stnut Node)
Femp ’ doa =kj
tunp ’ mest =hj
hettmpi

int main ()

Jrutt Node pq1


p-dola :2;
q data 3;
y.data 90;
strutt Nodr * hnd.
hnd p
prete
q.nat ;
Tntt NUL;
Iriaplay AliGlumcnts (hed D;
Vpents ("Basx addenm= "had),
/int S= !;
vpaplag-k Elurrerta (huad,s);
Ioàlayosa(head);

head =Inwtgt fint (head,j);


Dioplay Al Elmers (head);
rehun 0;

You might also like