Reverse the given Array without using built in function | Algorithms
Objective: Given a array, write an algorithm to reverse the array.
static int [] a;
public static void reverseIteration(){
int start =0;
int end = a.length-1;
while(start<=end){
int temp = a[start];
a[start] = a[end];
a[end] = temp;
start++;
end--;
}
}
public static void reverseRecursive(int start, int end){
if(start<=end){
int temp = a[start];
a[start] = a[end];
a[end] = temp;
start++;
end--;
reverseRecursive(start, end);
}
}
Read full article from Reverse the given Array without using built in function | Algorithms
Objective: Given a array, write an algorithm to reverse the array.
static int [] a;
public static void reverseIteration(){
int start =0;
int end = a.length-1;
while(start<=end){
int temp = a[start];
a[start] = a[end];
a[end] = temp;
start++;
end--;
}
}
public static void reverseRecursive(int start, int end){
if(start<=end){
int temp = a[start];
a[start] = a[end];
a[end] = temp;
start++;
end--;
reverseRecursive(start, end);
}
}
Read full article from Reverse the given Array without using built in function | Algorithms