Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 74 additions & 46 deletions Assignment 1/17CS30038_1.c
Original file line number Diff line number Diff line change
@@ -1,71 +1,99 @@
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdint.h>

struct node
{

int data;
struct node *xor;
};

};//End of structure

struct node *xor(struct node *a,struct node *b)

struct node *xor( struct node *a , struct node *b )
{
return (struct node*) ((uintptr_t) a ^ (uintptr_t) b);
}
void trafte(struct node *head)

return ( struct node* ) ( ( uintptr_t ) a ^ ( uintptr_t ) b );

}//End of function


void trafte( struct node *head )
{

int i;
struct node* temp=NULL,*prev=NULL,*temp2;
temp=head;
printf("front to end traversal\n");
printf("%d\t",temp->data);
temp=temp->xor;
prev=head;
while(xor(temp->xor,prev))
struct node* temp = NULL , *prev = NULL , *temp2;
temp = head;
printf( "front to end traversal\n" );
printf( "%d\t" , temp->data );
temp = ( temp->xor );
prev = head;

while( xor( temp->xor , prev ) )
{
printf("%d\t",temp->data);
temp2=prev;
prev=temp;
temp=xor(temp->xor,temp2);
}

printf( "%d\t" , ( temp->data ) );
temp2 = prev;
prev = temp;
temp = xor( ( temp->xor ) , temp2 );

}//End of while

printf( "%d\n" , ( temp->data ) );

}//End of function


printf("%d\n",temp->data);
}
int main()
{

int n;
scanf("%d",&n);
struct node * front=NULL,*end,*move,*temp,*prev,*temp2; ;
int i=0;
for(i=0;i<n;i++)
scanf( "%d" , &n );
struct node * front = NULL , *end , *move , *temp , *prev , *temp2;

int i = 0;
while( i < n )
{
move=(struct node*)malloc(sizeof(struct node*));
move->data=rand()%100;
move->xor=NULL;
if(front==NULL)

move = ( struct node* )malloc( sizeof( struct node* ) );//Allocate free space in the memory
( move->data ) = ( rand() % 100 );
( move->xor ) = NULL;

if( front == NULL )
{
front=move;
front = move;
}
else
{
prev->xor=move;
( prev->xor ) = move;

}
prev=move;
}
end=move;
move=front;
prev=NULL;
for(int i=0;i<n-1;i++)
}//End of if

prev = move;
i = ( i + 1 );

}//End of while

end = move;
move = front;
prev = NULL;

i = 0;
while( i < ( n - 1 ) )
{
temp=move->xor;
temp2=move;
move->xor=xor(prev,temp);
move=temp;
prev=temp2;

temp = ( move->xor );
temp2 = move;
( move->xor ) = ( xor( prev , temp ) );
move = temp;
prev = temp2;
i = ( i + 1 )

}
move->xor=prev;
trafte(front);
}//End of while

( move->xor ) = prev;
trafte( front );
return 0;

}
}//End of main