Giter VIP home page Giter VIP logo

linear_hashing's Introduction

Linear Hashing

Implementation of linear hashing algorithm of paper to handle duplicate elimination using c++ language.

Input

<Filename,M,B> as command line arguements. "M" is the number of buffers. "B" is the buffer size and "filename" is the name of input file whose each line consists one of single integer x (-10^9 <= x <= 10^9).

Output

After reading every line (call it record), If record is not inserted into data structure, print it and insert it into data structure.

NOTE

  1. M denotes the number of buffers and B denotes the buffer size (M>=2 and M*B<=10^6).
  2. Out of the M buffers, M-1 Buffers will be used as input buffers (which will hold the records from the input file), 1 buffer will be used as output buffer (holds the distinctrecords).
  3. If the output buffer gets filled, it should be flushed to the output. If the input buffers get empty, next chunk of records should be read from the input file.

Algorithm to decide buffer split

Assume block size = buffer size (B).
Let there are n blocks (without counting overflow blocks) and r records at some instant.
Let r0 be the maximum records that can fit in a block.
Split occupancy = r/(n*r0). Setting threshold to 0.75. This means split happens when occupancy >= 0.75.
To calculate r0:-
if each block has space for n keys and n+1 pointers then size occupied = 4*(n)+8*(n+1) [if keys are integer]
Let this be called "S". Thus, picking the maximum value of n such that S<=B (block size).
This maximum value of n is our r0.

linear_hashing's People

Contributors

priyansh2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.