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

Data Structure and Algorithms I - Mid - Fall 2023

Uploaded by

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

Data Structure and Algorithms I - Mid - Fall 2023

Uploaded by

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

United International University (UIU)

Dept. of Computer Science and Engineering (CSE)


Mid Exam Year: 2023 Trimester: Fall
Course: CSE 2215 Data Structure and Algorithms-I
Total Marks: 30, Time: 1 hour 45 minutes

(Any examinee found adopting unfair means will be expelled from the trimester
/ program as per UIU disciplinary rules)

There are FOUR questions. Answer all of them. Figures in the right-hand margin
indicate full marks.

1. a) How does the Descending Order Insertion Sort work on the following data? [3]
y p z x r s
Here, x=last two digits of your student id+3, y=x+3, z=x+y, p=y+z, r=x+2, s=y+9

b) Find a recurrence for time using the recursive Merge Sort and solve the recurrence. [3]

c) How many element comparisons are needed for the following instance of the [2]
Ascending Order Quick Sort to find the first partitioning element?

18 23 56 26 89 37 28 48

2. a) Find the memory location of A[70][80] if loc(A[15][20])=x+1400, where x=last four [3]
digits of your student ID. Assume column-wise memory is allocated in the double type
array A[90][100], where each double data is 8 bytes.

b) If f(n)=kn2-3n+5, prove that f(n)=Ɵ(n2). Here, k=last digit of your student id+4. [3]

c) How does the Binary Search Algorithm work on the following data?
Input Data: t r p z y x
Search Key=y
Here, x=last two digits of your student ID, y=x+4, z=x+y, p=y+z, r=z+p, and t=p+r [3]
Also find the total element comparisons for the given instance of the Binary Search.

3. a) An array contains 10, 20, 30, 40, 50. Now we want to insert 15 in-between 10 and 20. [2]
Remember that it will maintain the ascendency after insertion. What is the difficulty for
this insertion? How this problem can be resolved by a linked list easily?

b) Suppose a linear linked list headed with “start” contains four nodes whose data values [6]
are 40, 50, 30, 20, respectively. Show the following operations.
i) Draw a diagram for the linked list.
ii)Find a name for each of the nodes with respect to “start” that contain 40, 50, 30, 20,
respectively?
iii) Write statements to represent 40, 50, 30, 20, respectively.
iv) Write a statement to set NULL at the end of the linked list.
v) Write statements to delete the node that contains 30.
vi) Write statements to insert a node “temp” in-between 50 and 20 that contains 28.

1
4. a) Show the effect of each of the statements given in the following code segment. [3]
Assume, each of the nodes in the doubly linked list has three fields’ data, next and
back, where data is of integer type, and next and back will contain the addresses of the
next and previous nodes, respectively.

start=(node*)malloc(sizeof(node));
temp=(node*)malloc(sizeof(node));
temp1=(node*)malloc(sizeof(node));

start->data =10;
temp->data=40;
temp1->data=30;

start->next=temp;
temp->next=temp1;
temp1->next=NULL;

temp1->back=temp;
temp->back=start;
start->back=NULL;

temp->back->next=temp->next;
temp->next->back=temp->back;
free(temp);

b) How can you reverse a string using a STACK implemented by an array? Show push() [2]
and pop() operations in this regard.

You might also like