Hv dans

Comment

Author: Admin | 2025-04-27

-1; } // Function call hashing(hash_table, arr); }} Python # Python3 implementation of# the Quadratic Probing# Function to print an arraydef printArray(arr): # Iterating and printing the array for i in range(len(arr)): print(arr[i], end=" ")# Function to implement the# quadratic probingdef hashing(table, arr): # Iterating through the array for i in range(len(arr)): # Computing the hash value hv = arr[i] % tsize # Insert in the table if there # is no collision if (table[hv] == -1): table[hv] = arr[i] else: # If there is a collision # iterating through all # possible quadratic values for j in range(1, len(table)+1): # Computing the new hash value t = (hv + j * j) % tsize if (table[t] == -1): # Break the loop after # inserting the value # in the table table[t] = arr[i] break printArray(table)# Driver codeif __name__ == "__main__": arr = [50, 700, 76, 85, 92, 73, 101] # Size of the hash table tsize = 11 hash_table = [0] * tsize # Initializing the hash table for i in range(tsize): hash_table[i] = -1 # Function call hashing(hash_table, arr) C# // C# implementation of the Quadratic Probingusing System;class GFG { // Function to print an array static void printArray(int[] arr) { // Iterating and printing the array for (int i = 0; i arr.Length; i++) { Console.Write(arr[i] + " "); } } // Function to implement the // quadratic probing static void hashing(int[] table, int tsize, int[] arr, int N) { // Iterating through the array for (int i = 0; i N; i++) { // Computing the hash value int hv = arr[i] % tsize; // Insert in the table if there // is no collision if (table[hv] == -1) table[hv] = arr[i]; else { // If there is a collision // iterating through all // possible quadratic values for (int j = 1; j tsize; j++) { // Computing the new hash value int t = (hv + j * j) % tsize; if (table[t] == -1) { // Break the loop after // inserting the value // in the table table[t] = arr[i]; break;

Add Comment