Number of inversions in an Array.

Write a function which will accept an array and count the number of inversions in the array. Inversions in an Array are a measure of how far an array is sorted. Two elements in an array (say arr[i] and arr[j]) are said to be forming inversion iff, arr[i] > arr[j]  AND  i < j

Making both elements of an array zero

Given an Array of two elements one of which is 0, the other is either 0 or 1. You have to make both the elements of array 0. But following are the constraints:

Run Length Encoding

What is “Run Length Encoding (RLE)” ? Write a function, which will accept a string and convert it to a Run Length Encoded string.

Work & Time question

A man can do a piece of work in 60 hours. If he takes his son with him and both of them work together, then the work is finished in 40 hours. How long will the son take to do the same job, if he worked alone on the job?

C language MCQ

What will the below function return when it is called for n=1 as fun(1). Treat is as the first call to fun function, so i is not initialized earlier. int fun(int n) { static int i = 1; if (n >= 5) return n; n += i; i++; return fun(n); }

Compare Asymptotic Complexities

Arrange the below functions in the increasing order of their asymptotic complexity: A(n) = 2n B(n) = n3/2 C(n) = n * lg(n) D(n) = nlg(n)

Freeing memory allocated to n-dim array using free

Yesterday we learned about how to allocate memory on heap for an n-dim array using Malloc. Today let us see how to deallocate the memory on heap using free. It is Simple if we are deallocating normal pointers or pointers pointing to a one-dimensional array. How will deallocate memory of an n-dim array on heap?