Data structure Learning--hash list ADT (programmatic)

Source: Internet
Author: User

I do not know people at the beginning to see the "Data Structure and algorithm analysis--c language description" when the hash of a chapter, can not understand the contents of the book, Little ZZ Look at the time did not see how to understand. So went to ask degrees Niang, degrees Niang gave me such an article. It introduces the basic definition of hashing and the commonly used method of implementation, which is quite easy to understand (perhaps the IQ is a bit clumsy).

http://blog.csdn.net/u010275850/article/details/44963701

First read this blog post, and then read the conclusion, suddenly suddenly realized that there are wood ah.

Refer to the book on the program ideas, the following general operation of the hash list is programmed as follows:

/* Split Link Method Construction hash */#include <stdio.h> #include <stdlib.h> #define tbsize 10typedef struct listnode{int data; struct ListNode *next;}    list,*list;typedef struct hashnode{int tablesize; List *thelists;} HASH,*HT; HT initht (int tablesize);//Initialization Routines list find (int data,ht H);//find operation int hash (int data,int tablesize);//hash function void Insert (int    Data,ht h);//insert operation void Delete (int data,ht h);//delete operation void printht (HT H);//print entire hash table void Printlist (list L);//Print List int main () {    int data[10]={0,1,4,9,16,25,36,49,64,81};    int i=0;    HT h;    H=INITHT (10);    if (h==null) printf ("Out of space!\n");    for (i=0;i<10;i++) {insert (DATA[I],H);    } printht (h);    Insert (7,H);    Insert (59,H);    printf ("After insert 7 and 59:\n");    PRINTHT (h);    Delete (36,H);    printf ("After delete 36:\n");    PRINTHT (h);    Find (7,H);    Find (49,H);    Find (36,H); return 0;}    HT initht (int tablesize) {HT H;    int i;    H=malloc (sizeof (struct hashnode)); if (h==null) printf ("Out of SPACE!\n ");    h->tablesize=tbsize;    H->thelists=malloc (sizeof (list) *h->tablesize);    if (h->thelists==null) printf ("Out of space!\n");        for (i=0;i

Data structure Learning--hash list ADT (programmatic)

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.