SET- A
AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH
Faculty of Science and Technology
Department of Computer Science
CSC 2105 Data Structure (Section: ALL)
Mid Term Examination Summer 2022-23
Total Marks: 100 Moderator: Mohaimen-Bin-Noor Time: 2 hours
Specific Instructions:
1. There are [4] parts [Part-A, Part-B, Part -C and Part-D] and you need to answer from all parts.
2. All the questions are based on OBE Program Outcomes.
3. Answer Part-A in OMR Sheet.
4. Answer Part-B and Part-C in answer script. If required, you may use loose sheet signed and provided by the
invigilator.
5. Part-D is for OBE CO2 evaluation and MUST be answered in question paper.
6. Return the question paper, Answer Script, OMR sheet and loose sheet (if used) at the end of the examination.
Part – A (Answer All) Multiple Choice Questions [35 x 1 = 35 Marks]
Use the following options for question 1-8
(A) True (B) False
1. A structure may be treated as a frame where we organize some elementary items in different ways.
2. A data structure is an approach of organizing data in a computer's memory for only storing.
3. An algorithm is a set of instructions that may be used to solve a problem.
4. Each of these elements can be individually referenced by using an index to a unique identifier.
5. A pointer is a variable that stores the content of a memory.
6. A data structure may not exist as a component of another data structure.
7. A null pointer is a special type of pointer that can point to somewhere without a defined type.
8. An algorithm always performs better than its worst-case scenario.
Consider the following line of codes & answer from 9-12
char alpha[5];
alpha[5] = '*';
9. Which of the following is correct for the array?
(A) It shows memory segmentation error (B) Assigns * in all the indexes of the array
(C) Assigns * in index 5 of the array (D) None of them
10. Which of the following is correct to initialize the array?
(A) alpha[ ]={a,b,c,d,e} (B) alpha [ ]={‘a’,’b’,’c’,’d’,’e’,’/0’}
(C) alpha [ ]={‘a’,’b’,’c’,’d’,’e’} (D) alpha [ ]={“abcde”}
11. What will be maximum index for the array?
(A) 3 (B) 4 (C) 5 (D) 6
12. What will be the memory address of array[4] if the staring address is A100 in hexadecimal?
(A) A10C (B) A108 (C) A112 (D) A110
Consider the following array & answer from 13-17
int arr[3][3]; 1 2 3
2 3 4
3 5 6
13. What is the memory address of arr[1][1] if the starting address is AA00 in hexadecimal?
(A) AA04 (B) AA08 (C) AA01 (D) AA10
Summer 2022-23 CSC 2105 Data Structure Page 1 of 8
SET- A
14. Which of the following is correct for array initialization?
(A) arr[3][3]={ 1,2,3,2,3,4,3,4,6} (B) arr[3][3]={ {1,2,3},{2,3,4},{3,5,6}}
(C) arr[3][3]={ (1,2,3),(2,3,5),(3,4,6)} (D) All of the above
15. What will be maximum index for the array if it is considered as 1D array?
(A) 6 (B) 7 (C) 8 (D) 9
16. What does &arr represent?
(A) It gives an error (B) It gives the memory location of the index 0
(C) It gives element of 1 index of the array
st (D) None of them
17. What will be the sum of diagonal elements of the array?
(A) 19 (B) 16 (C) 21 (D) None of them
Consider the following figure & answer from 18-23
1. push(7);
2. push(6);
3. pop();
4. push(8);
5. push(2);
6. push(0);
7. pop( );
8. push(3)
9. pop( );
10. show( );
18. Which of the following is correct for line no. 6?
(A) Cannot be inserted because of underflow (B) Cannot be inserted because of overflow
(C) Can be inserted at the top of the stack (D) None of the above
19. Before executing line no. 7, what is the value of Top?
(A) 2 (B) 4 (C) 3 (D) 0
20. After executing line no. 8, what is the value of Top?
(A) 2 (B) 3 (C) 4 (D) 0
21. Which of the following is correct?
(A) 7 is inserted at Top 1 (B) 3 is inserted at Top 3
(C) 0 never gets popped (D) None of them
22. What will be popped in line 9?
(A) 3 (B) 0 (C) 8 (D) 2
23. What is the correct sequence of output for line no. 10?
(A) 7,8,2 (B) 3,2,8,7 (C) 2,8,7 (D) 7,3,2,8
Consider the following array & answer from 24-29
18 22 16 10
24. What is the mid value generated in the first iteration in Binary Search?
(A) 18 (B) 16 (C) 22 (D) None of the above
25. If we apply binary search on the array, without sorting the array, 10 can be found in _____
(A) First iteration (B) Second iteration (C) Third iteration (D) Never
26. What will be the best case for linear search?
(A) Search 18 (B) Search 22 (C) Search 10 (D) Both A & C
27. How many shifts are needed to sort the array using insertion sort?
(A) 5 (B) 6 (C) 8 (D) 10
28. How many comparisons are needed to sort the array using selection sort?
(A) 5 (B) 6 (C) 7 (D) None of the above
Summer 2022-23 CSC 2105 Data Structure Page 2 of 8
SET- A
29. Maximum how many passes are required to sort the array using bubble sort?
(A) 2 (B) 3 (C) 4 (D) None of the above
30. In bubble sort, how many comparisons are needed in pass 2 if the sorting completed in pass 1?
(A) 0 (B) 1 (C) 2 (D) None of the above
Consider the following code & answer from 31-35
1. int value=2, arr[6]={9,3,5,7,2,8};
2. char data='x';
3. int *p, *q; char *r;
4. p=&value; q=arr; r=&data;
5. *p-=1; *r--;
6. cout<< value << " "<< data<< endl;
7. cout<< *p;
8. cout<< *p+2;
9. cout<< *(q+4);
10. cout<< arr[value];
31. What will be output in line 6?
(A) 1 x (B) 1 w (C) 3 x (D) 3w
32. What will be output in line 7?
(A) 1 (B) 2 (C) 3 (D) 4
33. What will be output in line 8?
(A) 1 (B) 3 (C) 5 (D) 7
34. What will be output in line 9?
(A) 2 (B) 4 (C) 6 (D) 8
35. What will be output in line 10?
(A) 3 (B) 5 (C) 7 (D) 9
Part – B (Answer 2 out of 3) Pseudocode Writing [2 x 10 = 20 Marks]
36. Write a pseudocode to find the difference between the average of the diagonal elements and the
average of the boundary elements of a 2D array.
37. Write a pseudocode to sort an array in descending order using insertion sort algorithm.
38. Write pseudocode for the following operations of a stack:
a. isEmpty( ); //checks whether the stack is empty or not
b. isFull( ); //checks whether the stack is full or not
c. push(char element ); //inserts an element in the stack
d. show( ); //prints the stack
Summer 2022-23 CSC 2105 Data Structure Page 3 of 8
SET- A
Summer 2022-23 CSC 2105 Data Structure Page 4 of 8
SET- A
Summer 2022-23 CSC 2105 Data Structure Page 5 of 8
SET- A
Part – C (Answer 2 out of 3) Simulation [2 x 15 = 30 Marks]
39. Consider the following Stack of size 7 and draw the stack for executing the following operations. In
each operation, you must use the modified stack of the previous operation and show the value of top.
i) push(E)
ii) push(C)
T iii)push(H)
I iv) pop( )
G v) push(K)
O vi) push(B)
L
40. Show each simulation step for searching an element M from the following array using Binary Search
algorithm.
B D G I O Q T W
41. Show the simulation steps and complexity analysis for sorting the following array in ascending order
using Bubble Sort algorithm.
S U N D A Y
Summer 2022-23 CSC 2105 Data Structure Page 6 of 8
SET- A
Part – D (Answer All) Analytical Question [1 x 15 = 15 Marks]
The answer of this part will be Evaluated for the following OBE Course Outcome:
CO2: Solve real-life problems using advanced concepts of data structure.
Knowledge and proper use of Data Structure (5) Problem Analysis (5) Solution (5)
Name: ID:
42. Ali is excited about going to the Cattle Market with his father and uncle to buy cows for Eid-ul-Adha.
They plan to buy two similar (in height, weight, color, and breed) cows from a seller. While roaming
around the market, they found a seller who has assigned ratings to his cows based on their height,
weight, color, and breed. Ali along with his father and uncle has decided to buy the two cows having
the minimum difference between their ratings.
Write a pseudocode for Ali to find the minimum difference in ratings between two cows.
Hint:
Assume that the seller has N cows. The rating of a cow c is represented by a double value Ratings[c].
Ali needs to choose 2 cows so that the difference in their rating is minimum.
Sample Input Corresponding Output
N=5
0.01
Ratings [N] = {4.05, 4.17, 4.04, 3.99, 4.13}
[The minimum difference (0.01) can be achieved if the cows with rating 4.05 and 4.04 are chosen.]
Summer 2022-23 CSC 2105 Data Structure Page 7 of 8
SET- A
Summer 2022-23 CSC 2105 Data Structure Page 8 of 8