944,196 Members | Top Members by Rank

Ad:
Oct 31st, 2006
0

Hash tables in pascal

Expand Post »
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
type 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
procedure initialise(var h: HTable);
var i:integer;
begin
i:=0 ;
for i := 0 to tableSize-1 do
h[i]:= 0 ;
end;
is this correct and again should i be assigning everything a blank char ' ' ?

My display procedure is similar but it write to the screen
procedure display (h: HTable; filename: string);
var i:integer;
begin
i:=0  ;
for i := 0 to tableSize-1 do
begin
WriteLn ('#',i,': ',h[i]) ;
End;
end;
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
Last edited by mynameisrich; Oct 31st, 2006 at 10:35 am. Reason: to put code in code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mynameisrich is offline Offline
1 posts
since Oct 2006
Nov 2nd, 2006
0

Re: Hash tables in pascal

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
type 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
procedure initialise(var h: HTable);
var i:integer;
begin
i:=0 ;
for i := 0 to tableSize-1 do
h[i]:= 0 ;
end;
is this correct and again should i be assigning everything a blank char ' ' ?

My display procedure is similar but it write to the screen
procedure display (h: HTable; filename: string);
var i:integer;
begin
i:=0  ;
for i := 0 to tableSize-1 do
begin
WriteLn ('#',i,': ',h[i]) ;
End;
end;
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
Last edited by Daunti; Nov 2nd, 2006 at 1:13 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Daunti is offline Offline
2 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Tpx Error on load "Disk or EMS I/O failure"
Next Thread in Pascal and Delphi Forum Timeline: Pascal and Hex etc





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC