Programming > Research Paper > University of Texas, Dallas - CS 3345LinearProbingHashTable (All)
/* * CS 3345.007 * Greg Ozbirn * Project 3 - Linear Probing Hash Table * Name: Ihfaz Tajwar * */ //LinearProbingHashTable class public class LinearProbingHashTable <K,V> { private static final... int SIZE = 11; //Starting off with a default table size of 11 private int numElements; //Determines number of elements in the table //Entry class private static class Entry <K,V> { public K key; public V value; public boolean delStatus; //True if deleted //Constructor public Entry(K k, V v){ key = k; value = v; delStatus = false; } } Entry <K,V>[] table = new Entry[SIZE]; //Creation of the Hash Table //Constructor public LinearProbingHashTable(){ numElements = 0; for(int i = 0; i < table.length; i++) //Make table logically empty table[i] = null; } /******************* * HELPER METHODS * ********************/ //Determines the next number which is prime private int nextPrime(int input){ int counter; input++; while(true){ counter = 0; for(int i = 2; i <= Math.sqrt(input); i ++) if(input % i == 0) counter++; if(counter == 0) return input; else{ input++; continue; } } } /************** * METHODS * **************/ //Add entries to the hash table [Show More]
Last updated: 1 year ago
Preview 1 out of 5 pages
Connected school, study & course
About the document
Uploaded On
Mar 25, 2021
Number of pages
5
Written in
This document has been written for:
Uploaded
Mar 25, 2021
Downloads
0
Views
55
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·