## 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

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.

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?

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).

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);
}``````

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;
}

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.

### 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.