Data Structure-hash table (c description)

Source: Internet
Author: User

1. Conflict resolution based on separation chain

1.1 Main storage structure

struct ListNode
{
    ElementType Element;
    Position    Next;
};

This is the structure that stores the data and is actually a linked list.

typedef struct ListNode *Position;
typedef Position List;
struct HashTbl
{
    int TableSize;//哈希表大小
    List *TheLists;//指针数组
};

This is the hash table main structure, *thelists is an array of pointers, each item of the array is linked to one of the above ListNode, and this entry address corresponds to the Chain header node.

1.2ADT description

hashsep.h
typedef int ElementType;
#ifndef HASHSEP_H_INCLUDED
#define HASHSEP_H_INCLUDED
typedef unsigned int Index;
struct ListNode;
typedef struct ListNode *Position;
struct HashTbl;
typedef struct HashTbl *HashTable;
HashTable InitializeTable( int TableSize );
void DestroyTable( HashTable H );
Position Find( ElementType Key, HashTable H );
void Insert( ElementType Key, HashTable H );
ElementType Retrieve( Position P );
/* Routines such as Delete are MakeEmpty are omitted */
#endif // HASHSEP_H_INCLUDED

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.