## Chronus Interview Question

Interns**Country:**India

**Interview Type:**In-Person

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

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

}

inversion count problem,can be done in nlogn

- Hector August 24, 2013