Linked list in C
Në shqip: Lista e lidhur në C
ShpjegimiSQ
Në C, lista e lidhur ndërtohet me struct-e që kanë një vlerë dhe një pointer drejt nyjës tjetër, dhe çdo nyje e krijon me malloc. Është ushtrimi klasik për të kuptuar pointer-ët.
EnglishEN
In C, a linked list is built from structs holding a value and a pointer to the next node, with each node created by malloc. It's the classic exercise for understanding pointers.
Si ta mendosh
Si gjuetia e thesarit: çdo shënim të tregon ku është shënimi tjetër.
Lexoje në anglisht
Like a treasure hunt: each clue tells you where the next clue is.
Shembull kodic
struct Nyje { int vlera; struct Nyje *tjetra; };
struct Nyje *e_re = malloc(sizeof *e_re);
e_re->vlera = 5;
e_re->tjetra = koka; koka = e_re;