Each value in the array t is a pointer to the node node and the element in node node is key,data.
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct NODE
{
int key;
int data;
}node;
typedef struct T
{
Node **table;//using pointer arrays
int size;
}t;
void T_create (T *t)
{
printf ("What is the keyword whole domain u?") \ n ");
scanf ("%d", &t->size);
t->table= (Node *) calloc (sizeof (node*), t->size);
}
void Direct_search_insert (t* t,node *node)
{
t->table[node->key]=node;
}
void Direct_search_delete (t* t,int data)
{
int i;
for (i=1;i<=t->size;i++)
{
if (T->table[i]->data==data)
{
Delete t->table[i];
t->table[i]=null;
}
}
}
void Direct_search_search (T *t,int data)
{
int i;
BOOL Isexist=false;
for (i=1;i<=t->size;i++)
{
if (T->table[i]->data==data)
{
printf ("In existence%d", i);
Isexist=true;
}
}
if (Isexist==false)
{
printf ("This number does not exist \ n");
}
}
int main (void)
{
int key;
t* t= (t*) malloc (sizeof (t));
T_create (t);
printf ("Please enter some values to end \ n");
int ch;
int i=1;
while (scanf ("%d", &ch) ==1)
{
Node *node= (node *) malloc (sizeof (node));
node->key=i;
node->data=ch;
Direct_search_insert (T,node);
i++;
}
printf ("How much do you want to find:");
Fflush (stdin);
scanf ("%d", &key);
Direct_search_search (T,key);
return 0;
}
Results show
Direct addressing method of "hash list-Direct addressing method" containing satellite data