Two linked list in a array is possible?

1 answer

Answer

1226984

2026-04-24 00:36

+ Follow

Like this:

#define MAXLIST 100

int first, next [MAXLIST];

/* let the list be: #0 ---> #2 ---> #1 */

first= 0;

next[0]= 2;

next[2]= 1;

next[1]= -1; /* means end of list */

Note: you should track which elements are unused,

in the beginning every elements are unused:

int first_unused= 0;

for (i= 0; i<MAXLIST; ++i) next[i]= i+1;

next[MAXLIST-1]= -1; /* means end of list */

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.