The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
465 views

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 Mar 17, 2016 in Programming & Data Structures by Veteran (352,303 points) | 465 views

3 Comments

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.
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;
}
In the first code why are you returning list? Can the function work with return void?
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

37,019 questions
44,592 answers
126,850 comments
43,663 users