Download as pdf
Download as pdf
You are on page 1of 20
1 12 B ry 45 rT v7 rT) 5 20 2 2 2 24 a ro Pa 28 ra) 30 1 yy ey er ee 36 37 Ed ate eee pron teeeerecasy void insertbeg(int value); een erent 1 Prec een eames nanoH erearerens Serre Peri neetesh Saag ciarren Sirens poet eriny poet Cree oy Rar ae cease ey int main(){ Sieg ey eueg eC Re ceeaee eo Re ECs SUSGuB ote seu ry SGD reo emote req eee Tae SLCC aor Ba Pore en amtoys struct node *newnode=(struct node*)malloc(sizeof(struct node)); peur eerste Crean rriey| ee eee } ewe Cece cece Ceres ? SOC m URC erm} S Corea ery pres eter ie Cor tesn reson rsthes tetra Contest Se ais ES} rr oe 42 ry 44 ro PS 47 eo 49, Ed es 52 Ey 54 cA 57 58. re) cy Ge 62 ct 64 cs 66 a cy 69 70 rz n re ort struct node *newnode=(struct node*)malloc(sizeof(struct node)); ee eee ee eee Cece yg ere Smee re Ey 7 ors sere ese Tang cues ees oy Void insertatx(int value, int x){ Se Leer oe ate acy Ce ee ae Prec me TIDY eee ee ere nad B ene Pe GmecceEye ere meee) } Eee eae ect Re eee } + MoCm tore Ses ere Cee nS cere iiey cece oy eee eat Ferree res rE ofa rz ey rr) Er 81 Pa Fey Py PS ca Er 92 Pt 90 ch 92 Ee ey Pr eo er er) 99 100 101 sty) 103 104 eT aT Bier Es + void deleteend(){ See ere ec ed while (temp->next !=NULL){ crea Re ee eas 3 cer ees Sear Tn La COtenaeort eee Mets me are oad PiDeeigea mecieTie yg ores Re ee eas + ec eee aera) Stacey af SORE ZC ea MTS eres ac while(temp->next |=NULL){ ee eee cron cs eos I Gece eer 7 peer te aera at | pease eee if (temp=-NULL) return 0; es res Ccr ecco ys SE ed closers) 133 soy rN Length: 1 rt) a rr Pry 14 rey 16 v rT] re 7 2 rd ry px 26 2 28 rt) 30 31 Pr ) 34 co eo Ey or od oe x eras ee erie Meera Soe ra cacy rea esc ere ea aS eae sec ea Ty retest Oncaea eta) ra Trey eee ey eee eect co) temp-rdata = A[0] pe eee creat [CONC Ree reE maCTaEESD) a eC a eC aa) carne esh cerca nes pees cee aes 3 Peco 5} Serer a a) PCRC ua Unb) ee ee ey eee a 3 Rese ere Ce ee ee) ee eee Perea ere are T nn er ees rr oon 42 43 or es ora } ct a Cl eee aaa | { } en second = NULI eee E} CEsO} int AL] = (1,2,3,4}5 cra a CRA Gia CM second = create(B, 4); Peiem Greet Merri yy eee unary Pisa Gaur Meco mers print (second) ; re Gacy printf (“\n\nConcantenated Linked List: \n")5 PStraes trio en Siete S Ast Linked List: 1234 3 2nd Linked List: 5 678 renee we cc Metres 12345678 20 cg ° inclipiecstdio.n> Peet eerie ars cy prea s ra oy Tacos crea irre SoC n ee eta eae} i Pores potest cans tC seen) co while (current->next != NULL) { Sta reser) { rae reetscaet ry} Cease esc Gree eee eee cacy 5 or t } } eee eas SeCn re etoa eet aac) fa } struct Node* new node =(struct Node) malloc(sizeof(struct Node); pre eer ene ys eet een orem ean sy SSCn Stee etoat ae) Pee ae Tne) ci Et a eta QP ese ry cea cay + corto) Saree oa ean Pree Pree PCD Pree eed rence ey CeCe cae printf("\n Linked list before duplicate removal Pure cnt oy removeDuplicates (head) ; printf("\n Linked list after duplicate removal “); SUE ett) cera a ad ,, cy Pee Bea Ce sete er ee Sem oc Bettas sericea a eee oe) crt Et ca Ere ere TEL Poesy 5 t Ea eae a CROC Cag cea} { if (head == NULL) returns ea eee ee eat rs eee Unb aan Pree ee eee ero sees tee eco SC eC aae eea Re OTD) t Sea a eC aean RC eSt Ce ape ee eee em ces ei eet ee Cue (thead_ref) = new_node: + CREE Cea eat} { Lisi @e emo Sec eae esas + Ei Ey ro] Eo] 40 a ory rey on or 46 ya on ry Et) 52 53 int main() { eae aa ean Pree rae Preece eS renee) renee) eC PEC aD ET printf("\n Linked list before removal printList(head); Ptr Petgenue etl eecse ts fenovat S Ue CTC) ct ed 5 Pee EC oa ees SeeeU rears eee oT ae eS rr Er) eat Ey Er} sav ety eG 37 Prater eyes eater ress 6 eet aeee eras erase ag Boerner struct Node* next i POS Crema ae bool comparelists(struct Node*, struct Node*); Pov eo rt es Creaa tae) ie Se SC ee eed struct Node *second_half, *prev_of_slow ptr - head; Ses eae ee RY oo ee Co eee eee nee CCC oa ome nme ecto ae eae coat eee eee earocas prev_of_slow_ptr = slow ptr; Berman Comoe s) + pecan ne midnode = slow ptr Sn meee Cm cerns] + eee Mees Cm ta Caras rm ees ney acer Cesc MD res = compareLists(head, second_half); eC eeu acon if (midnode != NULL) { prev_of_slow_ptr-snext = midnode; Cee eee eet cr er 40 te oy ory or a5 a oy) ory ory Et Ee 53 cy eS 57 Ey ES 60 Gr 62 63 a a 66 67 cy 6 rT mn OES aS Cee 5} Pets} SUR Cae ee Ce) a + Pca eal ea ny eee eee ey eee aes eC ee Uno eg eee eee renee at nate Peas reac) } *head_ref = prev; bool comparelists(struct Node* head1, struct Node* head2) { crea nas Pea eco See ad PCR @er Sees Sed Sage eee ec cones ce eee eas ey ee Seas a7 Sed Pacey $ crac NULL) Pees aay Pe cd of) 7m r7 2 ozy 75 76 7 7 oD ET a Pa Ee} Py ES Ea Ey Ey Er cr ea 92 cy a ory 96 ey or cy or ce x Pace ce } void push(struct Node** head_ref, char new_data) t struct Node* new_node= (struct Node*)malloc(sizeof(struct Node)); Cee et ent Cet Se aero (thead_ref) = new node; ay Rote Sect aa carp) ae eC mee eee printf("%c->", ptr-sdata); eee eos 3 Prureg@n Ue + Srranrrty6) i Sera cea ean, Cee eae int i; cree ara Fo CEO ES , Prec et ae esp Beye tt Ree nage CEC ets ea a Feud Graco EUR sr oxtpatiot =x 1 Is Palindrome er cr x Poot cress 7 preetrererr cas Perea pare eee re cee ca eee eee) come te cae ne eee eae ae cs eee ato ea ey Peer at Ean [is eet ee Sree eee ey etna reas + head_ref = prev; + SCR Cae ea Re ane) ae Se a ae Coan CC conan en ee ee new_node-mnext = (*head_ref); ema + oC LE Caee aa eal) { Sea eae ey while (temp != NULL) { ee treGe RR Eee cee estas + int main() 37 38 Br 40 re a2 ory or ory oe oa oy 43 struct Node* head = NULL; eC yi push(&head, 3: push(&head, ree irae usec aw tne Cn Peco) ey trea ieee EU ECLA eee Poca ers SC ned etre eetr sera carers Coes et corn rere

You might also like