1 / 4

Inserarea unui nou element in lista

Inserarea unui nou element in lista. Inserarea unui nou element in lista. Inaintea nodului cu valoare x Dupa nodul cu valoare x Pe pozitia k. Inserarea unui element inaintea primului nod. Y. prim. nou. prim. prim. Pasii: Se aloca memorie nodului Se scrie informatia in nodul nou

fiona
Download Presentation

Inserarea unui nou element in lista

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Inserarea unui nou element in lista

  2. Inserareaunuinou element in lista Inaintea nodului cu valoare x Dupa nodul cu valoare x Pe pozitia k

  3. Inserareaunui element inainteaprimului nod Y prim nou prim prim Pasii: Se aloca memorie nodului Se scrie informatia in nodul nou Nodul nou se leaga de nodul prim Nodul nou inserat devine prim void inserare() {nod *p, *nou; int y; cout<<“y=“; cin>>y; if (prim->info==x) {nou=new nod; nou->info=y; nou->urm=prim; prim=nou;} }

  4. Inserareadupanodul cu valoare x Se aloca memorie nodului Se scrie informatia in nod Nodul nou se leaga de succesorul nodului q Nodul q se leaga de nodul nou Daca nodul p a fost ultimul nod al listei atunci nou devine ultim void inseraredupanodx() {nod *p, *nou; int y; cin>>y; p=prim; while (p->info!=x && p) p=p->urm; nou=new nod; nou->info=y; nou->urm=p->urm; p->urm=nou; if (p==ultim) ultim=nou; } urm=nou; nou q->urm Y q->urm nou q

More Related