[algogeeks] Re: Hash Table

2011-10-27 Thread ligerdave
from high level and with a very few collisions, it's O(1).

there isn't much to prove because this is based on a common sense.

for example, have the world as a hashtable and all countries as the keys of 
it. boxes(storage) marked by different country names(key) and you know 
where to locate them. now, you are given a mail and asked to put it into 
the box which goes to its destination country. 
so how many operations does it take you to put a mail in the box? 1
if you realized the mail wasn't misplaced and you need to take it out, how 
many operations does it take you to take the mail out of the box?

i hope this helps a bit

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/ZamCyJETdscJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
If N Element is already hashed and when you insert next element , Does
hashing will take log N time to find the next available position? Actually
the next insertion typically does not have any co-relation to pre-existing
table content (Until your Hash function is badly designed to hash always on
the same key everytime). So, its actually the design of Hash that has to be
efficient.Hence every operation cannot be mapped to the number of data which
is present in the existing table.

On Thu, Oct 27, 2011 at 12:49 AM, ligerdave david.c...@gmail.com wrote:

 from high level and with a very few collisions, it's O(1).

 there isn't much to prove because this is based on a common sense.

 for example, have the world as a hashtable and all countries as the keys of
 it. boxes(storage) marked by different country names(key) and you know where
 to locate them. now, you are given a mail and asked to put it into the box
 which goes to its destination country.
 so how many operations does it take you to put a mail in the box? 1
 if you realized the mail wasn't misplaced and you need to take it out, how
 many operations does it take you to take the mail out of the box?

 i hope this helps a bit

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/ZamCyJETdscJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread kumar raja
suppose the problem is
Problem 4: Find all unique pairs of element in an array that sum to S. For
ex. If array = {2,4,6,4,6} and S = 8 then answer is {2,6, 4,4}

suppose we use STL c++ hash class to solve the problem . In the first we
hash all the elements . in the second pass we take each element and subtract
it from '8' and then we search for that difference in the hash table. if it
is found then the pair exists .otherwise it does not exist.

My questions are
1) What is the space complexity used by hash table . is it O(n) becoz 'n'
elements are hashed into hash table.
2) Does the time to search an element is hash table is still O(1) ,but there
are 'n' elements in hash table .Then how could it be O(1)

Please clear my above doubts .These doubts are haunting me .I am very
thankful to them ...

On 27 October 2011 06:18, Prem Krishna Chettri hprem...@gmail.com wrote:

 If N Element is already hashed and when you insert next element , Does
 hashing will take log N time to find the next available position? Actually
 the next insertion typically does not have any co-relation to pre-existing
 table content (Until your Hash function is badly designed to hash always on
 the same key everytime). So, its actually the design of Hash that has to be
 efficient.Hence every operation cannot be mapped to the number of data which
 is present in the existing table.


 On Thu, Oct 27, 2011 at 12:49 AM, ligerdave david.c...@gmail.com wrote:

 from high level and with a very few collisions, it's O(1).

 there isn't much to prove because this is based on a common sense.

 for example, have the world as a hashtable and all countries as the keys
 of it. boxes(storage) marked by different country names(key) and you know
 where to locate them. now, you are given a mail and asked to put it into the
 box which goes to its destination country.
 so how many operations does it take you to put a mail in the box? 1
 if you realized the mail wasn't misplaced and you need to take it out, how
 many operations does it take you to take the mail out of the box?

 i hope this helps a bit

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/ZamCyJETdscJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread ligerdave
I am a bit confused. Are you talking about the runtime of hash function 
itself or to find the position. 
Agree on the efficient hash function design. However, no function could be 
designed to fit all cases. A key to make a particular hash function 
efficient is to know the potential data size.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
Well, if we talk abt space complexity in Hash.. M srry we require O(n)
for Hash Datastructure... As each Bucket can contain at most one data
value of Key Value pair,thats where key is gonna hash your value..

However, when we talk abt time complexity, its alwayz, the Hash
Function dependable question...

On 10/27/11, ligerdave david.c...@gmail.com wrote:
 I am a bit confused. Are you talking about the runtime of hash function
 itself or to find the position.
 Agree on the efficient hash function design. However, no function could be
 designed to fit all cases. A key to make a particular hash function
 efficient is to know the potential data size.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread kumar raja
@Prem :
So is the time complexity is O(1) or O(log n) or O(n)???

On 27 October 2011 07:28, Prem Krishna Chettri hprem...@gmail.com wrote:

 Well, if we talk abt space complexity in Hash.. M srry we require O(n)
 for Hash Datastructure... As each Bucket can contain at most one data
 value of Key Value pair,thats where key is gonna hash your value..

 However, when we talk abt time complexity, its alwayz, the Hash
 Function dependable question...

 On 10/27/11, ligerdave david.c...@gmail.com wrote:
  I am a bit confused. Are you talking about the runtime of hash function
  itself or to find the position.
  Agree on the efficient hash function design. However, no function could
 be
  designed to fit all cases. A key to make a particular hash function
  efficient is to know the potential data size.
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread kumar raja
I am asking for the above quesiton

On 27 October 2011 07:38, kumar raja rajkumar.cs...@gmail.com wrote:

 @Prem :
 So is the time complexity is O(1) or O(log n) or O(n)???


 On 27 October 2011 07:28, Prem Krishna Chettri hprem...@gmail.com wrote:

 Well, if we talk abt space complexity in Hash.. M srry we require O(n)
 for Hash Datastructure... As each Bucket can contain at most one data
 value of Key Value pair,thats where key is gonna hash your value..

 However, when we talk abt time complexity, its alwayz, the Hash
 Function dependable question...

 On 10/27/11, ligerdave david.c...@gmail.com wrote:
  I am a bit confused. Are you talking about the runtime of hash function
  itself or to find the position.
  Agree on the efficient hash function design. However, no function could
 be
  designed to fit all cases. A key to make a particular hash function
  efficient is to know the potential data size.
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in





-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Vicki Wen
@Kumar: It's O(1) for searching an element in hash table as long as there is
no collision.

-Vicki

On Thu, Oct 27, 2011 at 10:38 AM, kumar raja rajkumar.cs...@gmail.comwrote:

 @Prem :
 So is the time complexity is O(1) or O(log n) or O(n)???


 On 27 October 2011 07:28, Prem Krishna Chettri hprem...@gmail.com wrote:

 Well, if we talk abt space complexity in Hash.. M srry we require O(n)
 for Hash Datastructure... As each Bucket can contain at most one data
 value of Key Value pair,thats where key is gonna hash your value..

 However, when we talk abt time complexity, its alwayz, the Hash
 Function dependable question...

 On 10/27/11, ligerdave david.c...@gmail.com wrote:
  I am a bit confused. Are you talking about the runtime of hash function
  itself or to find the position.
  Agree on the efficient hash function design. However, no function could
 be
  designed to fit all cases. A key to make a particular hash function
  efficient is to know the potential data size.
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Hash Table

2011-10-27 Thread Prem Krishna Chettri
One sentence answer to your query is all Hash DataStructure is suppose
to provide Constant Time Complexity .i.e.O(1). However as an when
HashTable fills up,Data Value collision occurs becoz,common key will
generated by HashFunction.Thats where HashFunction dependibility comes
into picture..
 Well the Worst Case of Time Complxity extremgely poor hash function
may go upto O(n). Which is very rare and when data is hash table is
fully filled with all colliding values..

On 10/27/11, kumar raja rajkumar.cs...@gmail.com wrote:
 I am asking for the above quesiton

 On 27 October 2011 07:38, kumar raja rajkumar.cs...@gmail.com wrote:

 @Prem :
 So is the time complexity is O(1) or O(log n) or O(n)???


 On 27 October 2011 07:28, Prem Krishna Chettri hprem...@gmail.com wrote:

 Well, if we talk abt space complexity in Hash.. M srry we require O(n)
 for Hash Datastructure... As each Bucket can contain at most one data
 value of Key Value pair,thats where key is gonna hash your value..

 However, when we talk abt time complexity, its alwayz, the Hash
 Function dependable question...

 On 10/27/11, ligerdave david.c...@gmail.com wrote:
  I am a bit confused. Are you talking about the runtime of hash function
  itself or to find the position.
  Agree on the efficient hash function design. However, no function could
 be
  designed to fit all cases. A key to make a particular hash function
  efficient is to know the potential data size.
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/G_0Wm4NQIyIJ.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in





 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Hash Table

2011-10-25 Thread Don
It can be true if the hash table is used properly. If the table
becomes too full or the hash function produces too many collisions it
will not be constant time. So designing the hash system well remains
very important.
Don

On Oct 25, 12:15 am, kumar raja rajkumar.cs...@gmail.com wrote:
 I have read that Hash table provides storing/search operations in constant
 time.

 Is it true?? How to prove it??

 I have not found any sort of proof for it...

 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Hash Table

2011-10-24 Thread kumar raja
When the number of elements increases gradually ,the complexity must
increase .so it the situtaion is like it has to store all the 'n' elements
then all the basic operations require  O(log n) time.so how it is constant
always i am not getting...

On 24 October 2011 22:15, kumar raja rajkumar.cs...@gmail.com wrote:

 I have read that Hash table provides storing/search operations in constant
 time.

 Is it true?? How to prove it??

 I have not found any sort of proof for it...

 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in





-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: hash

2011-09-17 Thread Rahul Verma
Is there any function or template is available in C++ STL for the Has 
Function?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/q5NgwJPaAFMJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: hash

2011-09-17 Thread Nitish Garg
Wow Don!
You did a perfect job explaining hash functions for C.
Thanks a lot.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/bFBkFT_DytQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: hash

2011-09-16 Thread Don
There are entire books on the subject, so I can't give you everything,
but here's a quick summary:

First you need a hash function which maps your input to an index in
the table. Hashing strings is a common application, and there are a
lot of string hash functions. Most common is something like this:

int hash(char *s)
{
  int result = 0;
  for(int i = 0; s[i]; ++i)
result = 17 * result + s[i];
  return result;
}

You would then use mod to map the return value into the size of the
hash table.

There are better hash functions, but that one is not bad for most
purposes.

The next issue to deal with his how to handle collisions. There is
always the possibility that two values will map to the same spot in
the hash table, and the more full the table gets, the more that will
happen.

The most basic method is linear probing, in which you simply check the
next slot, and then the next, etc. until you find an empty slot. There
are several problems with this scheme. First, as the table gets full
it tends to create big clumps of filled cells, which reduces the
efficiency of searching and adding to the table. Secondly, when you
want to delete from the table, you might leave some other element in a
spot where it won't be found. That's because with this scheme, the
search table method must look in the location indicated by the hash
function, and if it is occupied, it must search each cell until it
finds one which matches or until it reaches an empty cell. If you
deleted one of the elements between the hash value of the element you
are searching for and the location where it was ultimately stored, you
will run into trouble if you are not careful. This is typically
addressed by marking a cell where an element has been deleted as
deleted. Then the search knows to keep looking past that location. A
cleanup can be run occasionally to put things back closer to where
they should be, but the cleanup is costly in terms of time, so you
don't want to do it too often.

Using a rehash function is a better way to deal with collisions. The
rehash is a different hash function which puts the element in another
location. I like to use a hash function which has a second parameter
which defaults to zero, but other values can be used to rehash a
string. Here is one:

int hash(char *str, int rehash=0)
{
  int result = rehash;
  for(int i = 0; s[i]; ++i)
result ^= s[result^str[i]];   // s[] is a permutation of values
0..255
  return result;
}

This has the nice characteristic that if hash(s1) == hash(s2),
hash(s1,1) and hash(s2,1) are likely to be different.

In some cases you can design a hash function which avoids collisions.
If you have 100 known strings to hash, you can usually use the second
function above and find a permutation s which results in no
collisions. Better yet, if you can control the hash tags, you can
ensure no collisions. In one case I was managing a set of up to N
items, and each one had a unique id tag. The tags didn't need to be
sequential, but each one had to be unique. So I assigned the tags by
building a queue of integers initialized with values 1..N. When I
needed an id for a new item I pulled it out of the queue, and when an
item was deleted, I added N to it's id and put that id into the queue.
This guaranteed that a hash function of id%N would never generate
collisions.

One of my favorite ways to deal with collisions is to have each cell
in the table be a bucket which can contain multiple elements. Making
it be a binary search tree is very nice, because it makes resolving
collisions into an O(ln n) operation rather than O(n) for linear
probing. If you already have a binary search tree class, you can just
make a table of them to use as a hash table.

In most cases you need to design in the ability to delete elements
from the hash table. If you don't need that ability, that makes your
job easier, but most applications do require it. You must make sure
that deleting one item doesn't affect searches on other items, and
that repeated insertions and deletes don't degrade the performance of
the hash table.

Chosing the right size for a hash table is very important. Hash table
performance degrades significantly when the table gets more than half
full. By the time it is 80% full you might as well be using a linear
search. Some hash systems use variable sized hash tables. But changing
size is very expensive because you must reinsert all the items into
the new table. You are better off, when possible, picking the right
size to start with.

There are many schools of thought on hashing, and many ways to tailor
a hashing system to a particular need. Think about the requirements of
your application and look for the best way to accomplish your specific
task.

I hope this helps.

Don

On Sep 16, 9:17 am, prasanth n nprasnt...@gmail.com wrote:
 can anyone tell how to implement a hash table in C?? how to choose the hash
 function?? algorithm??

 --
 *prasanth*

-- 
You received this message because you are subscribed to the 

[algogeeks] Re: Hash

2011-08-11 Thread Don
Yes. Linear probing, if done in the usual way, will end up at 2 if the
hash function returned values 1,2,7,8, 9, or 10. That is 6 of the 10
possible values, so if each one is equally likely, the probability is
0.6.
Don

On Aug 11, 3:04 pm, aditi garg aditi.garg.6...@gmail.com wrote:
 cud u xplain how?

 On Thu, Aug 11, 2011 at 11:31 PM, Tarun Arya tarun@gmail.com wrote:
  Rajeev sir,
  0.6 is correct :)

   --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Hash Table Design

2010-10-01 Thread ligerdave
First, if you have a set of unique usernames, those could be used to
be keys. How to generate hash is depends on your requirements. You can
add a few prefix chars or postfix

On Sep 30, 2:45 pm, amit amitjaspal...@gmail.com wrote:
 Design a hash table to store phone #s. Your job is to write a hash
 function that has a parameter username, and generate a key. Username
 is unique, length 5 and can be A-Z, 0-9, space. Write a hash function
 that generate keys without collisions and use minimum memory.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Hash Table Design

2010-10-01 Thread Gönenç Ercan
Use a trie, the memory needed will be less than having a list of
strings and it will be faster than hashTable (array implementation of
trie). Check Trie in Wikipedia. If the datastructure is going to be
static, then using a Directed acyclic finite automata (dafsa) may be
even better.

On Sep 30, 9:45 pm, amit amitjaspal...@gmail.com wrote:
 Design a hash table to store phone #s. Your job is to write a hash
 function that has a parameter username, and generate a key. Username
 is unique, length 5 and can be A-Z, 0-9, space. Write a hash function
 that generate keys without collisions and use minimum memory.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.