sanjay.rajputcse
BAN USERAn M-Way search tree for storing the data and 3 different tries each one for Countries, State, and Cities will do the trick.
Let me brief it...
Structure for Data.
1). A tree node will have a string, a pointer to it's parent and a head pointer to it's childrens list.
2). Root node will have string and parent pointer as NULL. And a head pointer to a list of countries.
3). All country will store it's name in string ,parent pointer to Root node and a head ponter to a list of it's states.
4). same goes for states they will store head ponter of a list of its cities.
Structure For Query
1). We will create a TRIE for all the countries and at the end of each leaf we will store the corresponding address of that country node in our tree.
2). Same we will create 2 more TRIES for the States and Cities.
Query
1). To get all the states for a country we will first search for country in Countries TRIE and get the address of that node and will just print it's children. O(Length(Country Name))
2). same we will do to get all the cities for a state will search in States TRIE, obtain address of node print it's children. O(Length(State Name)).
3). To get the state and country for a city first we search for the city in Cities TRIE obtain address of node. It's Parent will be it's State and it's GrandParent will be it's country in which the city exist. O(Length(City Name))
Repsherrymrex, Computer Scientist at CGI-AMS
I am Sherry from West Palm Beach USA, I started my journey in 2016 as a yoga teacher. I like ...
first reverse the content of both the file by doing following.
then just read one digit from both the file1 & file2 and add them and put it in file3.
Then reverse the content of file3.
- sanjay.rajputcse September 08, 2013