Write the definition of the function move Nth Front that tak
Write the definition of the function move Nth Front that takes as a parameter a genie and a positive integer, n The function moves the nth element of the genie to the front. The order of the remaining elements remains uncharged. For example, suppose genie = {5, 11, 34, 67, 43, 55}, and n = 3 After a call to the function genie = {34, 5, 11, 67, 43, 55}
Solution
queue NthFront(Queue qu[], int n) {
int previous = qu[n-1]; //Assuming queue starts from index 0
for(int i=0; i<n; i++) {
int next = qu[i];
qu[i] = previous;
previous = next;
}
return qu;
}
