http://www.gatecse.in/programming/

http://www.gatecse.in/data-structures/

Refer the above two links for the materials. Also do follow this blog for GATE 2017 (we won't be using moodle any more). I'll be adding some exercises as comments. Most exercises for this subject will be programming ones. 

posted in Programming & Data Structures Mar 17, 2016
by
969 views
0
Like
0
Love
0
Haha
0
Wow
0
Angry
0
Sad

3 Comments

3 Comments

Like
1. Write a C function to reverse a linked list.
struct node {
int x;
struct node * next;

};
typedef struct node node;
node * reverse (node * list);

2.
int c,d;
int *a = &c,  *b = &d;

Write a C function to swap the values of a and b.
Like
1.
node *reverse(node *list)
{
  node *prev , *current, *next;
  current=list;
  prev=NULL;
  while(current!=NULL)
  {
    next= current->next;
    current->next=prev;
    prev=current;
    current=next;
  }
list=prev;
return list;
}

2. void swap(int *a, int *b)
  {
     int temp;
     temp=*a;
     *a=*b;
     *b=temp;
}
Like
In the first code why are you returning list? Can the function work with return void?