Instead of doing hashing why cant you jut sort array and print the First letter 
when it changes.(Anyway the output you printed looks sorted within the hash 
bucket).So it will reduce the complexity of "hashing" and no extra storage.



________________________________
 From: Bhaskar Kushwaha <[email protected]>
To: [email protected] 
Sent: Friday, 22 June 2012 10:14 PM
Subject: Re: [algogeeks] Programming Question
 

simple hashing employing overflow with chaining
the hasing function maps a string to the first character of the string



On Fri, Jun 22, 2012 at 8:41 PM, Abhishek Sharma <[email protected]> wrote:

make a hashtable where,
> key is the first character of each word and,
> value is a list which contains index of each word starting with that 
>character.
>Now, sort that hash table wrt keys.
>Now print each each key and words corresponding to that key ( given by 
>arr[index1], arr[index2] ) 
>
>
>
>On Fri, Jun 22, 2012 at 5:55 PM, Ashot Madatyan <[email protected]> wrote:
>
>1. read the file one char at a time, and tokenize the standalone words (stop
>>char is either space or comma or eol)
>>2. put each parsed word in a structure "map<char, vector<string> >", where
>>the char is the key (the first letter of each scanned word). You are
>>basically creating a hash table here.
>>3. now print the hash table content using the formatting of your choice.
>>
>>Rgds,
>>Ashot
>>
>>
>>-----Original Message-----
>>From: [email protected] [mailto:[email protected]] On
>>Behalf Of Gobind Kumar Hembram
>>Sent: Friday, June 22, 2012 2:01 PM
>>To: [email protected]
>>Subject: [algogeeks] Programming Question
>>
>>I was asked this question in one company Programming Round.Please help
>>me in solving this,I tried with array of pointers ,2-D array and by
>>buffering.
>>
>>You have a file with names of brands separated by comma. Write a
>>program (in language of your choice) to group them by their starting letter.
>>
>>For example, if the input file is this:
>>Reebok, Puma, Adidas, Clarks, Catwalk, Converse, FILA, Lotto, Newfeel,
>>Nike, Numero Uno, New Balance, ASICS, Carlton London, Crocs
>>
>>The program should print the following:
>>A
>> ASICS, Adidas
>>
>>C
>> Carlton London, Catwalk, Clarks, Converse, Crocs
>>
>>F
>> FILA
>>
>>L
>> Lotto
>>
>>N
>> New Balance, Newfeel, Nike, Numero Uno
>>
>>P
>> Puma
>>
>>R
>> Reebok
>>
>>--
>>You received this message because you are subscribed to the Google Groups
>>"Algorithm Geeks" group.
>>To post to this group, send email to [email protected].
>>To unsubscribe from this group, send email to
>>[email protected].
>>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 [email protected].
>>To unsubscribe from this group, send email to 
>>[email protected].
>>For more options, visit this group at 
>>http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
>
>-- 
>Abhishek Sharma
>Under-Graduate Student,
>PEC University of Technology
>
>
-- 
>You received this message because you are subscribed to the Google Groups 
>"Algorithm Geeks" group.
>To post to this group, send email to [email protected].
>To unsubscribe from this group, send email to 
>[email protected].
>For more options, visit this group at 
>http://groups.google.com/group/algogeeks?hl=en.
>


-- 
regards,
Bhaskar Kushwaha
Student
CSE
Third year
M.N.N.I.T.  Allahabad


-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to