C++ Help

Completed Posted Apr 30, 2012 Paid on delivery
Completed 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.

Engineering Software Architecture Software Testing

Project ID: #2736872

About the project

4 proposals Remote project Active Apr 30, 2012

Awarded to:

ovidiuv

See private message.

$10 USD in 1 day
(234 Reviews)
5.6

4 freelancers are bidding on average $9 for this job

vano101

See private message.

$10.01 USD in 1 day
(418 Reviews)
6.5
admarinfotech

See private message.

$9 USD in 1 day
(76 Reviews)
5.0
klakatos

See private message.

$8 USD in 1 day
(14 Reviews)
4.8
tybah

See private message.

$8 USD in 1 day
(0 Reviews)
0.0