Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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)
(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 will 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
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