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 <abhi120...@gmail.com>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 <ashot...@gmail.com>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: algogeeks@googlegroups.com [mailto:algogeeks@googlegroups.com] On >> Behalf Of Gobind Kumar Hembram >> Sent: Friday, June 22, 2012 2:01 PM >> To: algogeeks@googlegroups.com >> 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 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. >> >> > > > -- > 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 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, 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 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.