## Microsoft Interview Question Software Engineer / Developers

• 0

Given a satellite picture with islands in ocean, how would you count the number of islands?

Team: Bing
Country: India
Interview Type: Phone Interview

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

Start traversing the picture
----> If found an unfound land pixel
--------> DFS traverse all connected land pixels mark all of them found

Number of islands = Number of DFS traversals started for land pixels

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

Any closed shape of sufficient area containing color other than blue as majority can be considered an island.

This is just a basic idea but can be helpful if a programming approach is to be used.

Comment hidden because of low score. Click to expand.
0

Other than the blue color, use dfs to find disconnected graphs. Each disconnected graph is counted as an island.

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

Perform image segmentation to get the number of islands.

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

separate the picture into n by m grids, you shall know the resolution of the picture so make sure each tile is at least 4 times smaller than an minimum island. then count all connected tiles other than blue as one, sum them up to get the number of islands.

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

We can do this by using the Connected Components algorithm that uses the Union-Find data structure. To account for different shades of same color we can define a function that will return true if difference between color attributes of neighbouring pixels are within some configurable threshold.

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

Perform a Fourier transform using polar coordinates and find the spikes of concentric radii that differ in phase using the color as a complex magnitude. They will be evident by the difference in continuity of the transform.

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

Connected components Algorithm or DFS/BFS can be applied once you convert the given satellite picture into a graph/tree which is practically not a good practice.

This is a Machine Learning question. You need sample data (if supervised learning is to be implemented).

Comment hidden because of low score. Click to expand.
0
of 2 vote

You don't need machine learning for this. This is a popular image processing problem called blob counting.

Basic idea is to:
Convert to gray-scale, low-pass filter to get rid of any noise, count blobs.

Search for "image processing blob counting" if you want something more concrete.

Name:

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

### Books

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

### 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.