0% found this document useful (0 votes)
6 views

CSF102 Data Structures

This document is a mid-term examination paper for B.Tech (CSE/IT) students at DIT University, focusing on Data Structures. It includes various questions related to linked lists, algorithms, time complexity, and asymptotic notations, with a total of 50 marks. Students are required to attempt all questions and cannot leave the examination hall before completion.

Uploaded by

sugarmomo222
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

CSF102 Data Structures

This document is a mid-term examination paper for B.Tech (CSE/IT) students at DIT University, focusing on Data Structures. It includes various questions related to linked lists, algorithms, time complexity, and asymptotic notations, with a total of 50 marks. Students are required to attempt all questions and cannot leave the examination hall before completion.

Uploaded by

sugarmomo222
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Paper Code: CSF102 Printed Page 1 of 2

DIT UNIVERSITY DEHRADUN


B.TECH (CSE/IT) MID TERM EXAMINATION, EVEN SEM 2023-24 (SEM II)
Roll No.
Subject Name: Data Structures
Time: 2 Hours Total Marks: 50
Note: All questions are compulsory. No student is allowed to leave the examination hall before the completion of the exam.
______________________________________________________________________________________________________

Q.1) Attempt all Parts :


(a) If you are using C language to implement the heterogeneous linked list, what pointer type will you
use? And why?
(b) Write the time and space count for the following code fragment?

for(i=0; i<N; i++){


for(j=0; j<N; j++){
sequence of statements
}
}
for(k=0; k<N; k++){
sequence of statements
}
(c) Consider the following definition of a node -
struct node{
int data;
struct node* next;
};
What does the following function do for a given linked list?

void fun2(struct node* head){


if(head==NULL)
return;
printf(“%d”, head->data);
if(head->next!=NULL)
fun2(head->next->next);
printf(“%d”, head->data);
}
(d) Mention the time complexity (frequency count) of below mentioned recursive function.

void fun1(int n){


int i=0;
if(n>1)
fun1(n-1);
for(i=0; i<n; i++)
printf(“*”);
}
[4 x 2.5= 10]
Paper Code: CSF102 Printed Page 2 of 2

Q.2) Attempt all Parts :


(a) Find the validity of the statement “A O(n) algorithm is ɵ(1)”? Justify your answer.
(b) What are the properties of a priority queue? Explain the various operations a priority queues
supports.
(c) Given an integer array, provide the algorithm to find subarrays with a given sum in it. Also provide the
worst case time complexity for both union and intersection.
(d) Consider an array consisting of –ve and +ve numbers. What would be the upper bound of the time
complexity of an algorithm to segregate the numbers having same sign altogether i.e all +ve on one
side and then all -ve on the other?
[4 x 2.5= 10]

Q.3) Attempt any Two Parts :


(a) How will you find the nth node from the end of a singly linked list in a single pass?
(b) Given a linked list that contains alphabets. The alphabets may be in upper case or in lower case. Write
an algorithm/program to create two linked lists, one which stores upper case alphabets and the other
that stores lower case characters.
(c) Write an algorithm with computational complexity O(log n) to search an element in the sorted array.
[2 x 5= 10]

Q.4) Attempt any Two Parts :


(a) Write and algorithm/C program to input an n digit number. Now, break this number into its individual
digits and then store every digit in separate node thereby forming a linked list. For example, if you enter
1234, now, there will be four nodes in the list containing nodes with values 1, 2, 3, 4.
(b) Write an algorithm/C program to delete the last occurrence of a given character in a linked list.

(c) Covert the following expressions from infix to postfix:


a.) A/B^C+D*E-A*C
b.) (b^2-4*A*C)^(1/2)
[2 x 5= 10]

Q.5) Attempt any Two Parts :


(a) List the properties of circular linked list and write the C code for creating a circular linked list.
Suppose a queue is housed in an array in circular fashion. It is desired to add new items to the queue.
Write down a procedure Enqueue to achieve this also checking whether the queue is full. Write another
procedure Dequeue to delete an element after checking queue empty status.
(b) Why do we use asymptotic notations in the study of an algorithm? Describe commonly used asymptotic
notations along with their significance.
(c) Given two arrays a[] and b[] of size n and m respectively. Provide the algorithm to define an operation
to find the union and intersection of these two arrays. Also provide the upper bound of the time
complexity for both union and intersection.
[2 x 5= 10]
-----END OF PAPER ----

You might also like