Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

I would like to submit the following question I was asked
recently during my technical interview at Google.
I'm rephrasing the question to make it clear for everyone
to understand:

- You are going on a one-way flight trip that includes
billions of layovers.
- You have 1 ticket for each part of your trip (i.e: if
your trip is from city A to city C with a layover in city
B, then you will have 1 flight ticket from city A to city
B, and 1 flight ticket from city B to city C.
- Each layover is unique. You are not stopping twice in the
same city.
- You forgot the original departure city.
- You forgot the final destination city.
- All the tickets you have are randomly sorted.

Question are:
- Design an algorithm to reconstruct your trip with minimum
complexity.
- How would you improve your algorithm.

Example:
- randomly sorted:
New York->London
San Francisco-> Hong Kong
Paris->New York
London->San Francisco

- sorted:
Paris->New York
New York->London
London->San Francisco
San Francisco-> Hong Kong

Answer Posted / raghvendra

1) Assuming the data in 2 dim array. (2 Columns: FROM
destination & TO destination)
2) Sort the array (any standard sorting logic) using column
1 i.e. FROM destination.
3) Take "TO" destination value of row 1 and use binary
search to search its match in "FROM" destination column
from row 2 to n
If match found, adjust that row as row 2. (Swap
pointers in place of physical data)
Take "TO" destination value of row 2 and
use binary search to search its match in "FROM" destination
column from row 3 to n
continue this logic till as long as a match
is found.

if match not found.
Resort the remaining unadjusted rows
using "TO destination" column.
Take "From" destination value of
row 1 and use binary search to search its match in "To"
column in all unadjusted rows.
Match must be found otherwise data
incorrect. adjust that row as row -1. (Swap pointers in
place of physical data)
Continue this till end of the
array.

Now you have the sorted list.


I am sure there can better ways to achieve the same.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If Web site developer want to evaluate their current authoring tool, where would they start?

2000


give difference between generic & iterative process model.

2122


What is an authoring tool?

1921


what do you mean by Foreign exchange domain

3004


Discuss operations of CAD and CAM system.

921


what stage/s of the development lifecycle should end users be involved?

947


Write a command to find all of the files which have been accessed within the last 30 days. Output should be stored in a file “December.files”

3381


How would you create a footprint in your PCB designer software (say, Altium)?

979


What is the role of the W3C in Web accessibility?

2107


What is Make to Order, and what is the difference between Make to order and Make to Cash

2667


The procedure of hiring fresher’s in CEI is as follows. Only graduates from an engineering background with specialization in ECE (Electronics and Communications), Computer science and IT streams are accepted. We also accept students who have completed their Masters in Computer Applications. Only those candidates who have a score of 70% and above throughout their academics are considered. We follow a four level procedure for selecting any fresher to be part of our highly skilled technical team. These include: 1. Written Test 2. Technical Interview 1 – Conducted by CEI Developers 3. Technical Interview 2 – Conducted by CEI Project Managers 4. HR Discussion The written test is divided into 3 sections as mentioned below: 1. Logical: Critical Reasoning and Analytical Reasoning – 30 Questions 2. Quantitative Aptitude – 25 Questions 3. Technical Questions – 25 Questions Logical: These questions primarily test the analytical and critical thinking skills of the applicants. It tests the most integral skills of the applicant, the logical consistency in thought, understanding and processing data and making valid conclusions from them, and out of the box thinking. The best part about logical reasoning is that it does not require any learning or prior knowledge. Example: • If the positions of the first ten letters and the last ten letters in the English alphabet are interchanged such as that the first and the seventeenth the second and the eighteenth letters are interchanged and this continues till the tenth letter is interchanged with the twenty-sixth letter, which letter will be the fifth to the right of the twelfth letter from the right after this rearrangement? • There is a 3 digit number. The sum of the digits is 17, and two of the digits are the same. The unique digit subtracted from one of the other digits equals a positive even number. What is the digit that is different from the other two digits? Quantitative aptitude Section consists of questions related to Simplifications, Data Sufficiency, and from the topics of Arithmetic. For e.g.; Fraction, Profit and Loss, Combinations and Permutations, Percentage problems, Ratio, Probability, Allegations and Mixtures, Time and distance, Time and work, Measurements, etc. Example: • A sales person by mistake multiplied a number and got the answer as 3, instead of dividing the number by 3. What is the answer he should have actually got? • A traveler walks a certain distance. Had he gone half a kilometer an hour faster, he would have walked in 4/5 of the time, and had he gone half a kilometer an hour slower, he would have walked 2 ½ hours longer. What is the distance? • Two taps A and B fill a tank in 12 and 20 hours respectively and a third tap C empties it in 15 hrs. In how many hours will the tank be filled if the taps A and B are opened simultaneously and C is opened after two hours.? Technical Section consists of sections related to basics concepts of programming languages, and some basic entry level programming are given to assess the applicant’s ability to solve the program. Example: • An alternate to using interrupts for I/O devices is • The main advantage of using indexes is • PRODUCT Product ID Product Description Manufacturer ID MANUFACTURER Manufacturer ID Manufacturer Name Referring to the above table, what type of relationship exists between the Product table and the Manufacturer table?  Once a candidate clears the written test they will be considered for the second round.

3337


What is platform-driven design?

2230


How to Design a Good Ad?

1985


Ford Software engineer interview process and model questions

6005


What are the difference phases of software development? Explain briefly?

951