Question
i have to implement open addressing hashing using linear probing inside a random access file. the format for each record should be: 10 chars (name
i have to implement open addressing hashing using linear probing inside a random access file. the format for each record should be:
10 chars (name a String or a char[])
4 bytes (id int; id is autoincrement, start at 1)
1 byte (meta -- data information byte: dirty bit, empty bit)
The data are laid out on the record as shown above.
The meaning of the byte that stores the dirty bit is:
0b0000 there is no data present 0b0001 dirty the data is invalid. I.e., this is a tombstone
0b0100 clean data there is data present and the data is valid
0b0101 dirty data there is data present, but the data is dirty.
Note! Only the bottom 4 bits of the byte is shown. The top four bits are, obviously, all 0.
The hash table is a random access file comprising records. You must create the initial hash table in the file by setting up 16 records: The hash table is initially empty and is size 16. Use Java Objects hash() function for the hash function. You will hash the String data to obtain the hash value. The record will be inserted to the file as given by the hash value.
i should be able to insert into the hash table inside of the raf file padding or truncating as necessary. if the data in the location calculated by the hash value of the string is marked dirty or empty, i should insert it there. otherwise i should continue linear probe until i find a sutable location. every insert should also test if the hash table is overcapacity. if it is 50% or more, it should rehash into a bigger table.
i should also be able to delete from the hash table inside of the raf file and print the hash table at any time. deleting from the table should mark the data as dirty.
to test if the data is dirty i should have an unsigned byte variable named info
The data is dirty: info && 0x01
The data is present and clean: !dirty(info) && (info && 0x04)
The record is empty: info == 0x00
Set the dirty bit: info = info || 0x01
Clear the dirty bit: info = info && 0xFE
Set the data present bit: info = info || 0x04
Clear the data present bit: info = info && 0xFB
any help would be appreciated!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started