find code blocks necessary to insert a value into an ordered array given a position (index) to insert.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

'

Below you will find code blocks necessary to insert a value into an ordered array given a position (index) to insert. Be careful! Some lines are not needed.

'
Move the necessary blocks over into the response area:
return false;
array[i]
array[i-1];
: bool insertElement(char array[], int& numElems, int capacity, int position, char value) {
if (position < 0 || position > numElems || numElems ==
сараcity) {
return true;
}
: сарасity++;
: for (int i = position; i <= numElems; i++) {
for (int i = numElems-1; i >= position; i--) {
: bool insertElement(char array[], int numElems, int &capacity, int position, char value) {
if (position > 0 || position <= numElems & & numElems
== capacity) {
array[i+l]
array[i];
%D
}
numElems++;
array[position]
= value;
Transcribed Image Text:Move the necessary blocks over into the response area: return false; array[i] array[i-1]; : bool insertElement(char array[], int& numElems, int capacity, int position, char value) { if (position < 0 || position > numElems || numElems == сараcity) { return true; } : сарасity++; : for (int i = position; i <= numElems; i++) { for (int i = numElems-1; i >= position; i--) { : bool insertElement(char array[], int numElems, int &capacity, int position, char value) { if (position > 0 || position <= numElems & & numElems == capacity) { array[i+l] array[i]; %D } numElems++; array[position] = value;
Expert Solution
steps

Step by step

Solved in 2 steps

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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT