Qualcomm Interview Question for Software Engineer in Tests






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

Can you please elaborate on this question? Bcoz What I am guessing is you are trying to tell that Build a 5x5 matrix from 1-25 where each row,column and diagonals have same sum? Am I right?

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

Could you explain the questions in further detail? I do not understand.

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

ALso can you please let me know how did you plan to use the recursion. I can not think of a way

- Anonymous November 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ALso can you please let me know how did you plan to use the recursion. I can not think of a way

- Anonymous November 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for filling an array without repeating random number:
int min=0;
int max=0;
for i 0 to 99
arrayname[i]= min + (int)(Math.random*(max-min+1))
min++;
max++;
rof

- sp!de? March 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How do you prove your matrix is random ? In fact it is not !

- subhadeepmaji September 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

For second question you can use random function and use time as seed to generatr 1 to 100 unique numbers check each time if you have already used that number...

- Shahid Siddique June 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

srand(time(?)) will help u to get different (non identical matrix) between consequitve runs. it will not guarntee that the matrix elements will be unique.

- solx July 02, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I could not understand

- Anonymous July 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Observe that a matrix needs to be generated such that it a permutation of 1..100. Let us call is PI(1..100), if you generate a permutation of 1..100 and populate the matrix in any fashion you wish then you get a random matrix of 1..100.

To generate a random permutation of 1..100, the probability of generation of a particalr permutation say p should be = 1/ (100) !

that is pr { PI=p} = 1/100! for all p in PI(1..100)

Pr{PI=p}= 1/100! = 1/100 * 1/99 * 1/98 .......* 1/2 * 1

therefore you should be able to generate the first element with probability 1/100
second with 1/99 and so on and that would make p a random permutation.

To do this job initialize an array A={1,2,.......100}
generate an index between 0 to 99 using random function of ur choice
and choose A[index] now do a compaction of the array form index+1 to 99
so that the array has all elements in 1..100 except A[index] and array
elements occupy positions 0...98

repeat the above proc again this time generating random numebr between 0 to 98.

- subhadeep September 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

That's a magic square.

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

static int matrix[25] = { 1, 2, ... 25 };

void draw(int * pRandom1, int * pRandom2)
{
*pRandom1 = rand();
*pRandom2 = rand();
//NOTE, make sure the random1 and random2 are not identical.
}

void GenMatrix(const int MaxDrawTimes)
{
int r1, r2;

for (int i =0 ; i < MaxDrawTimes; ++i)
{
//Exchange eletements according to random draw
draw(&r1, &r2);
matrix[r1] <===> matrix[r2];
}
}

int main(int argc, char* argv[])
{
GenMatrix(rand());
//Print out generated matrix.
return 0;
}

- Ian F. April 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Seems this is to let you generate matrix with a random algorithm in a very simple way.
Above idea is to use a fixed initialization layout and do several random rounds of item exchanges in a high performance.

- Ian F. April 13, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the question was about the Magic Square too. Here is the perfect example.
ideone.com/wD2EpN

- Maddy March 30, 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