Binary MCQ Quiz in मल्याळम - Objective Question with Answer for Binary - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Apr 5, 2025
Latest Binary MCQ Objective Questions
Top Binary MCQ Objective Questions
Binary Question 1:
The recurrence relation that arises in relation with the Complexity of binary search is
Answer (Detailed Solution Below)
Binary Question 1 Detailed Solution
The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(Logn). We basically ignore half of the elements just after one comparison.
1) Compare x with the middle element.
2) If x matches with middle element, we return the mid index.
3) Else If x is greater than the mid element, then x can only lie in right half subarray after the mid element. So we recur for right half.
4) Else (x is smaller) recur for the left half.
The time complexity of Binary Search can be written as
T(n) = T(n/2) + cBinary Question 2:
If node 16 is deleted from the following binary tree and the resulting binary tree is traversed in-order then what would be the sequence in which the nodes would be visited?
Answer (Detailed Solution Below)
Binary Question 2 Detailed Solution
The correct answer is : option 1
Key Points
In-order Traversal:
In-order traversal of a binary tree means: Left Subtree → Root → Right Subtree
Original Tree (Before deletion of node 16):
22 / \ 10 44 \ 16 \ 19
In-order traversal before deletion: 10 → 16 → 19 → 22 → 44
Now delete node 16:
Since node 16 has only one child (19), deletion involves linking node 10 directly to node 19.
Modified Tree (After deletion of node 16):
22 / \ 10 44 \ 19
In-order traversal after deletion:
- Left subtree of 22: Traverse 10 → 19
- Visit root: 22
- Right subtree of 22: 44
Sequence: 10, 19, 22, 44
Correct Option: Option 1) 10, 19, 22, 44
Additional Information
- In-order traversal always visits the left subtree, then the root, then the right subtree.
- When a node with only one child is deleted, its child is directly connected to its parent.
- The resulting structure still maintains the binary search tree (BST) property.
Binary Question 3:
For which of the following tasks, stack is not suitable data structure?
(a) Binary search in an array
(b) Breadth first search
(c) Implementing function calls
(d) Process scheduling
Answer (Detailed Solution Below)
Binary Question 3 Detailed Solution
Concept :
Stack is a data structure in which elements can be inserted and deleted only from one end i.e. top of the stack. It follows the LIFO property i.e. last in first out.
Explanation:
(a) Binary search in an array
Binary search in an array can be performed with the help of stack. Binary search works on the divide and conquer approach and finds the middle element and then perform the search in the left side if element is smaller than the middle element otherwise search proceed in the right of middle element.
(b) Breadth first search
Breadth first search is graph traversal algorithm. It uses queue data structure to traverse the graph or the tree. It is also used to find the connected components in a graph.
(c) Implementing function calls
Function calls are implemented using the stack data structure. As, when a function call arrives then the state or the data currently operated on is stored on the stack where it is resumed after the execution of function call.
(d) Process scheduling
Process scheduling is implemented using the queue data structure . Ready queue is maintained for the processes which are ready for the execution.
Binary Question 4:
The recurrence relation for binary search algorithm is :
Answer (Detailed Solution Below)
Binary Question 4 Detailed Solution
The correct answer is T(n) = T(n/2) O (1).
Key Points
- The binary search algorithm is a search algorithm that finds the position of a target value within a sorted array.
- Binary search works by repeatedly dividing the search interval in half.
- If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half.
- Otherwise, narrow it to the upper half. Repeat until the value is found or the interval is empty.
Additional Information
- The recurrence relation for the binary search algorithm is T(n) = T(n/2) + O(1).
- This is because at each step, the algorithm divides the problem size by 2 (hence T(n/2)) and performs a constant amount of work (O(1)).
- The time complexity of binary search is O(log n) in the worst case.
- Binary search is more efficient than linear search, especially for large datasets.
Binary Question 5:
Let A be an array of 31 numbers consisting of a sequence of 0’s followed by a sequence of 1’s. The problem is to find the smallest index i such that A[i] is 1 by probing the minimum number of locations in A. The worst-case number of probes performed by an optimal algorithm is
Answer (Detailed Solution Below)
Binary Question 5 Detailed Solution
The correct answer is 5
Explanation:
Worst case of the given problem is when a single 0 is followed by all 1’s i.e.
0111111111111……
Also, worst case can also be considered as when all 0’s are followed by single 1.
000000000………………1
Since in both the cases there is a sorted sequence of 0 and 1 and for sorted sequence binary search is preferred.
At each stage, the element index is compared and if it is 1, search towards left and if it is 0 search towards the right.
Total worst-case number of probes performed by an optimal algorithm is = ⌈log2 31⌉ = 5 = 5
Example:
Optimal Algorithm: Binary search
Consider element containing 7 elements
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
Element |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1st probe |
|
|
|
↑ |
|
|
|
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
Element |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
2nd probe |
|
|
|
|
|
↑ |
|
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
Element |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
3rd probe |
|
|
|
|
|
|
↑ |
Maximum probes = ⌈ log27 ⌉ = 3
For 31 elements
Maximum probes = ⌈ log2 31⌉ = 5
Binary Question 6:
The order of the binary search algorithm is _______.
Answer (Detailed Solution Below)
Binary Question 6 Detailed Solution
The order of the binary search algorithm is O(log n).
Key Points
- The binary search algorithm is an efficient algorithm for finding an item from a sorted list of items.
- It works by repeatedly dividing in half the portion of the list that could contain the item, until you've narrowed down the possible locations to just one.
- In each step, the algorithm compares the target value to the middle element of the list.
- If the target value is less than the middle element, the search continues in the lower half of the list; otherwise, it continues in the upper half.
- This process is repeated until the target value is found or the remaining list is empty.
- Because the list is divided in half each time, the time complexity of binary search is O(log n).
Additional Information
- Binary search can only be applied to a list that is sorted. If the list is unsorted, it must be sorted first, which can take O(n log n) time.
- In contrast, linear search runs in O(n) time and does not require the list to be sorted.
- The binary search algorithm is commonly used in computer science, including in applications such as database indexing and algorithmic trading.
- In practical applications, binary search can significantly reduce the time required to search large datasets, making it a valuable tool for optimizing performance.
Binary Question 7:
What is the best-case running time of binary search?
Answer (Detailed Solution Below)
Binary Question 7 Detailed Solution
Binary search algorithm:
Binary search algorithm is used to find an element in an already sorted array.
STEPS 1:
It finds the middle element of the array and compare the element with the element to be searched, if
it matches then return true.
STEPS 2:
If not, then divide the array into two halves in which if element to be search is less than middle
element then search takes place in left part otherwise search in right half.
STEP 3:
Repeat this process, until you get the element.
Explanation:
Best case of Binary search occurs when element to be searched is the middle element of the array.
Then in that case, it just simply compares the element with the middle element, if matches then return
true. Comparing with the one element will take only O(1) time complexity.
Best Case: Search 35 in below give array
11 |
12 |
15 |
24 |
35 |
50 |
51 |
63 |
17 |
T(n) = O(1)
Binary Question 8:
Choose true statement :
I - Binary search is faster than linear search.
II - Binary search may not be applied on all the input lists on which linear search can be applied.
Answer (Detailed Solution Below)
Binary Question 8 Detailed Solution
The correct answer is option 3.
Concept:
Statement 1: Binary search is faster than linear search.
True, Unless the array size is tiny, binary search is faster than linear search. However, sorting the array is required before doing a binary search. In contrast to binary search, there exist specialized data structures created for quick searching, such as hash tables.
Statement 2:Binary search may not be applied on all the input lists on which linear search can be applied.
True, Binary search is applied only on the sorted list it can not apply to an unsorted list. Whereas linear search is applicable for all types of lists. It means the sorted or unsorted type of lists.
Hence the correct answer is Both I and II.
Binary Question 9:
In binary search, the key to be searched is compared with the element in the __________ of a sorted list.
Answer (Detailed Solution Below)
Binary Question 9 Detailed Solution
The correct option is (3)
Concept:-
The binary search algorithm is used to find a specific element in a sorted array. The target value is compared to the array's middle element in a binary search.
Key Points
- Sequential search is substantially less efficient than binary search. The elements must, however, be presorted before using the binary search method.
- It works by dividing the area of the list that could contain the item in half until the number of possible sites is reduced to just one.
- Binary search is an efficient algorithm and is better than linear search in terms of time complexity.
- Because it splits the array into two half as part of the process, it's called binary. A binary search will initially compare the item in the middle of the array to the search terms.
Binary Question 10:
The minimum number of comparisons for a particular record among 32 sorted records through binary search method will be:
Answer (Detailed Solution Below)
Binary Question 10 Detailed Solution
Concept:
Binary search: Binary search follows the divide and conquer approach. To search for an element, first find the middle element, if a match found, then return the location. Otherwise, if the element is less than the middle element search will proceed in the left half, else the search will proceed into the right half.
Explanation:
Recurrence relation for binary search :
T(n) = T(n/2) + 1
Time Complexity of this algorithm: O(log2n)
Here, we have to apply the binary search on 32 elements. So, it will take log232 = 5 comparisons to search for the element.