Cov txheej txheem:

Koj yuav rho tawm ib daim ntawv txuas txuas li cas?
Koj yuav rho tawm ib daim ntawv txuas txuas li cas?

Video: Koj yuav rho tawm ib daim ntawv txuas txuas li cas?

Video: Koj yuav rho tawm ib daim ntawv txuas txuas li cas?
Video: Koj Tsuas Zoo Tham Xwb Tsis Zoo Yuav - Maiv Xis Hawj (Official MV 2023) 2024, Kaum ib hlis
Anonim

Kev rho tawm los ntawm Daim Ntawv Txuas Txuas Txuas

  1. Yog tias lis tsis yog khoob ces peb txhais ob pointers curr thiab prev thiab pib lub pointer curr nrog lub taub hau ntawm.
  2. Hla mus lis siv curr kom pom cov node yuav tsum tau muab tshem tawm thiab ua ntej txav curr mus rau ntawm qhov txuas ntxiv, txhua zaus teeb tsa prev = curr.
  3. Yog tias pom cov node, xyuas seb nws puas yog tib leeg ntawm qhov lis .

Ua li no, yuav ua li cas koj rho tawm qhov kawg ntawm lub voj voog txuas?

Rho tawm qhov kawg ntawm qhov Circular Linekd List

  1. Siv ob lub ntsiab lus tam sim no thiab yav dhau los thiab hla cov npe.
  2. Txav mus rau ob lub pointers xws li tom ntej ntawm yav dhau los yog ib txwm taw tes rau tam sim no.
  3. Ib zaug, tus pointer tam sim no mus txog qhov kawg ntawm, ua cov hauv qab no:

Tsis tas li ntawd, koj yuav rho tawm cov ntsiab lus ntawm cov npe txuas li cas? Muaj ob peb kauj ruam rau kev rho tawm ib lub ntsiab lus los ntawm cov npe:

  1. Nrhiav cov node nrog lub caij (yog tias nws muaj).
  2. Tshem cov node.
  3. Rov qab txuas cov npe txuas.
  4. Hloov kho qhov txuas mus rau qhov pib (yog tias tsim nyog).

Raws li txoj cai, koj yuav thim rov qab daim ntawv teev npe sib txuas li cas?

Hauv qab no yog kauj ruam los ntawm kauj ruam logic kom thim rov qab daim ntawv txuas txuas

  1. Pib pib peb lub pointer variables, kawg = taub hau, cur = taub hau-> tom ntej thiab prev = taub hau.
  2. Tsiv lub taub hau node ua ntej i.e. taub hau = taub hau-> tom ntej;
  3. Txuas tam sim no node nrog yav dhau los ntawm i.e. cur->next = prev;
  4. Ua yav dhau los node tam sim no i.e. prev = cur;

Dab tsi yog daim ntawv sib txuas ob npaug?

Circular doubly linked list yog ib hom kev sib txawv ntawm cov ntaub ntawv ntau dua nyob rau hauv uas ib lub node muaj cov taw qhia rau nws yav dhau los node thiab cov tom ntej node. Thawj qhov ntawm cov lis kuj tseem muaj qhov chaw nyob ntawm qhov kawg ntawm nws tus taw tes dhau los. A ncig ob daim ntawv txuas yog qhia hauv daim duab hauv qab no.

Pom zoo: