Adobe Interview Question for Accountants


Country: India
Interview Type: Written Test




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

permute(int arr[ ])
{
 for(int i=0;i<n;i++)
 {
       int k = rand_n() - 1
       int temp = arr[i];
       arr[i] = arr[k];
      arr[k] = arr[i];
 }

}

Time Complexity : O(n)

- AC Rush November 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It should be arr[k] = temp above

- AC Rush November 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The key should be "random" permutation. If it means "equal opportunity" for each permutation, the question is harder. If it doesn't mean "equal chance", it's much easier.

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

The key should be "random" permutation. If it means "equal opportunity" for each permutation, the question is harder. If it doesn't mean "equal chance", it's much easier.

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

I believe the question implies that you can get same index when you call rand function.

- Anonymous January 25, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

the expected running time would be :

1 + n(1/1 + 1/2 + 1/3 + 1/4 + ... + 1/(n-1))

- sonesh November 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

permute(int arr[ ])
{
 for(int i=0;i<n;i++)
 {
       int k = rand_n() - 1
       int temp = arr[i];
       arr[i] = arr[k];
      arr[k] = arr[i];
 }

}

Time Complexity : O(n)

- AC Rush November 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

permute(int arr[ ])
{
 for(int i=0;i<n;i++)
 {
       int k = rand_n() - 1
       int temp = arr[i];
       arr[i] = arr[k];
      arr[k] = arr[i];
 }

}

Time Complexity : O(n)

- AC Rush November 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

permute(int arr[ ])
{
 for(int i=0;i<n;i++)
 {
       int k = rand_n() - 1
       int temp = arr[i];
       arr[i] = arr[k];
      arr[k] = arr[i];
 }

}

Time Complexity : O(n)

- AC Rush November 03, 2012 | 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