The document contains a C program that implements a simple linked list using an array. It defines a structure for nodes and includes functions to insert values into the list and display the current list. The program manages the head of the list and tracks the next free index for new nodes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Singly Linked List Array Implementation
The document contains a C program that implements a simple linked list using an array. It defines a structure for nodes and includes functions to insert values into the list and display the current list. The program manages the head of the list and tracks the next free index for new nodes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
#include <stdio.
h> head = freeIndex;
freeIndex++; #define SIZE 10 } #define NULL_INDEX -1 void display() { struct Node { int current = head; int data; while (current != NULL_INDEX) { int next; printf("%d -> ", list[current].data); }; current = list[current].next; } struct Node list[SIZE]; // Array to store nodes printf("NULL\n"); int head = NULL_INDEX; // Index of the first node } int freeIndex = 0; // Points to the next free space in the array int main() { insert(10); void insert(int value) { insert(20); if (freeIndex == SIZE) { insert(30); printf("List is full.\n"); return; printf("Linked List: "); } display();