Skip to main content

Posts

Showing posts from August, 2012

Linked list using C

This is a Program for Linked List using C. The Code contains enough comments to make your life easy. # include < stdio.h > // structure to hold our data // we call it node // has a int 'value' // also has a pointer that points to next node struct node { int value ; struct node * next ; } ; //typdef will save our time //from now onwards 'struct node' will be replaced by NODE typedef struct node NODE ; // you can notice that we are passing NODE** to insert // Why???? // The answer is simple // since we will be passing the head pointer to the function // and head pointer can be modified in insertion operation // so we must pass a NODE** // reason being if we pass a NODE* to function // its value will be restored after function has returned // hence even if have modified head pointer, it will be restored // so we pass NODE** //------------------ // v is the value to be inserted void insert ( NODE * * base , int v ) {...