Extendible Hash File Search - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Extendible Hash File Search

Description:

If there is room for another record on that page. Then store the new record there ... If room available in bucket. Then insert new record. Else If overflow ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 7
Provided by: edwa74
Category:
Tags: extendible | file | hash | room | search | store

less

Transcript and Presenter's Notes

Title: Extendible Hash File Search


1
Extendible Hash File Search
  • Perform Hash function H on key,
    pkey H(key)
  • Assign high order D bits of pkey, where D is the
    Directory depth, to i,
    i High_Order(D,pkey)
  • Get pointer to leaf page,
    lptr Directoryi
  • Search page pointed to by lptr for record with
    key
  • If found record in step 4 then return record else
    return Not Found

2
Extendible Hash File Insert
  • Perform steps 1 thru 3 from Search algorithm
  • Access page pointed to by lptr
  • If there is room for another record on that page
  • Then store the new record there
  • Else
  • Begin
  • get space for new leaf page,
    new_lptr is pointer
  • to new leaf page
  • increase depth of leaf page by 1
  • set depth of new leaf page to be
    the same as
  • that for page pointed to by
    lptr
  • divide records between the two
    leaf pages pointed to by lptr
  • and new_lptr

3
  • Extendible Hash File Insert (continued)
  • If new pages depth is gt Directory
    depth Then
  • Begin
  • increase directory depth by
    1
  • double directory size
  • update pointers in directory
  • End
  • Else
  • update directory so that it
    points to new_lptr page
  • If could not insert new record
  • Then repeat Insert Algorithm from
    step 1
  • End

4
Linear Hash File Search
  • bucket key MOD (2Level N)
  • If bucket lt next


    Then bucket
    key MOD (2Level1 N)
  • Search bucket for record with key (may involve
    searching overflow for bucket)
  • If found record then return record else return
    Not Found

5
Linear Hash File Insert
  • Perform steps 1 and 2 of Search Algorithm
  • Access bucket found in step 1
  • If room available in bucket
  • Then insert new record
  • Else If overflow buckets
  • Then
  • Begin
  • search for room in
    overflow
  • If room Then
    insert
  • Else add another
    overflow bucket with new record
  • End
  • Else add first overflow bucket
    with new record

6
Linear Hash File Expand
  • Expand bucket and its overflow chain at location
    next,
  • add new bucket at location next
    (2Level N)
  • to distribute records from bucket next
    and the new bucket, use key MOD (2Level1 N)
  • next (next 1) MOD (2Level N)
  • If next 0 Then level level 1
Write a Comment
User Comments (0)
About PowerShow.com