Microsoft Interview Question for Software Engineer / Developers






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

What do you mean by setting a pixel exactly? Is it setting the value to 1? Since it is a monochrome monitor, all we have is Os and 1s. If the image is of size 800 by 600, then we need an array as big as 800 * 600 (800 rows and 600 cols). So, iterate through each element in the array and keep track of the cols and rows and set the bits accordingly..please correct me if I am wrong...

- noviceprog September 27, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes. The pixel has to be set to 1. Given the x and y coordinate of the screen you need to index into the array to set it.

- Hello World September 27, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Given pixel(x, y) element in the 1D array is x*800+y.

To add Monochrome doesn't mean just one color. It is shades of a single color.

- Satish September 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Should first check the boundary condition of x, y. Make sure the point is actually with 800 * 600. Image what would happen if given a point (1, 700).

- Ke February 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

assumed the 1D array is a bit array which givs either present or absent of the pixel

long count = 0;
while(count < 480000/*=800x600*/)
{setpixel(count%800/*x*/, count/800/*y*/,/*color*/);count++;}

- mail2vcp@gmail.com September 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If the pixels are stored in row major, we need to set the array's index(say i) given x, y.
and assuming 1,1 is at top left corner and array index starts from 0

i = (y-1)*800 + (x - 1)

screen resolution is columns x rows

- onion834 September 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Shoud it be i = (y-1)*799 + (x - 1) ?

- Anonymous November 06, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

why should it be?

- onion834 November 06, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is bit vector.

- Anonymous October 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

shouldn't it be (y-1)*600+x;

- onion daddy July 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assume the screen has 800 rows and 600 columns.Initialize the screen as a 1D array

int *ptr = (int *) malloc (800*600*sizeof(int));

Now if I want to set the pixel (400,300) = (i,j)

int i = 400;
int j = 300;

*((600*i)+ ptr + j) = 1;

Am I correct?

- nick April 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes nick i think u are right..

- ridercoder October 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

address_index=base_adrees+(row)*600*sizeof(int)+col;
*address_index=1;

and also check if (row)>=0 and row<800 and col>=0 and col<600;

- ridercoder October 21, 2010 | 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