









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Date: Jan 13, 2015 Marks: 100 Time: 3 hours
Roll Number: _______________ Section: ____________
Q1 [10] Programming Basics
What is the value of variables x , y Just before the return statement of function main? Also what will be stored in arr3 before the end of main function?
#include
int main() { int x = 1,y=5; int arr1[SIZE]={1,3,7,9,23}; int arr2[SIZE]={2,8,10,12,24}; int arr3[SIZE*2]={0}; ProcessCode(x,y); switch(x+y) { case 1: case 2: MysteryFunction(arr1,arr2,arr3,SIZE-1); break; case 3: MysteryFunction(arr1,arr2,arr3,SIZE); break; case 4: MysteryFunction(arr1,arr2,arr3,SIZE-2); break; } //what is the final value of the variables? return 0; }
void MysteryFunction(int arr1[],int arr2[], int arr3[],int size) { int i=0,k=0,j=0; while (i<size || j< size) { if ((i < size) && (arr1[i] < arr2[j])) { arr3[k] = arr1[i]; i++; } else { arr3[k] = arr2[j]; j++; } k++; } }
void ProcessCode(int Code1,int &Code2) { Code1 = Code1+1; Code2 = Code2-4; }
x = _____________ y = _____________ arr3[] = ___________________________________________________________________________
Q2 [25] LinkedList
(a) Swap two adjacent pair elements by adjusting data along whole linked list Singly linked list. Write a recursive function for it.
Original List
Resultant List
Q3 [15] Priority Queue
A priority queue can be expressed in the form of heap tree. Priority will be used as heap criteria. Assuming priority queue is built to handle processes in operating system and a list of processes is maintained in a priority queue. Processes are attached with attributes priority and arrival time. Write a procedure HEAP_PRIORITY_QUEUE to service the processes as FIFO order only.
Q4 [30] Tree Representations and Algorithms
(a) Define a template based Node of B Tree.
(b) Perform the following operations on the 4-way B-Tree (2-3-4 tree) given below.
Starting from the initial tree, insert: 66, 54, 88, and 39 Starting from the initial tree, delete: 16, 25, 53 and 27
Q5 [20] Graph Representations and Algorithms
(a) Given an undirected weighted graph G = (V, E), design an algorithm to find a minimum weight cycle in G. Note that the weight of cycle is simply the sum of the weights of all its edges. There could be more than one minimum weight cycles in G, and you might report any one of them, along with the weight itself. You must:
Describe your algorithm in English. Give a clean and precise pseudo code. Analyze your algorithm and state its running time as a function of |V| and |E|.
Note: You should not re-write any algorithm covered in class, but can use it as a function call.