C++ Help
$10-15 USD
Paid on delivery
Write a function that inserts an integer into an integer array at a specified position in the array. As it is impossible to insert anything into a full array, your function must distinguish capacity and population. The function’s prototype is bool insertAt(int elts[], int capacity, int& population, int new_pos, int new_elt); The function returns true if the insertion succeeds and false other wise. Translate the insertAt and shiftDown pseudo-code into C++. insertAt(array, capacity, population, insert_pos, value) if 0 <= population < capacity and 0 <= insert_pos <= population then shiftDown(array, insert_pos, population, capacity) array[insert_pos] <- value return true else return false end if end insertAt shiftDown(array, shift_pos, population, capacity) if 0 <= shift_pos <= population < capacity then for pos <- population - 1 to shift_pos step -1 array[pos + 1] <- array[pos] end for population <- population + 1 return true else return false end if end shiftDown Write a function that removes an integer from an integer array at a specified position in the array. As it is impossible to remove anything from an empty array, your function must distinguish capacity and population. The function’s prototype is bool removeAt(int elts[], int capacity, int& population int elt_pos); The function returns true if removeAt succeeds and false other wise. Translate the removeAt and shiftUp pseudo-code into C++. removeAt(array, capacity, population, remove_pos) if 0 <= remove_pos < population then shiftUp(array, remove_pos, population) return true else return false end if end removeAt shiftUp(array, shift_pos, population) if 0 <= shift_pos < population then for pos <- shift_pos to population ??" 2 array[pos] <- array[pos + 1] end for return true else return false end if end shiftUp Write a program to THOROUGLY test the four functions.
Project ID: #2736872