There is a firm that provides Mobile Operator 3 functions. 1. char[] get_number: to get a new number(10 digit) 2. bool is_allocated(char[]) : if the number is already allocated. 3. bool allocate(char[]) : allocate the number.
What data structure to use? We can use hash table to store the number that is already allocated. char[] get_number() { Generate the random 10 digit number. } bool is_allocated(char[] num) { Get the lock Hash the given number. Index the hash to the hash table. Look for collision. if collide return true else return false. release the lock } bool allocate(char[] num) { Get the lock hash the given number Index the hash to the hash table set the entry in the hash table for the given index. release the lock } -- 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.