VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 06:55:26 02/28/02 Thu
Author: Hjálmtýr
Subject: Re: Linked lists
In reply to: 's message, "Linked lists" on 05:38:01 02/28/02 Thu

>Til að búa til hausabendi á lista með fyrsta stak q, á
>það ekki að vera hægt að búa til nýjan hnút með NULL í
>Item og q í next (NULL,q)? Þetta fæst ekki til að
>virka. Er þetta ekki annars leiðin til að búa til
>hausabendi ?

Það er tvennt hér: Innihald item-sviðsins verður að vera af réttu tagi. Ef tag þess er int, þá ætti að vera í
lagi að setja NULL í það svið (því NULL er bara 0), en ef tag þess er eitthvað annað, þá þarf gildið að vera af því
tagi. Þetta er bara dummy gildi, því það er aldrei notað, en það verður samt að setja eitthvað í það þegar hnúturinn er búinn til (hann er búinn til eins og hver annar hnútur).

Síðan þarf q að vera hnútabendir (node *q), sem ggæti verið NULL eða bendir á raunverulegan hnút.

Þá gæti kódinn verið:

node *q = NULL;
node *haus = new node( 0, q );

Reyndar er bendirinn q ónauðsynlegur, því við höfum bendirinn haus, sem bendir á hausahnútinn.

[ Next Thread | Previous Thread | Next Message | Previous Message ]

Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.