You are on page 1of 11

Proqant -5

Cisculas Linkec tst aboot the înfosmaton


of a Student
# incwde <stdßo.h
+ incode <6tdßb.h
inctude <stiq.h
Stouct Student E
chax name [50]*
int so numbes 3
Stact student *hext 3

Stooct Student* CTete Studert (chas havneCJ,iut %ollnumber E


Stct Stude nt * heuo Stodent =(stsuct Stude ntt)malloclsizeof (stuct Gtdet):
Stscpy nesstudent hame,hame):
hewstudentoLnumbeS= Tolhumbes i
heu Studetnext NuLL3
etun Neo Studenti

Void inert Foont (struct Stodent **head,chas name [1, int Tolnombe)f
Stoct Student* newStudent =Coeccte Stodent(name,olLnumbes):
if ( head== NUL)
*head= neo Studerti
Chead) hext*headi
3
else E
hepGtvdert next= head)next
(*head)’ hext = hewStudeht s
* head = nestudenti
Void delete [tudent lstsoct Student *
head, iut rolnomber )$
hed== NuL)

Tetun
Stuct Stodent *temp ( head)nert:
Stouct Student psov = *headi
wleltonp!= *hend)é
iftempo nomben olLnUmbes)f
PeNet temp’nexti
If tenp= *head)
* head =poev s

free(tonp)
Tetuoni

temp temp hexts


iftenpdolnombeg =0lLnomber)$
Prelnext= temp- hext i
if Ltemp== head)
*head= NUL 5
foee (temp)
elses
Poiutflstudeut uoith TolLnombes '.d not fovud\nolnumbes)s
Void dispay (stoct studeut Ahead)
if (head== No)E
Piatf" ist is empty")»
Stouct &tudent * temp =head- next s
Poutf ("Students iathe ist: ln)
do f
Poitf(CNoame: 1.6,koll nomtes :1.d\n", tempnametemplnobes)
ternp =temp’nexti
wlile tenmp = headnet);

Stouct Student *head= NULL:


iusest Foot (sheadAyush", 14)3
iusert Foot (aheadSaqd", 46) >
Rusest Fooud | Shead, Kunal", 24)
display lhead)s
deleteStudent Lhead,24)3
display Uead)
Tetun 0
3
wNode3 asoentnew
nenodeode
newNode-next=UOet’
hext;
Urseutnexti orsent=
Eata< (Crooeutnext
l=NuLL
Ss oile
elses
newNodei *head=
head3 *next=heoNode-
>=data)E (head<=NULLIl
datahead)’ if
*head cuo»Seut= Nodet Stouct
(data);
=cseateNode Node ne Nodet stsuct
data) E iuiusestSorstedlstouct
t head, teNode Void
Node New Tetusn
NeONode’nex=
NULLi
datadata= neuoNode
\); faited allacatfo MemOy Priutf('
NU) (Neonode == if
Node)) lStuct (sizeof malloc nodet)node-(Stovct new Nodet Stooct
data)
(iut Nocle ceate Node* Stouct
hexti Node* Stzuct
datas
node stisutuct
cstdb.hz iucyde #
<stdio.h #inclode
List
Liuked Sorted deletfou
u InseztiouS
Poqsam-b
Void delete Node Is&ct Node *# head, iut data)t
Stoct Node t temp=hend,* prev i
Ctemp != NuLL && tenp-s datr==data)¬
*head =temp’ hext )
free temp):

We (tep = NULL &S tenap- data |= dato)


Prev= temp
tenp temp--next

if Ctemp = NULL)
Tetuoni
Psev’next =tevpnext i

Void dispay LStoct Node t hend){


stsuct Node *temp = headi
wh¥e (tenp !=No)E
Pitf .d ", temp’daBa);
*enp= tempnets
Poiutf("NULL \n"):

ut moiu)
trouct Node * head = NuLL :
iusert Sored (sheads5)}
jusestsotedl&hecd,0);
iusest Sooted sheod, 2);
Susert Soroted (& head1);
usest Sooted s hend4);
Pritf ("sorted lRred list: );
display head);
delete Node dahead ,5)>
delete Node Câ head2):
Poitf("So sBed liuked Gst aftes deletio w: "):
divplay (hend):
Tetuu D;
Pogam
"Create Lineax Eyueue Using Linked ist aud
Tnplemeut difteaeut opeatfous
# include <stdio.h>
#include <stdißb. h>
Stsuct node
0ut data
Stouct node next

stoct qyueue f
Stouct nole foout ;

Stsuct queue * coeate qyueve ()£


Stsct qoeue *=
*q = malloc (size of
(Stouct queue )):
4oont =NULL;
"etusn

iut is Ermpty (stuct yueue ty)i


etusu a ’foout == NULL:

Vo euayueue (stsoct qyueue *a*, Tut data)


stouct node * neuoNode = malbc (size of
(stTuct node));
neuNodedcta - datai
heuNode next = NUL 3
next; =temp Temp
tempdata); zdPoiatf
NuL) temp olite
l=
fsouti temp=q node* Stuct
*v)E quewe (stuct bucue display Void
datai TetuTu
(temp); tree
NUL; deas=
==NULu) &lfout if
fout=foout’
y nexti
frout temp= node stauct
datai foout data= iuct
elsef
(ktmpty(y)E
qruveue (stroct deqyveue iut
newNode
4deaTnext
i
else
newNode 4DeaT =
newNode i 4frout
(kÉmptyly)E
int main (OE
stoct yueve * = Create Sueue )i

euqyuewe (qy,20)
Chqyueve (qy30) ;
di~play Suevel);

display Sueue lq)3


detusu 0;
Progam-8
Perfoom Operatfous ou
Search Toee "

t iuclvde <stdio.h >


# iuclude <stalb.h>
typedef Sttuct Node 8
iut datai
Stouct Node left i
Gtuct Node* elqkt
Node ;
Node * ceate Node Gut data)
Node * newNode = (Node* ) malloctSize of (Node));
if neusNode')

newNode data= daa s


neo Nde
left ==NULL;
new Node igut = NULL)

Detuou newNode:

void iusest (Node **toot , ut data)


Foot = NULL)
*röoot = cveate Node (data) i

if Cdata <(* Toot)’data)


fusect (A toot)left),data);
else $
Tusedt (s(* Toot)ogt), data) i
Void fuosder Iiaversal ( Node t Toot )
1f(Doot == NuLL)

luosderTaueTsal(oot Left):
Poiutf I.d-", oot deta):
fuosdeg 1auesal ( Tootight )i

Void poeTavessal (Nodet s0ot


f(zoot = NULL)
detuui
fsiatf .d", doot-data):
PseTsaveoSel (30ot eft
Pse TyauesalLt00t t;

jut mau()
Stout Node* oot =NULL3
lwsestoot,50) ;
iusest (S oot,30);
iusert b-0ot. l00);
iuserst (&ooot , bo):
IwoodesTsavegsalsoot
Foiutf ("n);
Pse ToaveKsal loot;

You might also like