Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS351 DATA ORGANIZATION AND MANAGEMENT Programming Assignment #1 Static Hashing in JAVA October 13, 2009 Due Date: Oct. 23, 2009, Friday; by 23:59 Assignment: The purpose of this assignment is to give you a practical exercise with static hashing. For the sake of simplicity, you will implement record insertion from an input file “Students.txt” , not deletions or modifications. You will use “RandomAccessFile” class of Java which will help you during insertion of records to the output file. As you know, in static hashing, there are two areas which contain records: “Prime” and “Overflow” areas. Each area will have specified number of buckets. Your program will ask user both the prime area bucket number and overflow area bucket number . For ex., when user enters 10 for prime area bucket number and 3 for prime area bucket number; then there will be 10 buckets in prime area and 3 buckets in overflow area. But you will choose Bkfr (Bucket Factor) as 1 , which means there will be only one record in each bucket both in overflow area and prime area. Input File: “Students.txt” The structure of the input file is as follows. 3 blank separated fields exist in each line of the input file. (b indicates a blank character) StudentID b StudentName b StudentDepartment 6 bytes 8 bytes 2 bytes Ex: 204021 Emre CS 204123 Levent IE 203212 Dilek EE The prime area bucket number taken from user will be used in our hash function, h(x), x mod prime area bucket number (x is the StudentID field of Students.txt). By using this hash function, you will identify the bucket in which that record will be inserted. Because of bucket factor is 1, if the bucket in the prime area has another record already inserted, then you will insert the record into another bucket in the overflow area. But you also have to check whether overflow area has any empty buckets, because overflow area will have specified number of buckets, not infinite. When inserting a record, if the overflow area is full , then you will give an error message about insertion and you will skip to insertion of other records in the input file.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Output File: “HashFile.txt” Your program will create an output file, “HashFile.txt” which will both prime area buckets and overflow area buckets. First of all, the output file will contain only 1 line , which means it will be a sequential file : each bucket will come one after the other. This will ease your seek operation during insertions. Then, each bucket will cover 20 bytes in the output file: StudentID StudentName StudentDepartment OverflowAreaLink 6 bytes 8 bytes
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2011 for the course CS 351 taught by Professor Fazlıcan during the Spring '11 term at Bilkent University.

Page1 / 5


This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online