WorksheetsA9 - SEARCHING
Total questions: 43
Worksheet time: 32mins
(a) is a very simple search algorithm. In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.
Step in Linear Search. This step is set i to 1
(a)
Step in Linear Search. This step seeks if i > n then go to step 7
(a)
Step in Linear Search. This step seeks if A[i] = x then go to step 6
(a)
Step in Linear Search. This step is set i to i + 1
(a)
Step in Linear Search. This step goes back to Step 2
(a)
Step in Linear Search. This step prints Element x Found at index i and go to step 8
(a)
Step in Linear Search. This step prints element not found
(a)
Step in Linear Search. This step is the last step, where it only shows an "exit"
(a)
(a) is a fast search algorithm with run-time complexity of Ο(log n). This search algorithm works on the principle of divide and conquer. For this algorithm to work properly, the data collection should be in the sorted form.
Binary search looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of item is returned. If the middle item is greater than the item, then the item is searched in the _______ to the left of the middle item. Otherwise, the item is searched for in the _______ to the right of the middle item. This process continues on the _______ as well until the size of the _____ reduces to zero.
(a)
For a binary search to work, it is mandatory for the target array to be (a) .
(a) is an improved variant of binary search. This search algorithm works on the probing position of the required value. For this algorithm to work properly, the data collection should be in a sorted form and equally distributed.
Binary search has a huge advantage of (a) over linear search.
Linear search has (a) of Ο(n) whereas binary search has Ο(log n).
(a) of the Binary Search
A ← sorted array
n ← size of array
x ← value to be searched
Pseudocode of the Binary Search
A ← (a)
Pseudocode of the Binary Search
n ← (a)
Pseudocode of the Binary Search
x ← (a)
There are cases where the location of target data may be known in advance. For example, in case of a telephone directory, if we want to search the telephone number of Morphius. Here, linear search and even binary search will seem slow as we can directly jump to (a) where the names start from 'M' are stored.
In binary search, if the desired data is not found then the rest of the list is divided in two parts, _____ and ______. The search is carried out in either of them.
(a)
mid = Lo + ((Hi - Lo) / (A[Hi] - A[Lo])) * (X - A[Lo])
Where:
A - (a)
mid = Lo + ((Hi - Lo) / (A[Hi] - A[Lo])) * (X - A[Lo])
Where:
Hi - (a)
mid = Lo + ((Hi - Lo) / (A[Hi] - A[Lo])) * (X - A[Lo])
Where:
Lo - (a)
mid = Lo + ((Hi - Lo) / (A[Hi] - A[Lo])) * (X - A[Lo])
Where:
A[n] - (a)
In the Positioning of Binary Search. This step starts searching data from middle of the list.
(a)
In the Positioning of Binary Search. This step seeks if it is a match, return the index of the item, and exit.
(a)
In the Positioning of Binary Search. This step seeks if it is not a match, probe position.
(a)
In the Positioning of Binary Search. This step divides the list using probing formula and find the new middle.
(a)
In the Positioning of Binary Search. This step seeks if data is greater than middle, search in higher sub-list.
(a)
In the Positioning of Binary Search. This step seeks if data is smaller than middle, search in lower sub-list.
(a)
In the Positioning of Binary Search. This step will undergo repetition until it matches.
(a)
(a) is a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value. Access of data becomes very fast if we know the index of the desired data.
Thus, it becomes a data structure in which insertion and search operations are very fast irrespective of the size of the data. Hash Table uses an array as a (a) and uses hash technique to generate an index where an element is to be inserted or is to be located from.
(a) is a technique to convert a range of key values into a range of indexes of an array. We're going to use modulo operator to get a range of key values. Consider an example of hash table of size 20, and the following items are to be stored. Item are in the (key,value) format.
Searches an element in a hash table.
(a)
inserts an element in a hash table.
(a)
Deletes an element from a hash table.
(a)
Define a data item having some data and key, based on which the search is to be conducted in a hash table.
(a)
In such a case, we can search the next empty location in the array by looking into the next cell until we find an empty cell. This technique is called (a) .
Whenever an element is to be searched, compute the hash code of the key passed and locate the element using that hash code as index in the array. Use linear probing to get the element ahead if the element is not found at the computed hash code.
(a)
Whenever an element is to be inserted, compute the hash code of the key passed and locate the index using that hash code as an index in the array. Use linear probing for empty location, if an element is found at the computed hash code.
(a)
Whenever an element is to be deleted, compute the hash code of the key passed and locate the index using that hash code as an index in the array. Use linear probing to get the element ahead if an element is not found at the computed hash code. When found, store a dummy item there to keep the performance of the hash table intact.
(a)
