InsertNum(int num){} Write the method body of above method such that:

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

InsertNum(int num){}

Write the method body of above method such that:

1. It checks first if the array is sorted or not. If array is sorted than it is self intelligent to place that user entered num at desired place in an array i.e if array is {2,3,5,7} and the number entered is 6 than it will place the number after 5 and increment the size and moves 7 to the right. 

2. In case of unsorted array it will place the number at the end of array in constant time. (BigO(1))

Write code in C++ and dont use pointers.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage