M Mỹ An New member Sep 21, 2021 #1 How many swaps are required for reversing an array having n elements where n is an odd number? A. (n-1) / 2 B. n/2 C. (n/2) – 1 D. (n+1)/2
How many swaps are required for reversing an array having n elements where n is an odd number? A. (n-1) / 2 B. n/2 C. (n/2) – 1 D. (n+1)/2
H Hiếu Hoàng Member Sep 21, 2021 #2 Answer: a Explanation: The number of swaps required for an odd element and an even element array is different because in an odd element array the position of the middle element does not need to be changed. So the number of swaps will be (n-1) / 2. Upvote 0 Downvote
Answer: a Explanation: The number of swaps required for an odd element and an even element array is different because in an odd element array the position of the middle element does not need to be changed. So the number of swaps will be (n-1) / 2.