Searching MCQ Quiz in தமிழ் - Objective Question with Answer for Searching - இலவச PDF ஐப் பதிவிறக்கவும்
Last updated on Apr 11, 2025
Latest Searching MCQ Objective Questions
Top Searching MCQ Objective Questions
Searching Question 1:
A _______ is an ordered collection of finite, homogeneous data elements.
Answer (Detailed Solution Below)
Searching Question 1 Detailed Solution
Concept:
Homogeneous data structure (HDS):
- HDS that contains only similar type of data like only integers or only float values.
- Basic example of Homogeneous data structure is Array.
Explanation
In question we required ordered finite HDS which is nothing but Array but Array is not present in the
Options so we have to choose best option among them Let’s take option wise.
Option 1: Linked list
Linked list is HDS but not finite because linked list size is decided on Run time.
Option 2: Graph
Graph is HDS but not finite because Graph size is decided on Run time.
Option 3: Tree
Tree is HDS but not finite because Tree size is decided on Run time.
Option 4: Hash Table
Hash table is ordered and finite data structure (Size is decided on Compile time ).
Hence option 4 is the Best option to choose for the answer.
Searching Question 2:
What is the best-case running time of binary search?
Answer (Detailed Solution Below)
Searching Question 2 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)
Searching Question 3:
Which of the following behaviour takes smallest time in linear serach ?
Answer (Detailed Solution Below)
Searching Question 3 Detailed Solution
The correct answer is option 1.
Concept:
Linear search:
A linear search, often known as a sequential search, is a technique for locating an element in a list. It systematically verifies each element of the list until a match is discovered or the entire list has been searched.
Algorithm:
linear_search(int a[], int n, int X)
{
for (int i = 0; i < n; i++)
{
if (a[i] == X)
return i+1;
}
}
Explanation:
Best case:
The best case in the Linear Search Algorithm happens when the item to be found is at the beginning of the Array. If the element is found at starting of the array the linear search successful and comes out from the loop. Hence this behavior takes less time when compared to other behaviors.
Worst-case:
In the Linear Search Algorithm, the worst-case scenario happens when the item to be found is at the end of the Array or the element is not present in the array. Hence the linear search compares each element till the end. So it takes maximum time behavior in linear search.
Average case:
In the Linear Search Algorithm, the average scenario happens when the item to be found is somewhere in the center of the Array.
Hence the correct answer is a searching element is at beginning of the array.
Searching Question 4:
The average number of comparisions performed in sequencial search on a list of n elements is
Answer (Detailed Solution Below)
Searching Question 4 Detailed Solution
The average number of comparisons in a sequential search is \({(N+1)} \over 2\) where N is the size of the array.
If the element is in the 1st position, the number of comparisons will be 1,
the element is in the 2nd position, the number of comparisons will be 2,
the element is in the 3rd position, the number of comparisons will be 3,
the element is in the 4th position, the number of comparisons will be 4, .....
if the element is in the last position, the number of comparisons will be N.
So Total number of comparisons are= (1+2+3+4+5+...+N)
The total number of comparisons are=\({N(N+1)} \over 2\)
The average number of comparisons in a sequential search is \({N(N+1)} \over 2 \times N\)
Hence the correct answer is \({(N+1)} \over 2\)
Searching Question 5:
Which collision resolution technique involves placing collided elements in the next available empty slot in the hash table?
Answer (Detailed Solution Below)
Searching Question 5 Detailed Solution
The correct answer is Linear probing
Key Points
- Linear Probing:
- When a collision occurs (two elements hash to the same location), linear probing involves placing the collided element in the next available (unoccupied) slot in the hash table.
- If that slot is also occupied, it continues to search for the next empty slot in a linear fashion (moving one slot at a time) until an empty slot is found.
- Linear probing can lead to clustering, where consecutive elements form clusters in the hash table.
Additional Information
- Quadratic Probing:
- Similar to linear probing, but instead of moving one slot at a time, quadratic probing uses a quadratic function to determine the next position to check.
- If the slot at the hash index is occupied, it checks slots at positions incremented by successive squares.
- Quadratic probing helps to reduce clustering compared to linear probing.
- Separate Chaining:
- Instead of placing collided elements in the next available slot in the hash table, separate chaining involves maintaining a linked list at each slot in the hash table.
- When a collision occurs, the collided elements are added to the linked list at that slot.
- Each slot contains a separate data structure (like a linked list or a tree) to handle collisions.
- Double Hashing:
- In double hashing, a secondary hash function is used to determine the step size between probe attempts.
- If a collision occurs, the algorithm uses the secondary hash function to calculate a new index to probe.
- This helps to avoid clustering and provides a more systematic way to find an empty slot.
Searching Question 6:
Which of the following searching technique does not get affected on increasing the size of search list.
Answer (Detailed Solution Below)
Searching Question 6 Detailed Solution
The correct option is Search by Hashing.
CONCEPT:
In linear search, every element of a given list is compared one by one with the given key without skipping any element.
It is useful when we need to search for an item in a small unsorted list, but the time taken to search the list increases as the size of the list increases.
For example, consider a list of length 5 and the key element is present at the end of this list. Number of comparisons required to search the key element = size of list i.e 5
If we increase the size of the same list (say 15) and the key element is present at the end of this list. Number of comparisons required to search the key element = size of list i.e 15
In binary search, the key to be searched is compared with the middle element of a sorted list, If the element at the middle position:
i) Matches the key the search is successful
ii) Is greater than the key then the key element may be present in the left part of the list
iii) Is smaller than the key, then the key element may be present in the right part of the list
This process continues till the element is found or the list is traversed completely.
Thus the time taken to search the list increases as the size of the list increases. But it will not be as large as the time required by linear search
Hash-based searching requires only one key comparison to find the position of a key, provided every element is present at its designated position decided by a hash function.
For example, consider a list of length 5 and the hash function: h(element) = element % size(list)
A hashing function is a mathematical function that generates unique results for each unique value supplied to the hash function in constant time.
For example: Consider a list of length 5 and if we want to search for key = 12, the index returned by the hash function is h(12) = 12 % 5 = 2 and requires only one key comparison to find the key at that index
Similarly increasing the size of the list (say 15) and if we want to search for key = 12, the index returned by the hash function is h(12) = 12 % 5 = 12 and requires only one key comparison to find the key at that index
Thus it is independent of the length of the list.
Searching Question 7:
In hashing, collision results when _______.
Answer (Detailed Solution Below)
Searching Question 7 Detailed Solution
Searching Question 8:
Consider the hashing table with ‘m’ slots and ‘n’ keys. If the expected number of probes in an unsuccessful search is 5, the expected number of probes in successful search is________
(Up to 2 decimals)Answer (Detailed Solution Below) 2.01 - 2.02
Searching Question 8 Detailed Solution
Formula:
Expected number of probes in unsuccessful search = \(\frac{1}{{1 - p}}\)
Expected number of probes in successful search = \(\frac{1}{p}\ln \left( {\frac{1}{{1 - p}}} \right)\)
\(p = \frac{n}{m}\)
where p is load factor.
Calculation:
\(\frac{1}{{1 - p}} = 5\)
1 = 5 – 5p
5p = 4
\(p = \frac{4}{5}\)
\(\frac{1}{p}\ln \left( {\frac{1}{{1 - p}}} \right) = \frac{5}{4}\ln \left( {\frac{1}{{1 - \frac{4}{5}\;}}} \right) = \frac{5}{4}\ln \left( 5 \right) = \frac{5}{4} \times 1.609 = 2.011\)
So, number of probes in successful search is 2.01
Searching Question 9:
In a hash table with 40 slots 60 records are inserted with collisions being resolved by chaining. What is the expected number of key comparisons in an unsuccessful search assuming uniform hashing?
Answer (Detailed Solution Below) 1.50
Searching Question 9 Detailed Solution
Answer: 1.5
Explanation:
In a hash-table with chaining and uniform hashing, the expected number of comparisons in an unsuccessful search is given by
α, where α is the load factor
\(\alpha = \frac{m}{n} = \frac{{60}}{{40}} = 1.5\)
Here, So, expected
number of comparisons for an unsuccessful search = 1.5
Searching Question 10:
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) 5
Searching Question 10 Detailed Solution
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, \(\frac{{low + high}}{2}\) element index is compared and if it is 1, search towards left and if it is 0 search towards right.
Total worst-case number of probes performed by an optimal algorithm is = \(lo{g_2}31\) = 5