22nd Feb, 2011 1. Inversions (25) An inversion in an array of real numbers A is any pair (i,j) such that iA[j]. For e.g. in the array [25,7,51,3], the inversions would be (0,1),(0,3),(1,3) and (2,3). You have to write a program which takes 7 distinct non-negative integers from the user as array entries. The program then should print out the inversions in the given array-each separated by a tab character. If there are no inversions in the given array (i.e. array is sorted), your program should output "No inversions here!" 2. Linked list (50) A singly-linked list is a data structure that consists of a sequence of nodes each of which contains a reference (i.e., a link) to the next node in the sequence. In a list though only the head (i.e. the first element of the list) can be accessed, to access the k-th element of the list, one must follow the references. You have to implement a list with the following two operations: a) addElement - adds an element at the tail of the list b) removeElement - removes an element at the head of list and shifts all the elements to the left and returns the removed element. For e.g. in a list {4,3,9}, addElement(25) would result in {4,3,9,25} whereas removeElement() results in {3,9} with 3 as the new head. Such a list can be modelled by intializing a global int array of size 10 and a counter to keep a count of number of elements in the list currently. To add a new element you will have to traverse (in a loop) all the elements of the array until you reach the tail and only then add it to the list. While removing, you will have to shift accordingly. Protoypes: void addElement(int elemToAdd) int remeoveElement() Create a list of 10 elements using addElement operation, print the resultant list. Then remove 5 elements out of it by using removeElement. You must print your list after every remove operation. Extra Credit : Make the above program menu driven. eg . Display the following menu : 1. addElement 2. removeElement 3. Exit Take input from user choosing the operation. Exit from program only if user chooses exit. 3. Euclid number (25) Primorial of n is defined as the product of first n prime numbers (first prime number is 2). For example, P(0) = 1 (base case); P(1) = 2; P(2) = 2 x 3 = 6 P(5) = 2 x 3 x 5 x 7 x 11 = 2310. This idea is a bit similar to that of factorial but here only successive primes are multiplied. Euclid numbers E(n) are positive integers of the form E(n) = P(n) + 1, where P(n) is the primorial of n. It is known that not all Euclid numbers are primes. You have to write a function which finds the nth Euclid number. Using this or otherwise write a function which prints (from n=1) all the Euclid numbers till the first composite Euclid number is encountered. In your solution you may want to write the following two helper functions: int getPrimorial(int k) : returns the primorial of k. int isPrime(int k): reports if k is a prime or not.