Unit 2: Linear Data Structures

11/30/2025
5 min read
Data Structures and Algorithmssemester3SEITSPPUPremium

2.1 Arrays

An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together.

array_example.c
#include <stdio.h>

int main() {
    int arr[5] = {10, 20, 30, 40, 50};
    
    // Accessing elements
    printf("Element at index 2: %d", arr[2]); // Output: 30
    
    return 0;
}

2.2 Linked Lists

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers.

Singly Linked List Node Structure

struct Node {
    int data;
    struct Node* next;
};

Last updated: 11/30/2025