How many probes are necessary to retrive “35” from the list below if you use sequential…
- User
How many probes are necessary to retrive “35” from the list below if you use sequential search? Keys: 70 55 24 11 94 35 19 21 87 58 48 20 4 71 14
- Assistant
To retrieve "35" using sequential search, we would need to check each key in the list one by one until we find the target.
In this case, the target is "35". To find it, we need to sequentially search through the list of keys: 70, 55, 24, 11, 94, 35.
Therefore, we would need a total of 6 probes to retrieve "35" using sequential search.
- User
How many probes are needed if binary search technique is applied?
- Assistant
To use binary search, the list of keys must be sorted in ascending order.
The sorted list of keys is: 4, 11, 14, 19, 20, 21, 24, 35, 48, 55, 58, 70, 71, 87, 94.
To retrieve "35" using binary search, we start by comparing the target with the middle element of the list. Since the middle element is 21, which is smaller than 35, we can eliminate the left half of the list (including 4, 11, 14, 19, 20, and 21).
Next, we compare the target with the middle element of the remaining list. The middle element is 55, which is greater than 35. We can eliminate the right half of the list (including 55, 58, 70, 71, 87, and 94).
Now, we are left with the element 24. Since 24 is smaller than 35, we eliminate it as well.
Finally, we are left with the target "35".
During the binary search, we performed a total of 3 probes (comparisons) to retrieve "35".
- User
Insert records with the keys below by using H(key) = key mod 7 hashing function and EISCH collision resolution method. Keys: 17 40 45 49 80 10 19
- Assistant
To insert records using the hash function H(key) = key mod 7 and the EISCH collision resolution method, we will iterate through each key and perform the following steps:
-
Create a hash table with 7 slots (0 to 6) and initialize all slots as empty.
-
Calculate the hash value for each key using the hash function H(key) = key mod 7.
- For key 17, H(17) = 17 mod 7 = 3.
- For key 40, H(40) = 40 mod 7 = 5.
- For key 45, H(45) = 45 mod 7 = 3. (Collision)
- For key 49, H(49) = 49 mod 7 = 0.
-
- User
Construct a perfect hashing function using Cichelli’s algorithm with the keys below. Use a maximum value of 3 for assigning to characters. Keys: ece mert ada eda nuri iclal aydan
- Assistant
Cichelli's algorithm is used to construct a perfect hashing function for a given set of keys. Here's how we can use Cichelli's algorithm to construct a perfect hashing function for the given set of keys: ece, mert, ada, eda, nuri, iclal, and aydan.
Step 1: Assign a unique number to each key character.
ece: 1 2 3 mert: 1 2 3 1 ada: 1 2 1 eda: 1 2 1 nuri: 1 2 3 1 iclal: 1 2 3 4 1 aydan: 1 2 3 4 1
Step 2: Construct a matrix with a row for each key character and a column for each character position.
1 2 3 4
1 | 1 1 1 1 2 | 2 2 2 2 3 | 3 3 3 3 4 | 4 4
Step 3: Check if any column has more than one non-zero entry. If so, go to step 4. Otherwise, go to step 5.
In our case, column 4 has two non-zero entries, so we need to go to step 4.
Step 4: Resolve the collision by incrementing the values in the rows which share the same column position with the collision.
- User
Insert records with keys below by using H(key) = key mod 11 hashing function, I(key)=Quotient(key/11) mod 11 increment function and the Binary Tree collision resolution method. (PS: You should draw the binary trees for each insertion)
- Assistant