পরীক্ষা আর্কাইভ

৪৯তম বিসিএস ⎯ তথ্য ও যোগাযোগ প্রযুক্তি [২৮১]

পরীক্ষা৪৯তম বিসিএস ⎯ তথ্য ও যোগাযোগ প্রযুক্তি [২৮১]তারিখতারিখ অনির্ধারিতসময়30 minutes৪৫ বৈধ · অসম্পূর্ণ
মোট প্রশ্ন৪৬
সিলেবাস
Exam 11 Data Structures and Algorithms: Internal data representation, Elementary data structures, Advanced data Structures. Techniques for analysis of algorithms, Methods for the design of efficient algorithms. [Source: Class-9 and relevant books]
ঘনত্ব
উত্তর
উত্তরিতবর্তমানপুনরায় দেখুনঅসম্পূর্ণ

৪৯তম বিসিএস ⎯ তথ্য ও যোগাযোগ প্রযুক্তি [২৮১]

৪৯তম বিসিএস ⎯ তথ্য ও যোগাযোগ প্রযুক্তি [২৮১] · তারিখ অনির্ধারিত · ৪৬ প্রশ্ন

.
What is the binary representation of the decimal number 37?
  1. 101100
  2. 110011
  3. 100101
  4. 101010
সঠিক উত্তর:
100101
উত্তর
সঠিক উত্তর:
100101
ব্যাখ্যা

To convert the decimal number 37 to binary, we divide it by 2 and keep track of the remainders. The binary representation of 37 is 100101.

Solution:
37 ÷ 2 = 18 remainder 1
18 ÷ 2 = 9 remainder 0
9 ÷ 2 = 4 remainder 1
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1

Reading the remainders from bottom to top gives 100101.

Source: 
Structured Computer Organization by Andrew S. Tanenbaum

.
In a computer, the internal data is typically represented in:
  1. Decimal format
  2. Hexadecimal format
  3. ASCII format
  4. Binary format
সঠিক উত্তর:
Binary format
উত্তর
সঠিক উত্তর:
Binary format
ব্যাখ্যা

Internally, computers represent all data (whether numbers, text, or other forms) in binary format (using 0s and 1s). This is because binary is the native language of computers, as they use digital circuits with two states (on/off or true/false) to represent information.

Example:
The decimal number 15 is represented in binary as 1111.

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
Which of the following is the correct representation of the number -5 in an 8-bit two's complement system?
  1. 11111011
  2. 11111001
  3. 10000101
  4. 10111001
সঠিক উত্তর:
11111011
উত্তর
সঠিক উত্তর:
11111011
ব্যাখ্যা

In a two's complement system, to represent a negative number:
1. Find the binary representation of the positive number (in this case, 5).
2. Invert all the bits (flip 1's to 0's and 0's to 1's).
3. Add 1 to the result.

Steps to find -5 in 8-bit two's complement:
1. Binary representation of +5:
5 in binary is: 00000101.

2. Invert the bits (find the one's complement of 00000101):
Inverting 00000101 gives: 11111010.

Add 1 to the result:
∴ Adding 1 to 11111010 gives: 11111011.

Thus, the 8-bit two's complement representation of -5 is 11111011.
The right answer is 11111011

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
Which encoding scheme is used to represent characters in a computer?
  1. Binary Coded Decimal (BCD)
  2. ASCII
  3. Gray Code
  4. Excess-3
সঠিক উত্তর:
ASCII
উত্তর
সঠিক উত্তর:
ASCII
ব্যাখ্যা

American Standard Code for Information Interchange (ASCII) is the most common encoding scheme used to represent characters in a computer. It uses 7 or 8 bits to represent each character, allowing for 128 or 256 possible characters, including letters, numbers, and symbols.

Example:
The ASCII code for the character 'A' is 65 (binary: 01000001).
The ASCII code for '1' is 49 (binary: 00110001).

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
What is Excess-3 ?
  1. A method for representing binary numbers
  2. A method of binary-coded decimal (BCD) where each digit is offset by 3
  3. A way to encode negative numbers in binary
  4. A code used to convert text into numbers
সঠিক উত্তর:
A way to encode negative numbers in binary
উত্তর
সঠিক উত্তর:
A way to encode negative numbers in binary
ব্যাখ্যা

Excess-3 (XS-3) is a binary-coded decimal (BCD) code in which each decimal digit is represented by its 4-bit binary equivalent plus 3. This means each digit is "offset by 3" from its actual binary value. The code is commonly used in digital systems for error detection and correction.

Example:
The decimal digit 0 is represented as 0000 in binary, but in Excess-3, it is represented as 0011 (0 + 3).

Excess-3 encoding:
0 → 0011
1 → 0100
2 → 0101
3 → 0110
4 → 0111
5 → 1000
6 → 1001
7 → 1010
8 → 1011
9 → 1100

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
How many bytes are required to store the binary number 110010011011 in a computer?
  1. 1 byte
  2. 2 byte
  3. 3 byte
  4. 4 byte
সঠিক উত্তর:
2 byte
উত্তর
সঠিক উত্তর:
2 byte
ব্যাখ্যা

The binary number 110010011011 is 12 bits long. Since 1 byte = 8 bits, it will require 2 bytes to store it, as 12 bits can be divided into two 8-bit groups (each byte).

Example:
12 bits require 2 bytes since 12 ÷ 8 = 1.5 (round up to the next byte, which is 2 bytes).

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
In a computer system, how is negative data typically represented in the internal memory?
  1. Sign magnitude
  2. Two's complement
  3. One's complement
  4. Excess-3
সঠিক উত্তর:
Two's complement
উত্তর
সঠিক উত্তর:
Two's complement
ব্যাখ্যা

The most common method for representing negative numbers in internal computer memory is two's complement. This system allows for easier arithmetic operations and avoids the issues associated with sign magnitude and one's complement, such as the representation of both positive and negative zero.

Example:
In 8-bit two's complement, the negative number -5 is represented as 11111011.

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
Which of the following is not a key characteristic of an Abstract Data Type (ADT)?
  1. It encapsulates data
  2. It defines the operations that can be performed on the data
  3. It specifies the exact implementation of the data structure
  4. It can be implemented in various ways
সঠিক উত্তর:
It specifies the exact implementation of the data structure
উত্তর
সঠিক উত্তর:
It specifies the exact implementation of the data structure
ব্যাখ্যা

An ADT does not specify the exact implementation of a data structure. Instead, it defines the logical behavior of the data and the operations that can be performed. The implementation is left to the programmer and can vary.

Example:
The List ADT might define operations like insert and delete but does not specify whether the list is implemented using an array, a linked list, or some other structure.

Source: Structured Computer Organization by Andrew S. Tanenbaum

.
Which of the following operations is commonly associated with the Stack ADT?
  1. Enqueue and Dequeue
  2. Insert and Remove
  3. Push and Pop
  4. Add and Delete
সঠিক উত্তর:
Push and Pop
উত্তর
সঠিক উত্তর:
Push and Pop
ব্যাখ্যা

The Stack ADT defines two primary operations:
Push: Adds an element to the top of the stack.
Pop: Removes the top element from the stack.

Example:
For a stack containing the elements [1, 2, 3], if we perform a Pop operation, the stack becomes [1, 2]. If we Push a 4, the stack becomes [1, 2, 4].

Source: Structured Computer Organization by Andrew S. Tanenbaum

১০.
Which of the following data structures is most commonly used to implement a Queue ADT?
  1. Stack
  2. Array
  3. Linked list
  4. Tree
সঠিক উত্তর:
Array
উত্তর
সঠিক উত্তর:
Array
ব্যাখ্যা

A Queue ADT can be implemented using either an array or a linked list, but arrays are commonly used due to their simplicity. Operations such as enqueue (insert) and dequeue (remove) are easily managed with an array, although for dynamic resizing, a linked list is often more efficient.

Example:
A queue can be represented as an array with pointers (or indices) to keep track of the front and rear of the queue for efficient enqueue and dequeue operations.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১১.
Which of the following is an example of an Abstract Data Type (ADT) in real-world applications?
  1. An array
  2. A stack in a browser for back-and-forth navigation
  3. A linked list used in database management systems
  4. A table in a relational database
সঠিক উত্তর:
A stack in a browser for back-and-forth navigation
উত্তর
সঠিক উত্তর:
A stack in a browser for back-and-forth navigation
ব্যাখ্যা

A stack in a browser is a real-world example of an Abstract Data Type (ADT). The back and forward buttons of a browser operate using a stack data structure where pages are pushed onto the stack when navigating and popped when moving backward or forward through history.

Example:
When you navigate through webpages, the browser pushes the page onto the stack, and when you click back, the browser pops the previous page off the stack to display it.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১২.
Which of the following is a characteristic of an array in a programming language?
  1. Elements are stored in a non-contiguous memory block
  2. The size of an array is fixed after its declaration
  3. Arrays can store only data of the same data type
  4. All of the above
অনির্ধারিত
ব্যাখ্যা

সঠিক উত্তর খ) ও গ)। 
ক) অপশনটি ভুল থাকায় All of the above সঠিক উত্তর নেওয়া যাচ্ছে না। 
প্রশ্ন অনুসারে অপশনে একাধিক সঠিক উত্তর থাকায় প্রশ্নটি বাতিল করা হয়েছে। 
-----------------

An array is a data structure that:
Stores elements in contiguous memory locations, which allows for fast access.
Has a fixed size once it is declared (it cannot be resized during execution).
Stores elements of the same type (such as integers, characters, or floats).

Example:
In languages like C or Java, an array is declared with a specific size, and all elements in the array must be of the same data type, like int[] or float[].

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৩.
In a zero-based indexed array, what is the index of the last element of an array with 10 elements?
  1. 9
  2. 10
  3. 0
  4. 1
সঠিক উত্তর:
9
উত্তর
সঠিক উত্তর:
9
ব্যাখ্যা

In a zero-based indexed array, the indexing starts from 0. Therefore, an array with 10 elements will have the indices 0 through 9. The last element will be at index 9.

Here's the full list of indices for an array with 10 elements and zero-based indexing:
The first element is at index 0.
The second element is at index 1.
The third element is at index 2.
The fourth element is at index 3.
The fifth element is at index 4.
The sixth element is at index 5.
The seventh element is at index 6.
The eighth element is at index 7.
The ninth element is at index 8.
The tenth (last) element is at index 9.

The index of the last element of an array with 10 elements is 9.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৪.
Which of the following operations can be performed on an array?
  1. Insertion at the beginning of the array
  2. Deletion at the end of the array
  3. Accessing an element using its index
  4. All of the above
সঠিক উত্তর:
Accessing an element using its index
উত্তর
সঠিক উত্তর:
Accessing an element using its index
ব্যাখ্যা

Arrays provide constant time access to their elements using an index. However, insertion and deletion in an array are typically not efficient. Insertion and deletion at the beginning or middle require shifting elements, which can be slow. Accessing elements via indices is efficient because of the contiguous memory structure.

Example:
You can access the 3rd element in an array using its index arr[2] in 0-based indexing.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৫.
Which of the following is true about multidimensional arrays?
  1. Multidimensional arrays are arrays of arrays.
  2. Multidimensional arrays can only be 2-dimensional.
  3. The size of a multidimensional array can be dynamically allocated.
  4. Multidimensional arrays can only store integers.
সঠিক উত্তর:
Multidimensional arrays are arrays of arrays.
উত্তর
সঠিক উত্তর:
Multidimensional arrays are arrays of arrays.
ব্যাখ্যা

A multidimensional array is essentially an array of arrays. Each element in a multidimensional array is itself an array. For example, a 2D array can be seen as an array of 1D arrays.

Example:
In a 2D array arr[3][4], the array arr contains 3 rows, and each row is an array with 4 columns.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৬.
Which of the following searching algorithms can be used to search for an element in an unsorted array?
  1. Binary Search
  2. Linear Search
  3. Jump Search
  4. Interpolation Search
সঠিক উত্তর:
Linear Search
উত্তর
সঠিক উত্তর:
Linear Search
ব্যাখ্যা

Linear Search is used to find an element in an unsorted array by checking each element in sequence. Since the array is unsorted, there is no way to efficiently narrow down the search space like with binary search.

Example:
For an array arr = [4, 2, 5, 1, 3], linear search will check each element sequentially until it finds the desired element.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৭.
In which of the following cases would you prefer to use an array over a linked list?
  1. When the number of elements is unknown at compile time
  2. When frequent insertions and deletions are required
  3. When constant-time access to elements is required
  4. When memory efficiency is a priority
সঠিক উত্তর:
When constant-time access to elements is required
উত্তর
সঠিক উত্তর:
When constant-time access to elements is required
ব্যাখ্যা

Arrays allow for constant-time access (O(1)) to elements, which makes them ideal for scenarios where fast access to elements is needed by index. This is because arrays use contiguous memory, and accessing an element at a given index is very efficient.

Example:
If you need to frequently access elements in a random order or by index, an array is more efficient than a linked list.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৮.
Which of the following is true for a list data structure?
  1. A list is a collection of elements with a fixed size.
  2. A list allows random access to its elements.
  3. A list stores elements of only one type.
  4. A list is a linear data structure where elements can be added or removed dynamically.
সঠিক উত্তর:
A list is a linear data structure where elements can be added or removed dynamically.
উত্তর
সঠিক উত্তর:
A list is a linear data structure where elements can be added or removed dynamically.
ব্যাখ্যা

A list is a linear data structure that allows dynamic resizing, meaning elements can be added or removed at any position. It does not necessarily store elements of a fixed type (like arrays), and while it allows access to elements, it does not guarantee random access in all implementations (especially in linked lists).

Example:
In a Python list, elements can be added or removed dynamically using append(), pop(), or insert() methods.

Source: Structured Computer Organization by Andrew S. Tanenbaum

১৯.
Which of the following operations can be performed efficiently on a linked list?
  1. Random access to elements by index
  2. Insertion and deletion at the beginning or middle
  3. Sorting the elements in place
  4. Accessing elements in constant time
সঠিক উত্তর:
Insertion and deletion at the beginning or middle
উত্তর
সঠিক উত্তর:
Insertion and deletion at the beginning or middle
ব্যাখ্যা

Linked lists allow efficient insertion and deletion operations at the beginning or middle of the list. Since nodes in a linked list are connected by pointers, adding or removing nodes does not require shifting elements, unlike in an array. However, random access and sorting in linked lists are less efficient compared to arrays.

Example:
In a singly linked list, inserting a new node at the beginning requires only changing the head pointer, which is an O(1) operation.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২০.
A circular linked list differs from a regular linked list in that:
  1. It has no pointers between the nodes
  2. The last node points back to the first node
  3. It can store elements of different data types
  4. It does not require any pointers
সঠিক উত্তর:
The last node points back to the first node
উত্তর
সঠিক উত্তর:
The last node points back to the first node
ব্যাখ্যা

In a circular linked list, the last node does not point to null, as in a regular linked list. Instead, it points back to the first node, forming a circle. This makes traversal in the list easier in certain applications, as you can loop through the list indefinitely without needing to check for the end.

Example:
A circular linked list where the last node points back to the first node is useful in applications like round-robin scheduling.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২১.
Which of the following is a common way to implement a stack?
  1. Using a dynamic array
  2. Using a linked list
  3. Using a static array
  4. All of the above
সঠিক উত্তর:
All of the above
উত্তর
সঠিক উত্তর:
All of the above
ব্যাখ্যা

A stack can be implemented in various ways, including:
Dynamic array: A stack can be implemented using an array with dynamic resizing.
Linked list: A stack can also be implemented using a linked list, where each node represents an element, and the head of the list represents the top of the stack.
Static array: A stack can be implemented using a static array, with a pointer or index to track the top of the stack.

Example:
A stack implemented with a linked list will dynamically allocate memory as elements are pushed, while an array-based stack may use a fixed amount of memory or grow dynamically if necessary.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২২.
Which of the following best defines a queue?
  1. A data structure that follows Last In, First Out (LIFO) order
  2. A data structure that allows insertion and deletion at any position
  3. A data structure that follows First In, First Out (FIFO) order
  4. A data structure that stores only one type of data
সঠিক উত্তর:
A data structure that follows First In, First Out (FIFO) order
উত্তর
সঠিক উত্তর:
A data structure that follows First In, First Out (FIFO) order
ব্যাখ্যা

A queue is a linear data structure that follows the First In, First Out (FIFO) principle. This means that the element added first (enqueued) is the first to be removed (dequeued).

Example:
In a queue of people waiting for a bus, the first person to enter the queue is the first to leave.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৩.
Which of the following operations is performed on a queue?
  1. Enqueue and Dequeue 
  2. Insert and Remove
  3. Push and Pop
  4. Add and Delete
সঠিক উত্তর:
Enqueue and Dequeue 
উত্তর
সঠিক উত্তর:
Enqueue and Dequeue 
ব্যাখ্যা

The primary operations of a queue are:
Enqueue: Adding an element to the rear of the queue.
Dequeue: Removing an element from the front of the queue.

Example:
In a queue, if you enqueue elements 5, 10, and 15, the front of the queue will have 5 and the rear will have 15. Dequeuing will remove 5.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৪.
Which of the following is the most efficient implementation for a queue that allows both insertion and deletion in constant time?
  1. Using a singly linked list
  2. Using a doubly linked list
  3. Using an array
  4. Using a binary tree
সঠিক উত্তর:
Using a singly linked list
উত্তর
সঠিক উত্তর:
Using a singly linked list
ব্যাখ্যা

A singly linked list allows both insertion at the rear (enqueue) and deletion at the front (dequeue) in O(1) time. The front pointer is used to delete elements, and the rear pointer is used to insert elements, ensuring constant time complexity for both operations.

Example:
In a linked list-based queue, you can easily add an element at the end by linking it to the last node and remove the element from the front by adjusting the front pointer.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৫.
Which of the following is an example of a real-world application that uses a queue?
  1. Undo/Redo operations in a text editor
  2. People waiting in line at a ticket counter
  3. Memory allocation in a computer
  4. Sorting data in a list
সঠিক উত্তর:
People waiting in line at a ticket counter
উত্তর
সঠিক উত্তর:
People waiting in line at a ticket counter
ব্যাখ্যা

The queue is a natural representation of the First-In, First-Out (FIFO) principle, which describes how elements are processed in the order they arrive. A queue is used in scenarios like a line at a ticket counter, where the first person in line is the first to be served.

Example:
At a bank, customers stand in a line (queue) and are served in the order they arrived.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৬.
Which of the following is a feature of a priority queue?
  1. The elements are processed in the order they arrive
  2. The elements are processed based on their priority
  3. It follows the Last-In, First-Out (LIFO) principle
  4. It can only store integer data
সঠিক উত্তর:
The elements are processed based on their priority
উত্তর
সঠিক উত্তর:
The elements are processed based on their priority
ব্যাখ্যা

A priority queue is a type of queue where each element has a priority. Elements with higher priority are dequeued before elements with lower priority, regardless of their arrival order. Priority queues are typically implemented using a heap or a sorted list.

Example:
In a hospital emergency room, patients with life-threatening conditions are treated first, regardless of their arrival time.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৭.
Which of the following is true about a binary tree?
  1. Each node has at most one child
  2. Each node has at most two children
  3. Each node has exactly two children
  4. Each node can have more than two children
সঠিক উত্তর:
Each node has at most two children
উত্তর
সঠিক উত্তর:
Each node has at most two children
ব্যাখ্যা

In a binary tree, each node can have at most two children: a left child and a right child. Binary trees are commonly used in various applications such as searching, sorting, and expression parsing.

Example:
A simple binary tree could look like this:
    1
   / \
  2   3

Node 1 has two children, 2 and 3.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৮.
What is the maximum number of nodes at level n in a binary tree?
  1. 2n
  2. 2n - 1
  3. n2
  4. n
সঠিক উত্তর:
2n
উত্তর
সঠিক উত্তর:
2n
ব্যাখ্যা

In a binary tree, each node can have at most two children, so at level n (starting from level 0), the maximum number of nodes is 2n. This gives the maximum breadth of the tree at that level.

Example:
At level 0, there is 1 node (the root).
At level 1, there are at most 2 nodes.
At level 2, there are at most 4 nodes, and so on.

Source: Structured Computer Organization by Andrew S. Tanenbaum

২৯.
Which of the following is true for a min-heap?
  1. The root node has the maximum value.
  2. Every node's value is less than or equal to the values of its children.
  3. The root node has the minimum value.
  4. The tree is unsorted but balanced.
সঠিক উত্তর:
The root node has the minimum value.
উত্তর
সঠিক উত্তর:
The root node has the minimum value.
ব্যাখ্যা

A min-heap is a complete binary tree where:
1. The root node contains the minimum value.
2. The value of each node is less than or equal to the values of its children (this property holds recursively for all nodes in the tree).

Example:
In a min-heap:
     10
    /  \
   20   30
  /  \
 40   50

Source: Data Structures and Algorithms by Andrew S. Tanenbaum

৩০.
In a B-tree, which of the following is true about its nodes?
  1. Each node can have only two children.
  2. Each node can have multiple keys and child pointers, making it suitable for large datasets.
  3. The B-tree is always binary and requires rebalancing after every insertion.
  4. Nodes in a B-tree are not allowed to have duplicates.
সঠিক উত্তর:
Each node can have multiple keys and child pointers, making it suitable for large datasets.
উত্তর
সঠিক উত্তর:
Each node can have multiple keys and child pointers, making it suitable for large datasets.
ব্যাখ্যা

A B-tree is a self-balancing tree data structure that allows nodes to store multiple keys and child pointers. The tree is designed to be efficient for systems that read and write large blocks of data (like database systems and file systems). B-trees allow quick search, insertion, and deletion operations while maintaining balance.

Example:
A B-tree with order 3 can have 2 keys and 3 children in each node, and the tree remains balanced even as elements are inserted or deleted.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩১.
Which of the following is a feature of a hash table?
  1. It stores elements in sorted order.
  2. It uses a hash function to map keys to indices in an array.
  3. It provides fast access by index, like an array.
  4. It allows storing only unique elements.
সঠিক উত্তর:
It uses a hash function to map keys to indices in an array.
উত্তর
সঠিক উত্তর:
It uses a hash function to map keys to indices in an array.
ব্যাখ্যা

A hash table is a data structure that uses a hash function to map keys to indices in an array, allowing for fast access, insertion, and deletion operations (on average, O(1) time complexity). The hash function takes a key and computes an index where the corresponding value can be stored.

Example:
In a hash table storing phone numbers, a key like "John" might hash to index 5 in an array, where the phone number associated with John can be stored.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩২.
Which of the following time complexities is considered the most efficient for an algorithm that sorts an array?
  1. O(n2)
  2. O(log n)
  3. O(n log n)
  4. O(n)
সঠিক উত্তর:
O(n log n)
উত্তর
সঠিক উত্তর:
O(n log n)
ব্যাখ্যা

For comparison-based sorting algorithms, the best time complexity is O(n log n). Algorithms like Merge Sort, Quick Sort, and Heap Sort achieve this time complexity, which is much more efficient than O(n^2) (like Bubble Sort and Selection Sort) for large input sizes.

Example:
Merge Sort and Quick Sort both have an average-case time complexity of O(n log n).

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৩.
Which technique is used to solve the recurrence relation for the time complexity of a recursive algorithm?
  1. Divide and conquer
  2. Master Theorem
  3. Greedy method
  4. Dynamic programming
সঠিক উত্তর:
Master Theorem
উত্তর
সঠিক উত্তর:
Master Theorem
ব্যাখ্যা

The Master Theorem is a tool used to analyze the time complexity of divide-and-conquer recursive algorithms. It provides a straightforward method for solving recurrences of the form,

T(n)=aT(n/b)+f(n)

where a, b, and f(n) are constants.

Example:
Merge Sort has a recurrence relation:
T(n)=2T(n/2)+O(n)

Using the Master Theorem, we can easily determine that the time complexity is O(n log n).

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৪.
What is the space complexity of an algorithm that uses a constant amount of extra space, regardless of the input size?
  1. O(1)
  2. O(n)
  3. O(n2)
  4. O(log n)
সঠিক উত্তর:
O(1)
উত্তর
সঠিক উত্তর:
O(1)
ব্যাখ্যা

Space complexity measures the amount of memory an algorithm uses as a function of the input size. An algorithm that uses a constant amount of extra space regardless of the input size has a space complexity of O(1), meaning it does not require additional space as the input grows.

Example:
An algorithm that swaps two variables in place uses a constant amount of memory and has a space complexity of O(1).

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৫.
What is amortized analysis used for in algorithm design?
  1. To analyze the average time complexity of an algorithm
  2. To analyze the worst-case time complexity of an algorithm
  3. To determine the total time complexity of an algorithm across multiple operations
  4. To analyze only the first operation in an algorithm
সঠিক উত্তর:
To determine the total time complexity of an algorithm across multiple operations
উত্তর
সঠিক উত্তর:
To determine the total time complexity of an algorithm across multiple operations
ব্যাখ্যা

Amortized analysis is used to determine the average time per operation over a sequence of operations, even if some individual operations are expensive. It is useful for algorithms where most operations are inexpensive but occasionally one operation might be costly.

Example:
In the dynamic array implementation, append operations are generally O(1), but occasionally when the array needs to be resized, the operation becomes O(n). Amortized analysis helps show that the average cost per operation is still O(1) over multiple operations.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৬.
Which of the following algorithms is an example of a divide and conquer algorithm?
  1. Quick Sort
  2. Merge Sort
  3. Both of Merge Sort and Quick Sort
  4. None of above 
সঠিক উত্তর:
Merge Sort
উত্তর
সঠিক উত্তর:
Merge Sort
ব্যাখ্যা

Divide and conquer is a problem-solving technique where the problem is divided into smaller subproblems, each of which is solved recursively. The solutions to the subproblems are then combined to solve the original problem. Examples of divide and conquer algorithms include:
Quick Sort: Divides the array based on a pivot and sorts the subarrays.
Merge Sort: Divides the array in half, recursively sorts, and merges the results.
Binary Search: Divides the search space in half at each step.

Example:
Merge Sort breaks an array into smaller subarrays, recursively sorts them, and merges them back together to form the sorted array.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৭.
Who guarantees finding the best solution by systematically exploring all possibilities?
  1. Heuristic algorithms
  2. Genetic algorithms
  3. Brute force algorithms
  4. Approximation algorithms
সঠিক উত্তর:
Brute force algorithms
উত্তর
সঠিক উত্তর:
Brute force algorithms
ব্যাখ্যা

Brute force algorithms guarantee finding the best solution because they systematically explore all possible solutions to a problem, ensuring that no possible solution is missed. The downside of brute force algorithms is that they can be very inefficient, especially when the problem size is large, as they may require checking a vast number of possibilities.

Example:
Problem: Find the smallest subset with sum = target.
Brute force: Try all subsets → guaranteed exact solution.
Heuristic/Genetic/Approximation: May find a good solution faster, but not always optimal.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৮.
Which of the following is used in branch and bound to ensure that non-promising branches are discarded?
  1. A branching factor
  2. A lower bound
  3. A solution space tree
  4. A priority queue
সঠিক উত্তর:
A lower bound
উত্তর
সঠিক উত্তর:
A lower bound
ব্যাখ্যা

The lower bound is a crucial part of the branch and bound method. It is used to evaluate the best possible solution that can be obtained from a given node or partial solution. If the lower bound for a node is higher than the best solution already found, that branch is discarded (pruned) because it cannot yield a better solution.

Example:
In the Knapsack problem, when selecting items for the knapsack, a lower bound on the total value is calculated for the current set of items. If the bound is less than the best known solution, further exploration of that branch is avoided.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৩৯.
Which of the following does solve the Knapsack Problem?
  1. Dynamic Programming
  2. Greedy Algorithm
  3. Backtracking
  4. All of the above
সঠিক উত্তর:
All of the above
উত্তর
সঠিক উত্তর:
All of the above
ব্যাখ্যা

The Knapsack Problem is a classic problem in optimization, where the goal is to select items from a set of items, each with a weight and a value, to maximize the total value while staying within a weight limit.
There are different approaches to solve the Knapsack Problem:
Dynamic Programming (DP):
This is the most widely used approach for the 0/1 Knapsack Problem, especially when the problem involves finding the optimal solution. It systematically builds solutions for smaller sub-problems and uses them to construct the solution for larger sub-problems.
• Time complexity is O(nW), where n is the number of items and W is the capacity of the knapsack.

Greedy Algorithm:
• A greedy algorithm can be used for the Fractional Knapsack Problem (where you can take fractions of items). It selects items based on their value-to-weight ratio, choosing the highest ratio first.
• This approach does not guarantee an optimal solution for the 0/1 Knapsack Problem but works well for the fractional version.

Backtracking:
Backtracking is an exhaustive search method that explores all possible combinations of items. While this approach will always find the optimal solution for the 0/1 Knapsack Problem, it is less efficient than dynamic programming for large inputs.

Upshot:
For 0/1 Knapsack, Dynamic Programming and Backtracking are both correct approaches and for Fractional Knapsack, Greedy Algorithm is the most efficient approach.

Source: Data Structures and Algorithms by Andrew S. Tanenbaum

৪০.
Which of the following problems can be solved using the branch and bound technique?
  1. The Travelling Salesman Problem (TSP)
  2. The Knapsack Problem
  3. Integer Programming Problems
  4. All of the above
সঠিক উত্তর:
All of the above
উত্তর
সঠিক উত্তর:
All of the above
ব্যাখ্যা

Branch and bound is a general algorithmic method used for solving optimization problems, especially those that are combinatorial in nature. It can be applied to a wide range of problems, including:
The Travelling Salesman Problem (TSP), where the goal is to find the shortest possible route that visits all cities.
The Knapsack Problem, where the goal is to maximize the value of items packed into a knapsack with a weight constraint.
Integer Programming Problems, where variables must be integers and the objective is to find the optimal solution under given constraints.

Example:
In the Knapsack problem, branch and bound can be used to explore combinations of items and prune branches that cannot yield a better total value than the best known solution.

Source: Data Structures and Algorithms by Andrew S. Tanenbaum

৪১.
What is the relationship between lower bound and Big-O notation?
  1. Big-O notation represents the best-case performance of an algorithm.
  2. Lower bound is represented by Big-O notation.
  3. Lower bound is represented by Big-Ω notation, while Big-O notation represents the upper bound.
  4. Big-O notation represents the worst-case performance, while the lower bound is irrelevant in algorithm analysis.
সঠিক উত্তর:
Lower bound is represented by Big-Ω notation, while Big-O notation represents the upper bound.
উত্তর
সঠিক উত্তর:
Lower bound is represented by Big-Ω notation, while Big-O notation represents the upper bound.
ব্যাখ্যা

In algorithm analysis:
• Big-O notation describes the upper bound of an algorithm's running time, representing the worst-case scenario.
• Big-Ω (Big-Omega) notation describes the lower bound, representing the best-case or minimum time an algorithm will take for any input size.

Example:
For Merge Sort, the upper bound is O(n log n), and the lower bound (for comparison-based sorting) is Ω(n log n).

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৪২.
What does the lower bound of an optimization problem indicate?
  1. The maximum value achievable by the algorithm
  2. The number of operations required to solve the problem
  3. The worst-case time complexity of the problem
  4. The best possible solution that can be obtained for any input
সঠিক উত্তর:
The best possible solution that can be obtained for any input
উত্তর
সঠিক উত্তর:
The best possible solution that can be obtained for any input
ব্যাখ্যা

For optimization problems, the lower bound represents the best possible value or solution that can be achieved, regardless of the algorithm used. This provides a benchmark to evaluate the performance of algorithms and shows if the problem can be solved optimally.

Example:
For the Travelling Salesman Problem (TSP), the lower bound is the shortest possible route that visits each city exactly once. The lower bound helps in estimating how far a given solution is from the optimal one.

Source: Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein

৪৩.
Which of the following is the simplified form of the expression: (6x2 + 3x) /3x
  1. 2x + 1
  2. 2x2 + 1
  3. 2x + 3
  4. 2x2 + 3
সঠিক উত্তর:
2x + 1
উত্তর
সঠিক উত্তর:
2x + 1
ব্যাখ্যা

The expression simplifies by dividing both terms in the numerator by 3x.
Here, 
 (6x2 + 3x) /3x = 6x2 /3x + 3x /3x
= 2x + 1
The right answer is 2x + 1.

Source: Data Structures and Algorithm Analysis in C by Mark Allen Weiss

৪৪.
Which of the following is the factored form of the expression: x2 − 5x + 6 
  1. (x−3)(x−2)
  2. (x−1)(x−6)
  3. (x−4)(x+1)
  4. (x−5)(x+1)
সঠিক উত্তর:
(x−3)(x−2)
উত্তর
সঠিক উত্তর:
(x−3)(x−2)
ব্যাখ্যা

The given quadratic expression can be factored as
x2−5x+6
= x2−2x−3x+6
= x(x−2) - 3(x−2)
= (x−2)(x−3)

To verify, expand the factors:
(x−3)(x−2)
= x2−2x−3x+6
= x2−5x+6

The right answer is (x−2)(x−3)

Source: Data Structures and Algorithm Analysis in C by Mark Allen Weiss

৪৫.
Solve the following system of equations:
3x+4y=18
5x−2y=4
  1. x=1, y=2
  2. x=2, y=1
  3. x=2, y=3
  4. x=3, y=2
সঠিক উত্তর:
x=2, y=3
উত্তর
সঠিক উত্তর:
x=2, y=3
ব্যাখ্যা

To solve the system, use the substitution method or the elimination method.
From the first equation, solve for x:
      3x+4y=18
or, 3x = 18-4y
∴ x = (18-4y) /3

From substitute this into the second equation,
      5 ×  (18-4y) /3 - 2y = 4
or, (90 -20y) /3 -2y =4
or, (90−20y−6y) /3 = 4
or, 90 -20y - 6y = 4 × 3 
or, 90 -26y = 12
or, 26y = 90-12
or, 26y = 78
or, y = 78/26
∴ y = 3

Substitute y=3 into x = (18-4y) /3 :
∴ x = (18 - 4× 3 ) /3
     = (18 - 12 ) /3
     =  6/3
    = 2

So, x=2 and y=3.

Source: Data Structures and Algorithm Analysis in C by Mark Allen Weiss

৪৬.
If a directed acyclic graph (DAG) has multiple valid topological sorts, what does it indicate?
  1. The graph has cycles.
  2. The graph has no valid topological sort.
  3. The graph cannot have multiple valid topological sorts.
  4. The graph has multiple independent branches that can be ordered in different ways.
সঠিক উত্তর:
The graph has multiple independent branches that can be ordered in different ways.
উত্তর
সঠিক উত্তর:
The graph has multiple independent branches that can be ordered in different ways.
ব্যাখ্যা

A DAG may have multiple valid topological sorts if there are independent sets of vertices that do not have dependencies on each other. In such cases, the order of those independent vertices can vary, leading to multiple valid topological orderings.

Example:
In a graph representing tasks A, B, and C, where A must be completed before B, and C is independent of both, the valid topological sorts could be A, B, C or A, C, B.

Source: Data Structures and Algorithms by Andrew S. Tanenbaum