The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
448 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 (338,941 points) | 448 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

34,786 questions
41,762 answers
118,950 comments
41,409 users