Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sort table vs hashed table

Former Member
0 Likes
7,492

Can somebody tell me when I should use sort table and when hashed table?

Edited by: Comandante Che Guevara on Oct 14, 2008 12:23 PM

1 ACCEPTED SOLUTION
Read only

jordi_escodaruiz
Active Participant
0 Likes
2,723

Hi

It depends on your needs.

Hashed table access is by key, search time is independent of register number. You can use it when you have large amount of register, and you want to retrieve data very quickly.

In sorted table, if you access by the sorted key, you can specify BINARY SEARCH. Search time depends on register number, but not so much, since is logarithmic. If you access by another key (not sorted key), search is sequential and depends much on amount of data.

3 REPLIES 3
Read only

Former Member
2,723

Hashed table:

1)Only Key access possible, no index access

2)Unique Key is required

Hashed table shud be used if the internal table is too large.

Sorted Table:

1)Both Index and key acess possible

2)Unique/Non unique Key

Append is possible only with Standard tables, so it cannot be performed on hashed and sorted table.

Insert is possible in all the three tables but has different effects in all three:

in sorted table : it is inserted at the right place depending on the key.

in Hased Table : Inserted according to Hash algorithm.

Regards

Read only

jordi_escodaruiz
Active Participant
0 Likes
2,724

Hi

It depends on your needs.

Hashed table access is by key, search time is independent of register number. You can use it when you have large amount of register, and you want to retrieve data very quickly.

In sorted table, if you access by the sorted key, you can specify BINARY SEARCH. Search time depends on register number, but not so much, since is logarithmic. If you access by another key (not sorted key), search is sequential and depends much on amount of data.

Read only

Former Member
0 Likes
2,723

Hi,

Hashed table & Sorted table are a kind of access modes.

The access mode defines how to access the data in the internal table defined by the table type when performing key operations. In particular, it defines whether key accesses to the internal table are allowed.

Sorted table:

The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is dependent on the number of entries in the internal table.

Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.

Hash table:

The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.

You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).

Thanks,

Nitesh Jain