1. Using high and low pointers we can initialize two poinetrs high and low and swapping arr[low] with arr[high] with reverse our main array(arr) without using any auxuliaary array*/
| 33 | /* 1. Using high and low pointers |
| 34 | we can initialize two poinetrs high and low and swapping arr[low] with arr[high] with reverse our main array(arr) without using any auxuliaary array*/ |
| 35 | void reverse2(int arr[], int n) |
| 36 | { |
| 37 | for (int low = 0, high = n - 1; low < high; low++, high--) { |
| 38 | swap(arr[low], arr[high]); //swapping the elements from wiht the help of high and low pointers |
| 39 | } |
| 40 | |
| 41 | //Time-Complexity-->O(n) where n is the total number of elements in array |
| 42 | //space-complexity-->O(1) -->Constant |
| 43 | } |
| 44 | |
| 45 | |
| 46 | int main() |