Вы находитесь на странице: 1из 4

/* TABELAT HASH */

/* Implementimi i hashit te hapur */


typedef struct list_node *node_ptr;
struct list_node
{
element_type element;
node_ptr next;
};
typedef node_ptr LIST;
typedef node_ptr position;
struct hash_tbl
{
int table_size;
LIST *the_lists;
};
typedef struct hash_tbl *HASH_TABLE;
HASH_TABLE initialize_table( int table_size )
{
HASH_TABLE H;
int i;
if( table size < MIN_TABLE_SIZE )
{
error("Table size too small");
return NULL;
}
H = (HASH_TABLE) malloc ( sizeof (struct hash_tbl) );
if( H == NULL )
fatal_error("Out of space!!!");
H->table_size = next_prime( table_size );
H->the_lists = (position *)
malloc( sizeof (LIST) * H->table_size );
if( H->the_lists == NULL )
fatal_error("Out of space!!!");
for(i=0; i<H->table_size; i++ )
{
H->the_lists[i] = (LIST) malloc( sizeof (struct list_node)
);
if( H->the_lists[i] == NULL )
fatal_error("Out of space!!!");
else
H->the_lists[i]->next = NULL;
}
return H;
}

// Implementimi i kerkimit ne hash te hapur


position gjej( element_type key, HASH_TABLE H )
{
position p;
LIST L;
L = H->the_lists[ hash( key, H->table_size) ];
p = L->next;
while( (p != NULL) && (p->element != key) )
/* mund te duhet strcmp!! */
p = p->next;
return p;
}
// Implementimi i shtimit ne hash te hapur
void insert( element_type key, HASH_TABLE H )
{
position pos, new_cell;
LIST L;
pos = gjej( key, H );
if( pos == NULL )
{
new_cell = (position) malloc(sizeof(struct list_node));
if( new_cell == NULL )
fatal_error("Out of space!!!");
else
{
L = H->the_lists[ hash( key, H->table size ) ];
new_cell->next = L->next;
new_cell->element = key;
L->next = new_cell;
}
}
}
/* Implementimi hash i mbyllur */
enum kind_of_entry { legitimate, empty, deleted };
struct hash_entry
{
element_type element;
enum kind_of_entry info;
};
typedef INDEX position;
typedef struct hash_entry cell;
struct hash_tbl
{
int table_size;
cell *the_cells;
};
typedef struct hash_tbl *HASH_TABLE;
HASH_TABLE initialize_table(int table_size )
{
HASH_TABLE H;
int i;
if( table_size < MIN_TABLE_SIZE )
{
error("Table size too small");

return NULL;
}
H = (HASH_TABLE) malloc( sizeof ( struct hash_tbl ) );
if( H == NULL )
fatal_error("Out of space!!!");
H->table_size = next_prime( table_size );
H->the cells = (cell *) malloc( sizeof ( cell ) * H->table_size );
if( H->the_cells == NULL )
fatal_error("Out of space!!!");
for(i=0; i<H->table_size; i++ )
H->the_cells[i].info = empty;
return H;
}
// Implementimi hash i mbyllur/Gjej kuadratik
position gjej( element_type key, HASH_TABLE H )
{
position i, current_pos;
i = 0;
current_pos = hash( key, H->table_size );
while( (H->the_cells[current_pos].element != key ) &&
(H->the_cells[current_pos].info != empty ) )
{
current_pos += 2*(++i) - 1;
if( current_pos >= H->table_size )
current_pos -= H->table_size;
}
return current_pos;
}
// Implementimi hash i mbyllur/Shto kuadratik
void shto( element_type key, HASH_TABLE H )
{
position pos;
pos = gjej( key, H );
if( H->the_cells[pos].info != legitimate )
{
H->the_cells[pos].info = legitimate;
H->the_cells[pos].element = key;
}
}
/* Implementimi rehash */
HASH_TABLE rehash( HASH_TABLE H )
{
int i, old_size;
cell *old_cells;
old_cells = H->the_cells;
old_size = H->table_size;
H = inicializo( 2*old_size );
for( i=0; i<old_size; i++ )
if( old_cells[i].info == legitimate )
insert( old_cells[i].element, H );
free( old_cells );
return H;
}

Вам также может понравиться

  • Practical 10
    Practical 10
    Документ4 страницы
    Practical 10
    sdfsdfsd
    Оценок пока нет
  • Hashtable #Include #Include #Include #Include
    Hashtable #Include #Include #Include #Include
    Документ4 страницы
    Hashtable #Include #Include #Include #Include
    Paulina Voicu
    Оценок пока нет
  • Quardatic Probing
    Quardatic Probing
    Документ7 страниц
    Quardatic Probing
    Iqra Yasmeen
    Оценок пока нет
  • Ads Hash
    Ads Hash
    Документ4 страницы
    Ads Hash
    rohankhandare429
    Оценок пока нет
  • Hashtable Class: Vaishnavi Deshmukh Mca 2 Roll No. 1912012
    Hashtable Class: Vaishnavi Deshmukh Mca 2 Roll No. 1912012
    Документ9 страниц
    Hashtable Class: Vaishnavi Deshmukh Mca 2 Roll No. 1912012
    Vaishnavi Deshmukh
    Оценок пока нет
  • BangBam01 KetNoiTrucTiep
    BangBam01 KetNoiTrucTiep
    Документ7 страниц
    BangBam01 KetNoiTrucTiep
    Nguyễn Minh Tú
    Оценок пока нет
  • Tabele de Dispersie
    Tabele de Dispersie
    Документ3 страницы
    Tabele de Dispersie
    Robert Pop
    Оценок пока нет
  • CS 1103 Learning Journal Exercise 5
    CS 1103 Learning Journal Exercise 5
    Документ4 страницы
    CS 1103 Learning Journal Exercise 5
    lumstrylmoxyfgrhvd
    Оценок пока нет
  • Hash Table
    Hash Table
    Документ5 страниц
    Hash Table
    Luis Quiroz
    Оценок пока нет
  • Hashtable Module 5
    Hashtable Module 5
    Документ8 страниц
    Hashtable Module 5
    Ram Guggul
    Оценок пока нет
  • Untitled
    Untitled
    Документ2 страницы
    Untitled
    Kadetão Sampaio
    Оценок пока нет
  • Lab. Sheet Seven: Data Structure Laboratory
    Lab. Sheet Seven: Data Structure Laboratory
    Документ7 страниц
    Lab. Sheet Seven: Data Structure Laboratory
    xz
    Оценок пока нет
  • Hashing Ödevi
    Hashing Ödevi
    Документ3 страницы
    Hashing Ödevi
    serif.gul.449
    Оценок пока нет
  • Tabela Hash
    Tabela Hash
    Документ3 страницы
    Tabela Hash
    tony29dealmeida29
    Оценок пока нет
  • Task 3 - Solution To Quadratic Probing
    Task 3 - Solution To Quadratic Probing
    Документ5 страниц
    Task 3 - Solution To Quadratic Probing
    Muhammad Faiz Alam Khan
    Оценок пока нет
  • Oops & Ds Printout
    Oops & Ds Printout
    Документ84 страницы
    Oops & Ds Printout
    victor
    Оценок пока нет
  • List Part 2
    List Part 2
    Документ15 страниц
    List Part 2
    Mohammed Alhwaitat
    Оценок пока нет
  • Algorithm-Lab-Assignment Mid 118
    Algorithm-Lab-Assignment Mid 118
    Документ13 страниц
    Algorithm-Lab-Assignment Mid 118
    rarafat4057
    Оценок пока нет
  • Tables
    Tables
    Документ3 страницы
    Tables
    Steven Truong
    0% (1)
  • Experiment No. 8: Title: Program For Static Hashing
    Experiment No. 8: Title: Program For Static Hashing
    Документ4 страницы
    Experiment No. 8: Title: Program For Static Hashing
    yogita Bansod
    Оценок пока нет
  • Wordseg
    Wordseg
    Документ11 страниц
    Wordseg
    Kindirka Kin
    Оценок пока нет
  • Heap
    Heap
    Документ4 страницы
    Heap
    lekhaperumal
    Оценок пока нет
  • Linkedlist
    Linkedlist
    Документ4 страницы
    Linkedlist
    Nguyen Huynh Phi Long SV
    Оценок пока нет
  • Advanced Data Structure
    Advanced Data Structure
    Документ37 страниц
    Advanced Data Structure
    haider ali
    Оценок пока нет
  • Mcse Ads Amit Asthana
    Mcse Ads Amit Asthana
    Документ28 страниц
    Mcse Ads Amit Asthana
    AmitAsthana
    Оценок пока нет
  • Project 11
    Project 11
    Документ2 страницы
    Project 11
    v venkat
    Оценок пока нет
  • Linked List Advantages Over Array
    Linked List Advantages Over Array
    Документ15 страниц
    Linked List Advantages Over Array
    gshivam63
    Оценок пока нет
  • Лаб 5 САА
    Лаб 5 САА
    Документ11 страниц
    Лаб 5 САА
    Ivan Goranov
    Оценок пока нет
  • Practical 8 To 12
    Practical 8 To 12
    Документ16 страниц
    Practical 8 To 12
    Ravan bhoye
    Оценок пока нет
  • Cacbaitapmau
    Cacbaitapmau
    Документ21 страница
    Cacbaitapmau
    KATIE_3011
    Оценок пока нет
  • Pes2ug20cs296 Sai Hardik Ds Lab Week 9
    Pes2ug20cs296 Sai Hardik Ds Lab Week 9
    Документ11 страниц
    Pes2ug20cs296 Sai Hardik Ds Lab Week 9
    ROHIT V SHASTRY
    Оценок пока нет
  • Program To Create A Linked List22
    Program To Create A Linked List22
    Документ7 страниц
    Program To Create A Linked List22
    ĨnÔøcềnt Prîñçê
    Оценок пока нет
  • Exercice 1
    Exercice 1
    Документ5 страниц
    Exercice 1
    badi3bahida15
    Оценок пока нет
  • Program 3
    Program 3
    Документ20 страниц
    Program 3
    api-709999921
    Оценок пока нет
  • Tailieu DSA
    Tailieu DSA
    Документ40 страниц
    Tailieu DSA
    Hùng Cường
    Оценок пока нет
  • MYSQL Queries Part1
    MYSQL Queries Part1
    Документ4 страницы
    MYSQL Queries Part1
    theodor_munteanu
    Оценок пока нет
  • Tables in Oracle
    Tables in Oracle
    Документ5 страниц
    Tables in Oracle
    YashS
    Оценок пока нет
  • Lab Report 10 18l-1360
    Lab Report 10 18l-1360
    Документ22 страницы
    Lab Report 10 18l-1360
    Muhammad Mujtaba Bashir
    Оценок пока нет
  • EXERCISE HT Set
    EXERCISE HT Set
    Документ2 страницы
    EXERCISE HT Set
    m.pusiewicz
    Оценок пока нет
  • Dsa Final Paper
    Dsa Final Paper
    Документ21 страница
    Dsa Final Paper
    Haris Khan
    Оценок пока нет
  • Linked List
    Linked List
    Документ9 страниц
    Linked List
    chusherrera15
    Оценок пока нет
  • C++ Programs
    C++ Programs
    Документ57 страниц
    C++ Programs
    Buvana Siva
    Оценок пока нет
  • 7.1 101. Stack LL C PDF
    7.1 101. Stack LL C PDF
    Документ3 страницы
    7.1 101. Stack LL C PDF
    Md Asif Alam
    Оценок пока нет
  • 101.stack LL C PDF
    101.stack LL C PDF
    Документ3 страницы
    101.stack LL C PDF
    Shorya Kumar
    Оценок пока нет
  • SEARCH
    SEARCH
    Документ53 страницы
    SEARCH
    Phạm Quốc Bảo
    Оценок пока нет
  • C Sorting Searching Sample Source Codes: 2d Example Insertion Sort (Linked List)
    C Sorting Searching Sample Source Codes: 2d Example Insertion Sort (Linked List)
    Документ30 страниц
    C Sorting Searching Sample Source Codes: 2d Example Insertion Sort (Linked List)
    Javed Khan
    100% (1)
  • Created by Utkarsharora On 3/3/17. /: E V Al Marked Stack V Al Marked Stack Al
    Created by Utkarsharora On 3/3/17. /: E V Al Marked Stack V Al Marked Stack Al
    Документ4 страницы
    Created by Utkarsharora On 3/3/17. /: E V Al Marked Stack V Al Marked Stack Al
    Anonymous oQWqJ5OwZ
    Оценок пока нет
  • Recursos H
    Recursos H
    Документ2 страницы
    Recursos H
    diego depas
    Оценок пока нет
  • Hashing: Using Open Addressing
    Hashing: Using Open Addressing
    Документ6 страниц
    Hashing: Using Open Addressing
    Qazi Mujtaba
    Оценок пока нет
  • DSA Lab 11
    DSA Lab 11
    Документ7 страниц
    DSA Lab 11
    hananaasif2004
    Оценок пока нет
  • HW Algo 3
    HW Algo 3
    Документ16 страниц
    HW Algo 3
    Алтын бельгист
    Оценок пока нет
  • Array&LL Implementation of Stack
    Array&LL Implementation of Stack
    Документ7 страниц
    Array&LL Implementation of Stack
    mishalahamed0
    Оценок пока нет
  • C Program To Implement A Stack and Queue Using A Linked List
    C Program To Implement A Stack and Queue Using A Linked List
    Документ18 страниц
    C Program To Implement A Stack and Queue Using A Linked List
    Anonymous QbchUByq2
    Оценок пока нет
  • Hive
    Hive
    Документ3 страницы
    Hive
    ud
    Оценок пока нет
  • C++ Project (Program)
    C++ Project (Program)
    Документ15 страниц
    C++ Project (Program)
    Suman Lata
    Оценок пока нет
  • Dfa Simulation
    Dfa Simulation
    Документ5 страниц
    Dfa Simulation
    Mohsan Azad
    Оценок пока нет
  • Exportar Dados Do Wix para XLSX e CSV (2023) (Novo Método)
    Exportar Dados Do Wix para XLSX e CSV (2023) (Novo Método)
    Документ3 страницы
    Exportar Dados Do Wix para XLSX e CSV (2023) (Novo Método)
    Gustavo Alexandre Gustavo TIM Brasil
    Оценок пока нет
  • The Hash Table Data Structure: Mugurel Ionuț Andreica Spring 2012
    The Hash Table Data Structure: Mugurel Ionuț Andreica Spring 2012
    Документ9 страниц
    The Hash Table Data Structure: Mugurel Ionuț Andreica Spring 2012
    AlinaE.Barbu
    Оценок пока нет
  • Data Structure Rograms
    Data Structure Rograms
    Документ50 страниц
    Data Structure Rograms
    preetu1986
    Оценок пока нет
  • Hashing Data Structure: Hash Table
    Hashing Data Structure: Hash Table
    Документ5 страниц
    Hashing Data Structure: Hash Table
    GODWIN Gaming
    Оценок пока нет
  • Student Solution Chap 12
    Student Solution Chap 12
    Документ10 страниц
    Student Solution Chap 12
    priyapati21
    Оценок пока нет
  • 12 Hashing
    12 Hashing
    Документ40 страниц
    12 Hashing
    Jayanth Vasudev
    Оценок пока нет
  • T06 - Time and Space Tradeoffs
    T06 - Time and Space Tradeoffs
    Документ70 страниц
    T06 - Time and Space Tradeoffs
    Thejus Padmakumar
    Оценок пока нет
  • DSA Theory Final
    DSA Theory Final
    Документ8 страниц
    DSA Theory Final
    Talha Syed
    Оценок пока нет
  • Dutch & English & Estonian
    Dutch & English & Estonian
    Документ4 страницы
    Dutch & English & Estonian
    Ash Win
    Оценок пока нет
  • Sss
    Sss
    Документ3 страницы
    Sss
    faheem ansari
    Оценок пока нет
  • Fusion Trees
    Fusion Trees
    Документ19 страниц
    Fusion Trees
    Orange Shelly
    Оценок пока нет
  • Hashing: An Ideal Hash Table
    Hashing: An Ideal Hash Table
    Документ11 страниц
    Hashing: An Ideal Hash Table
    Mehwish Mehmood
    Оценок пока нет
  • Hashing: Quadratic Probing: Pamantasan NG Lungsod NG Muntinlupa NBP Reservations, Poblacion Muntinlupa City
    Hashing: Quadratic Probing: Pamantasan NG Lungsod NG Muntinlupa NBP Reservations, Poblacion Muntinlupa City
    Документ11 страниц
    Hashing: Quadratic Probing: Pamantasan NG Lungsod NG Muntinlupa NBP Reservations, Poblacion Muntinlupa City
    Lord Edgardian Jamela Tavu
    Оценок пока нет
  • The MD5 Encryption & Decryption
    The MD5 Encryption & Decryption
    Документ13 страниц
    The MD5 Encryption & Decryption
    kumarkl
    Оценок пока нет
  • 008
    008
    Документ117 страниц
    008
    Anonymous VHkVwt4
    Оценок пока нет
  • The Orange Manuscript v2 RED
    The Orange Manuscript v2 RED
    Документ61 страница
    The Orange Manuscript v2 RED
    Carolina Herrero
    Оценок пока нет
  • Collision Resolution Techniques
    Collision Resolution Techniques
    Документ15 страниц
    Collision Resolution Techniques
    vvsprasad
    Оценок пока нет
  • Message Integrity and Authentication
    Message Integrity and Authentication
    Документ41 страница
    Message Integrity and Authentication
    RAJ TAPASE
    Оценок пока нет
  • Vestel 17mb30-2 SCH
    Vestel 17mb30-2 SCH
    Документ11 страниц
    Vestel 17mb30-2 SCH
    Mihai Alexim
    Оценок пока нет
  • s53fds65f DSFDSFDSF 45
    s53fds65f DSFDSFDSF 45
    Документ17 страниц
    s53fds65f DSFDSFDSF 45
    Bi Milo
    Оценок пока нет
  • CS3353 Unit5
    CS3353 Unit5
    Документ21 страница
    CS3353 Unit5
    Padmapriya Thianu
    Оценок пока нет
  • Cryptographic Hash Functions
    Cryptographic Hash Functions
    Документ40 страниц
    Cryptographic Hash Functions
    Pedada Sai kumar
    Оценок пока нет
  • (Update) Post Test Week 6 - Attempt Revieww
    (Update) Post Test Week 6 - Attempt Revieww
    Документ5 страниц
    (Update) Post Test Week 6 - Attempt Revieww
    Dita Noviyanti
    Оценок пока нет
  • Python
    Python
    Документ4 страницы
    Python
    Trinh Tan Quang Bao K17 DN
    Оценок пока нет
  • Tugas Security V.2
    Tugas Security V.2
    Документ3 страницы
    Tugas Security V.2
    Marsel Xavier
    Оценок пока нет
  • Cryptographic Hash Functions
    Cryptographic Hash Functions
    Документ37 страниц
    Cryptographic Hash Functions
    yohan surya
    Оценок пока нет
  • Unit29 Hashing2
    Unit29 Hashing2
    Документ20 страниц
    Unit29 Hashing2
    Nikila Narayanan
    Оценок пока нет
  • Hashing
    Hashing
    Документ56 страниц
    Hashing
    Lamia Alam
    Оценок пока нет
  • Chapter 8 - Hashing
    Chapter 8 - Hashing
    Документ78 страниц
    Chapter 8 - Hashing
    sarvaang
    Оценок пока нет
  • Cryptographic Hash Functions
    Cryptographic Hash Functions
    Документ6 страниц
    Cryptographic Hash Functions
    graduation project
    Оценок пока нет
  • BCS304-DSA Notes M-5
    BCS304-DSA Notes M-5
    Документ22 страницы
    BCS304-DSA Notes M-5
    sagar2024k
    Оценок пока нет
  • Colossion in Hasing
    Colossion in Hasing
    Документ22 страницы
    Colossion in Hasing
    oggy
    Оценок пока нет
  • Hashlib
    Hashlib
    Документ5 страниц
    Hashlib
    Arvind Vaish
    Оценок пока нет