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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
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.

first line COMPLETED: bool insertElement(char array[ ], int& numElems, int &capacity, in position, char value) {

last line COMPLETE: bool insertElement(char array[ ], int numElems, int capacity, in position, char value) {

Exit Full Screen
RESPONSE AREA
ANSWER BANK
Organize answer blocks in the proper order:
Move the necessary blocks over into the response area:
i bool insertElement(char array[], int& numElems, int capacity, int pos
2
numElems++;
3
array[position]
value;
4
if (position < 0 || position > numElems|| numElems
capacity) {
: for (int i
position; i <= numElems; i++) {
7
return false;
array[i+l]
array[i];
9.
if (position > 0 || position <= numElems & & numElems ==
сараcity) {
10
}
11
return true;
for (int i
numElems-1;
i >= position; i--) {
# capacity++;
array[i]
array[i-1];
%D
}
i bool insertElement(char array[), int numElems, int &capacity, int pos
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
:::
00
Transcribed Image Text:Exit Full Screen RESPONSE AREA ANSWER BANK Organize answer blocks in the proper order: Move the necessary blocks over into the response area: i bool insertElement(char array[], int& numElems, int capacity, int pos 2 numElems++; 3 array[position] value; 4 if (position < 0 || position > numElems|| numElems capacity) { : for (int i position; i <= numElems; i++) { 7 return false; array[i+l] array[i]; 9. if (position > 0 || position <= numElems & & numElems == сараcity) { 10 } 11 return true; for (int i numElems-1; i >= position; i--) { # capacity++; array[i] array[i-1]; %D } i bool insertElement(char array[), int numElems, int &capacity, int pos ::: ::: ::: ::: ::: ::: ::: ::: ::: ::: ::: ::: 00
Expert Solution
trending now

Trending now

This is a popular 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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning