Hi, i have an assignment that involves me making a hash table which stores strings. I am struggling to find a good example of a hash table anywhere and would be greatful if someone could give me an idea of the basic code or even pseudocode for it.

ineed to
initialise the table
display the table
search it
and insert to it

my data type is

[B]type[/B] HTable = array [0 .. tableSize-1] of integer;

firstly- should it say string instead of integer?

my initialise procedure basically runs through the array assigning giving each item the value 0

[B]procedure[/B] initialise(var h: HTable);
[B]var[/B] i:integer;
[B]begin[/B]
i:=0 ;
[B]for[/B] i := 0 to tableSize-1 [B]do[/B]
h[i]:= 0 ;
[B]end[/B];

is this correct and again should i be assigning everything a blank char ' ' ?

My display procedure is similar but it write to the screen

[B]procedure[/B] display (h: HTable; filename: string);
[B]var[/B] i:integer;
[B]begin[/B]
i:=0  ;
[B]for[/B] i := 0 to tableSize-1 [B]do[/B]
[B]begin[/B]
WriteLn ('#',i,': ',h[i]) ;
[B]End[/B];
[B]end[/B];

this is how i have started and my program compiles but when i choose to display the list nothing at all happens, i have done something terribly wrong here?

thansk alot

Hi, i have an assignment that involves me making a hash table which stores strings. I am struggling to find a good example of a hash table anywhere and would be greatful if someone could give me an idea of the basic code or even pseudocode for it.

ineed to
initialise the table
display the table
search it
and insert to it

my data type is

[B]type[/B] HTable = array [0 .. tableSize-1] of integer;

firstly- should it say string instead of integer?

my initialise procedure basically runs through the array assigning giving each item the value 0

[B]procedure[/B] initialise(var h: HTable);
[B]var[/B] i:integer;
[B]begin[/B]
i:=0 ;
[B]for[/B] i := 0 to tableSize-1 [B]do[/B]
h[i]:= 0 ;
[B]end[/B];

is this correct and again should i be assigning everything a blank char ' ' ?

My display procedure is similar but it write to the screen

[B]procedure[/B] display (h: HTable; filename: string);
[B]var[/B] i:integer;
[B]begin[/B]
i:=0  ;
[B]for[/B] i := 0 to tableSize-1 [B]do[/B]
[B]begin[/B]
WriteLn ('#',i,': ',h[i]) ;
[B]End[/B];
[B]end[/B];

this is how i have started and my program compiles but when i choose to display the list nothing at all happens, i have done something terribly wrong here?

thansk alot

If you will go here www.sparknotes.com/cs/searching/hashtables/section1.html
you will find an excelent explanation of what you are trying to do with good examples of how. If you need further help with your code after you read it, post back.
Good Luck,
Daunti

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.