Question 1
Question 2
#include <stdio.h>
char str1[100];
char *fun(char str[])
{
static int i = 0;
if (*str)
{
fun(str+1);
str1[i] = *str;
i++;
}
return str1;
}
int main()
{
char str[] = \"GATE CS 2015 Mock Test\";
printf(\"%s\", fun(str));
return 0;
}
Question 3
Question 4
Consider the following routing table of a router.
Prefix | Next Hop |
---|---|
192.24.0.0/18 | D |
192.24.12.0/22 | B |
Consider the following three IP addresses.
Prefix |
---|
192.24.0.0/18 |
192.24.12.0/22 |
192.24.54.0 |
How are the packets with above three destination IP addresses are forwarded?
Question 5
Which of the following is NOT true about User Datagram Protocol in transport layer?
Question 6
T(x, c) = Θ(x) for c <= 2, T(c, y) = Θ(y) for c <= 2, and T(x, y) = Θ(x+y) + T(x/2, y/2)
Question 7
Question 8
Question 9
Which of the following changes to typical QuickSort improves its performance on average and are generally done in practice.
1) Randomly picking up to make worst case less likely to occur. 2) Calling insertion sort for small sized arrays to reduce recursive calls. 3) QuickSort is tail recursive, so tail call optimizations can be done. 4) A linear time median searching algorithm is used to pick the median, so that the worst case time reduces to O(nLogn)
Question 10
void fun(int arr[], int n)
{
for (int i = 0; i < n; i+=2)
{
if (i>0 && arr[i-1] > arr[i] )
swap(&arr[i], &arr[i-1]);
if (i<n-1 && arr[i] < arr[i+1] )
swap(&arr[i], &arr[i + 1]);
}
}
There are 18 questions to complete.