Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Linked List Data Structure: Implementation and Operations in C, Slides of Computer Programming

This code snippet demonstrates the implementation of a linked list data structure in c. It covers basic operations like insertion, deletion, and display. The code provides a clear and concise example of how to create, manipulate, and traverse a linked list, making it a valuable resource for understanding this fundamental data structure.

Typology: Slides

2020/2021

Available from 02/02/2025

the-manku-store
the-manku-store 🇮🇳

8 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linked List
pf3
pf4
pf5

Partial preview of the text

Download Linked List Data Structure: Implementation and Operations in C and more Slides Computer Programming in PDF only on Docsity!

Linked List

Linked List

struct node

int data;

struct node *next;

#include<stdio.h>

#include<stdlib.h>

struct node

{

int data; struct node *next;

};

void display (struct node* head)

{

struct node *temp = head; printf("\n\nList elements are - \n"); while(temp != NULL) { printf("%d --->",temp->data); temp = temp->next; }

}

void insertAtMiddle (struct node *head, int position, int value) { struct node *temp = head; struct node newNode; newNode = (node)malloc(sizeof(struct node)); newNode->data = value;

int i;

for(i=0; i<position-1&& temp!=NULL;i++) { temp = temp->next; }

newNode->next = temp->next; temp->next = newNode; }

void insertAtFront (struct node** head, int value) {

struct node newNode; newNode = (node)malloc(sizeof(struct node)); newNode->data = value; newNode->next = head; *head = newNode;

}

void deleteFromFront (struct node** headRef){ head=(head)->next; }