Adobe Interview Question for Software Engineer / Developers






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

My approach:

transpose(A,k,N){
if(k==N)
return;

for(i = k+1;i <= N;i++)
{
// swap a[i,k] with a [k,i]
}
transpose(A,k+1,N);

}

- random September 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I guess your approach is fine, but would you mind explaining the answer a bit with a simple example for others to follow. thank you.

- masamushi September 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks for the suggestion masamushi!

Following is the explanation..

First the iterative approach which is pretty simple.
Start at the beginning ( a(1,1)) of the diagonal matrix,and swap every element on the 1st row with the corresponding element on
the 1st column. Then do the same thing with the next element on the diagonal matrix viz. a(2,2),and so on. Once you reach the last
element on the diagonal matrix ,you need not do anything - the matrix is already transposed at this stage.

For the recursive approach, we can have the function transpose(A,k,n) where A is the matrix, k the current location on the diagonal matrix,
and N the order of the matrix (the square matrix)

Then the following code works similar to the iterative approach

transpose(A,k,N){
// if reached end of diag matrix,return
if(k==N)
return;
// interchange the elements on the k-th row with the corresponding elements of the k-column starting at a(k,k)
for(i = k+1;i <= N;i++)
{
// swap a[i,k] with a [k,i]
}

// recursively call the transpose function on the smaller square matrix starting at k+1
transpose(A,k+1,N);

}

- random September 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

why is the swapping commented out in your code? w/o that, the current code will just return the orig matrix

- jai ho September 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't remember much.. but can transpose be found only for a square matrix!!

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

Assumption : Matrix is a square matrix.
@Hello - Non-Square matrix do hava a Transpose matrix associated to it.

void Transpose(int input[][] matrix, int iterationCount){
if(iterationCount == 0) return;
for(int i= 0 ; i< iterationCount ;i++){
Swap(input[iterationCount][i],input[i][iterationCount]);
}
Transpose(matrix, iterationCount-1);
}

- Ankush Bindlish November 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

gggg

- gg February 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for (int d=0;d<n;d++)
for (int j=1;d+j<n;j++)
swap(a[d,d+j],a[d+j][d]);

- nutcracker July 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void Transpose(int** A, int N) // Square size - 1
{
    if(N == 0) // Transpose of a 1 X 1 Matrix
        return;
    else
    {
        Transpose(A,N-1);
        for(int i=0; i<N; i++)
        {
            int temp = A[i][N] ;
            A[i][N] = A[N][i];
            A[N][i] = temp;
        }
   }
}

Each recursion solves a N X N matrix.

- Saumitra Bhave August 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void transpose(int **a, int x)
{
if(x==n-1) return;
int i;
for(i=x;i<n;i++) swap(a[x][i],a[i][x]);
transpose(a,x+1);
}

- sweetest September 17, 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