Skip to content

Algorithms

CSE · Midterm · Spring 24

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

Read the questions as text

Read off the PDF by AI, so it may have mistakes. The PDF is the original.

Daffodil International University Faculty of Science & Information Technology Department of Computer Science and Engineering Mid Semester Examination, Spring-2024 Course Code: CSE213 Course Title: Algorithms Level: 2, Term: 1 Exam Duration: 1.5 Hours Marks: 25 Answer ALL Questions [Optional] [The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.] 1. Analyze the time complexity of the following code: a) for(i=0;i<n;i++i) { sum=sum+i; } for(j=0;j<=n;++j){ sum=sum+j; } b) if(n%2==0) { for(i=1; i<=n; ++i) { for(j=1; j<=n; ++j) { printf("Anything"); } } } else{ for(j=1; j<=n; ++j){ printf("Anything"); } } [2.5 + 2.5] | CO1 2. Apply a sorting algorithm that does not follow the divide and conquer method on the following data to sort them in increasing order and show step by step simulation. [15, 5, 49, 36, 27, 6, 1, 43, 29, 30] [5] | CO2 3. Character | H | E | L | O | A | P | - Frequency | 105 | 25 | 27 | 80 | 14 | 54 | 38 Given the above informative Table if someone wants to send a message "HELLO_APP" Applying Huffman coding techniques what will be the huffman encrypted message [i.e. Character wise encrypted Huffman code]. Show all the necessary steps. [5] | CO2 4. Suppose you are looking for a book in a Library with code number 27. The library has many books and the books are sorted by code number on the bookshelf. Unfortunately you have entered the library at the back side of the library [i.e for the given example below your starting position is in front of Book number 64]. Now you have to find out the book with code 27 and you will be given some Book code numbers. Apply an appropriate algorithm to find out the book as early as possible and show all the necessary steps. [ 64 51 43 42 38 30 27 23 15 7 ] [5] | CO3 5. Kakababu is a famous character in a Bangla short story. Basically he likes adventures and discovering historical and mysterious things. One day he and his nephew Shontu travel in the Arab country and they find a cave that contains some valuable stones. They were very delighted to collect the stones but unfortunately they had only a bag that can carry only 10kg. Shontu is your best friend and Shontu wants help from you to choose the stones that they can carry and make the best profit. Apply an appropriate algorithm to help Shontu. Stones | Value | Available Unit Diamond | 5 | 3 Pearl | 7 | 2 Ruby | 8 | 5 Sapphire | 3 | 4 Emerald | 10 | 1 [NB: They can partially take any stones and the stones are limited.] [5] | CO3