top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Implement link list without pointer in C Language ??

+5 votes

Implement link list without pointer ??

posted Nov 17, 2013 by Anuj Yadav

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

+1 vote
typedef struct item {
    type data;
    struct item next;
} Item;

and now the C compiler will go to try to figure out how large Item is. But since next is embedded right in Item, it'll end up with an equation like this

size-of-Item = size-of-type + size-of-Item

You end up with an infinitely large data structure that would use an infinite amount of memory, and that of course can't work.

answer Nov 18, 2013 by Satyabrata Mahapatra
how you will allocate/assign memory for this ?
+1 vote

I believe the best way to implement the link list without pointer is to use array.

struct node 
   type data;
   int    index;

struct node linklist[MAX_SIZE];

Here index represent the index within the array.

1. All the index may not be used which means a wastage of memory.
2. LinkList can not grow beyond the MAX_SIZE

answer Nov 18, 2013 by Salil Agrawal
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.