Showing posts from September, 2014

C Program to insert/delete/traverse/display XOR Linked List

Here is the C Program to insert/delete/traverse/display XOR Linked List.XOR linked list is said to be memory efficient version of doubly linked list.


struct Node{
int data;
struct Node *ptr;
struct Node* XOR(struct Node *a,struct Node *b){
return (struct node*) ((unsigned int) (a) ^ (unsigned int) (b));
void insertIntoXORLL(struct Node **head,int pos,int data){
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
if(*head==NULL){//Insert first Node
struct Node *current=*head;
struct Node *previous=NULL,*next=NULL;
struct Node *nextNode=NULL;
}else if(pos>1){
int count=1;
while(current!=NULL &&…

C Program to sort an array using insertion sort

I have seen couple of students who use swap in insertion sort to sort an array.Insertion sort is an example of exchange sort ,we don't swap two elements to sort an array ,instead of this we shift elements if ith element is greater than i+1th element to sort an array.It works on simple concept:-
Store the ith element in temporary variable and shift element until you find the element smaller than this element towards 0 index position.Here is the C Program to find insertion sort:-

#include <stdio.h>
#include <string.h>

    int arrSize,i;
   printf("Enter Size of array:");
   int array[arrSize];
   int temp,j;