Question Paper Midterm Algorithm PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Daffodil International University

Department of Computer Science and Engineering


Faculty of Science & Information Technology
Midterm Examination, Fall 2020 @ DIU Blended Learning Center
Course Code: CSE214 (Day), Course Title: Algorithms
Level: 2 Term: 2 Section: PC-A, PC-B
Instructor: SMAH Modality: Open Book Exam
Date: Tuesday 10 NOV, 2020 Time: 09:00am-01:00pm
Four hours (4:00) to support online open/case study-based assessment Marks: 25

Part 01: [marks:05]

What is the time complexity of the following code segment?


(a) [marks:02]
#include<stdio.h>
int main()
{
int i,j,k,n;
scan f("%d" , &n);
for (i = 1 ; i <= n ; i++)
{
for (j = 1 ; j <= n/3 ; j++)
{
printf ("DIU CSE");
}
}
For (k = 1; k <= n ; k++)
{
printf ("BLC");
}
}
(b) [marks:03]
Why do we need performance analysis of Algorithms? Given two Algorithms for a task,
how do we find out which one is better? Write a short discussion with an example of your
own.

Part 02: [marks:10]

Suppose, you are given a character array (called “Full_Name”) which contains your full name. The array
size is 10 and you have to fill up the array using values from your name as follows.
For example, let’s assume your full name is “AMINUL HAQUE” (All Capital) and fill up the
array without any space up to the last index.
Example: AMINUL HAQUE (All Capital)

Page 1 of 2
Index 0 1 2 3 4 5 6 7 8 9
No.

Value A M I N U L H A Q U

Now write your Full Name in all Capital Characters and fill up this “Full_Name” array and write in your
answer script before attempt to answering the following questions.

(a) [Marks: 05] Show the steps for sorting the array using “Quick Sort”. You have to show a
simulation for each iteration step while sorting in alphabetical order.
(b) [Marks: 05] In your sorted array, if you want to search an element from it, then which searching
algorithm you will use here and why. Show steps for searching “Q” in the array.
.

Part 03: [marks:10]

As you may be aware of that during our last DIU ICT Carnival of Daffodil International University, there
was a huge gathering, and like other years, on that day, we face some difficulties while traveling to the
Ashulia campus and also during return from the campus. Though the authority tries to provide sufficient
number of buses, there is always a wastage of bus seats, so many students, later suffer of not getting any
seats. For this year, due to the pandemic, unfortunately we have missed this occasion. However, this year,
we want to make a solution of this problem so in the future we can accommodate more students to their
seats.
Now, would you look at the following figures and provide reasonable solutions using suitable algorithms:
Every bus capacity: 12
Total number of groups: 4
Group sizes will be the addition of “3” with your individual digit of last four digits of your student ID.
For example: if your id is “191-15-2343” then your respective four group sizes will be:
Group 01 size: 2+3=5
Group 02 size: 3+3=6
Group 03 size: 4+3=7
Group 04 size: 3+3=6
Now, using your own student ID, at first, calculate the group sizes for your own. Then find out the
minimum number of the micro-buses for the occasion with your calculated own group sizes:
i. [marks:03] the total number of micro-bus using First-fit algorithm.
ii. [marks:03] the total number of micro-bus using First-fit decreasing algorithm.
iii. [marks:03] the total number of micro-bus using Full-bin packing algorithm.
iv. [marks:01] based on your solutions of 1, 2, and 3, suggest the best algorithm with proper reason.

----The End---

Page 2 of 2

You might also like