Question
A) Write the C++ code of a function that takes an array and its size, and then sort the array data in descending order using
A) Write the C++ code of a function that takes an array and its size, and then sort the array data in descending order using insertion sort. In each iteration one element in unsorted portion is inserted at correct position in sorted portion by sifting elements. An example is given below. 5 is considered sorted and then elements 1 through 2 are checked one by one and added at correct position by shifting of required elements in each iteration. B): Write the C++ code of a function that takes an array and its size, and then sort the array data in ascending using Odd-Even sorting algorithm. Odd-Even sorting
algorithm compares even odd index elements alternatingly in each iteration. In first iteration odd-even index (considering index starts at 1) pairs of elements are compared, and swapped, if required, then in next iteration even-odd pair of elements are compared. This process continues until the data is sorted completely. An example is given
WRITE C++ program for the following question you cannot use any break continue or goto statement
Took Question 1: Write the C++ code of a function that takes an array and its size, and then sort the array data in descending order using insertion sort. In each iteration one element in unsorted portion is inserted at correct position in sorted portion by sifting elements: An example is given below. 5 is considered sorted and then elements 1 through 2 are checked one by one and added at correct position by shifting of required elements in each iteration 5 8 3 9 2 2 Question 2: Write the C++ code of a function that takes an aray and its data in ascending using Odd-Even sorting algoritlim. Odd-Even sorting algorithm compares even odd index elements alternatingly in each iteration. In first iteration odd-even index (considering index starts at 1) pairs of elements are compared, and swapped, if required, then in next iteration even-odd pair of elements are compared. This process continues until the data is sorted completely. Au example is given size, and then sont the arayStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started