Question: 14. (15 pts) Write an insert algorithm, use function name myinsert. The function will have two inputs: x (an array of numbers sorted in ascending

 14. (15 pts) Write an insert algorithm, use function name myinsert.

14. (15 pts) Write an insert algorithm, use function name myinsert. The function will have two inputs: x (an array of numbers sorted in ascending order) and num (a number to insert into the array). The function I have one output: y (this should be x with num inserted in the proper place). The function will locate where num fits into the ascending order array. Once it finds that location, it will insert num into x at the proper location. Include a check at the beginning of the code, that ensures that num falls within the bounds of the x array and only insert it if the condition is true. If the condition is not true, include an appropriate error message. An example of what your function should do: if x=(1 4 7 9] and num=2, then y=[1 2 4 7 9). The only built-ins allowed are find and length (however, it is not required that you use them)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!