Question: In C++ Write a function insert that takes an array of integers in ascending order, the number of integers currently in the array, the total
In C++


Write a function insert that takes an array of integers in ascending order, the number of integers currently in the array, the total size of the array, and an integer to insert into the array. The function should insert the given integer into the array such that the array remains in sorted order. If the array is already full, the array should remain unchanged. The function should return the new number of elements in the array. Function specifications: The function name: insert The function parameters (in this order): o An array, int o The number of elements stored in the array, int O The size of the array, int o The new element to be added, int The function returns the number of elements after inserting the element Sample run 1 Before Insertion: 1,1,3,4,5,5,5,6 After Insertion: 1,1,2,3,4,5,5,5,6 Sample run 2 Before Insertion: 1,1,3,4,5,5,5,6 After Insertion: 0,1,1,3,4,5,5,5,6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
