Microsoft Interview Question for Senior Software Development Engineers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

class terminal
{
}

Terminal will have multiple objects of Runway
class Runway
{
string type;
Ctime t // class which holdsTime occupied
}

class Aircraft
{
}

class <NameOfAircraft> : Aircraft
{
}

In the main program I can stacks depending on the size of runways.
1 stack for small runways and second for long runways
Depending on the type of aircraft and runway runway is allocated and that stack is popped. Once it gets freed, stack gets pushed

- DashDash April 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Didn't understand the last part with Stack, is the idea is the requesting aircrafts ( for terminal ) goes into the stack (Push) ? if so the last requesting aircraft gets the terminal.

- abc April 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The Stack consists of the list of runways. I will have 2 stacks one for long runways and other for short runways. Whenever an aircraft comes we will pop a runway from the stack depending upon the size requirement and when the aircraft leaves runway we will push into a stack

- DashDash April 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How would you prioritize certain aircraft? For example, one might be low on fuel.

- DJ April 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How would you prioritize certain aircraft? For example, one might be low on fuel.

- DJ April 24, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

We can use priority queue to prioritize the aircrafts(like is an aircraft is low on fuel then it should get highest priority)

- Baahu July 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

This seems to me a concurrent application

Something like this:

class Runway implements Runnable{
	
	private final BlockingQueue<Aircraft> requests;
	
	public Runway(){
		requests = new LinkedBlockingQueue<Aircraft>();
	}
	
	public void requestLanding(Aircraft a){
		try {
			requests.put(a);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void dispatchRequest() {
		Aircraft a;
		try {
			a = requests.take();
			a.land();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}
	
	public void run(){
		while(true) {
			dispatchRequest();
		}
	}
}


class Aircraft{
	public void land(){
	    Thread.sleep(2000);
	}
}

- Cassio June 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Terminal
        {
            private class WaitingRunwayRequestor
            {
                public IRunwayRequestor runwayRequestor;
                public int minLength;
            }

            public List<Runway> AvailableRunways{get;set;}
            public List<WaitingRunwayRequestor> WaitingRunwayRequestors { get; set; }

            public Terminal()
            {
                AvailableRunways = new List<Runway>();
                WaitingRunwayRequestors = new List<WaitingRunwayRequestor>();
            }

            public void RequestRunway(IRunwayRequestor runwayRequestor, int minLength)
            {
                Runway allocatedRunway=null;

                foreach (Runway runway in AvailableRunways)
                {
                    if (runway.length >= minLength)
                    {
                        allocatedRunway = runway;
                        runwayRequestor.AssignRunway(runway);
                    }
                }

                if (allocatedRunway != null)
                {
                    AvailableRunways.Remove(allocatedRunway);
                }
                else
                {
                    WaitingRunwayRequestors.Add(new WaitingRunwayRequestor() { runwayRequestor = runwayRequestor, minLength = minLength });
                }
            }

            public void ReturnRunway(Runway runway)
            {
                WaitingRunwayRequestor allocatedRunwayRequestor = null;

                foreach (WaitingRunwayRequestor waitingRunwayRequestor in WaitingRunwayRequestors)
                {
                    if (waitingRunwayRequestor.minLength <= runway.length)
                    {
                        allocatedRunwayRequestor = waitingRunwayRequestor;
                        waitingRunwayRequestor.runwayRequestor.AssignRunway(runway);
                    }
                }
                if (allocatedRunwayRequestor != null)
                {
                    WaitingRunwayRequestors.Remove(allocatedRunwayRequestor);
                }
                else
                {
                    AvailableRunways.Add(runway);
                }
            }

        }
        public class Runway
        {
            public readonly int length;
            public readonly Terminal terminal;//same runway cannot be at 2 terminals

            public Runway(Terminal terminal, int length)
            {
                this.terminal = terminal;
                this.length = length;
            }
        }
        
        public interface IRunwayRequestor
        {
            void AssignRunway(Runway runway);
            void ReturnRunway();
        }
        public abstract class RunwayRequestor
        {
            public Runway AssignedRunway{get; set;}
            public Terminal Terminal { get; set; }

            public virtual void AssignRunway(Runway runway)
            {
                this.AssignedRunway = runway;
            }
            public virtual void ReturnRunway()
            {
                Terminal.ReturnRunway(AssignedRunway);
                AssignedRunway = null;
            }
        }
        public class Aircraft : RunwayRequestor
        {
            public Aircraft(Terminal terminal)
            {
                this.Terminal = terminal;
            }

            public override void AssignRunway(Runway runway)
            {
                base.AssignRunway(runway);
                Land();
            }
            public void Land()
            {
                //perform takeoff

                ReturnRunway();
            }
        }
        public class MaintenanceCrew : RunwayRequestor
        {
            public MaintenanceCrew(Terminal terminal)
            {
                this.Terminal = terminal;
            }

            public override void AssignRunway(Runway runway)
            {
                base.AssignRunway(runway);
                PerformMantenance();
            }
            public void PerformMantenance()
            {
                //perform maintenance

                ReturnRunway();
            }

        }

- pretentious.bastard February 25, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More