Chronus Interview Question for Interns


Country: India
Interview Type: In-Person




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

inversion count problem,can be done in nlogn

- Hector August 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Please specify how do you define a position which is not in sorted order? With the help of an example please.

- Nomad August 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

0? The array is sorted already.
For unsorted arrays you have to be a little more specific.
[4 1 2 3] -> No number is in its position.
[1 2 4 3] -> [1 2] in order, [3 4] not.

Did you mean counting inversions?

- Ehsan August 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is the problem of finding all the occurrences where a[i]-i!=0. The array is sorted and we need to do a binary search to find all those elements that do not satisfy the this condition. It can be don in O(lg n).

- Anonymous August 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//when we say find the number of positions of the number that are not in sorted order, i assume that  array is partially sorted like this int[] ordered = {1,2,3,4,3,5,6,7,8};
public static void FindUnsortedElement(int[] array)
        {
            int unorder = 0;
            int index;
            for (int i = 1; i < array.Length-1; i++)
            {
                if (array[i - 1] < array[i] && array[i] < array[i + 1])
                 continue;
                else
                {
                    if (array[i - 1] > array[i])
                        unorder = array[i];
                    index = i;
                }
                
                
            }
            Console.WriteLine( "{0},{1}"unorder);
        }

- Alemayehu Woldegeorgis January 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#define n 10
void not_sorted(int arr[n])
{ int i;
for(i=0;i<n;i++)
{ if(arr[i]>arr[i+1])
{ printf("\n%d no is at incorrect position at %d",arr[i],i+1);
}}}
int main()
{ int array[n],i;
printf("\nenter the sorted array: ");
for(i=0;i<n;i++)
{ printf("\nenter %d num: ",i+1);
scanf("%d",&array[i]);}
printf("\n\narray is:\n");
for(i=0;i<n;i++)
{ printf("%d ",array[i]);}
not_sorted(array);
return 0;
}

- chugh.rachita January 31, 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