Amazon Interview Question
Software Engineer / DevelopersYou will have a class called Entry:
>phone_number: int
>name: string
>details of that person like email, address, alternate number....
>Two child objects of Entry - Entry Left, Entry Right
Then there will be a class called Phonebook
It will have a BST on this structure and use foll functioins:
void insert(Elem elem);
int delete(Elem elem); //return true if elem found and delete
Elem search(String Name);//or number
int update(Elem elem);
void display();
the main adv of storing in BST will be that while displaying alphabetically, u wont need to sort them.
other class can be groups:
to store some groups like friends, relatives, project__1, ...
each of them will have a linked list of the specified Element objects.
Members:
group_name;
List list;
sendToAll();
/* */
use tries
- vinaysachdeva23 November 03, 2010