C++ Help

Completado Publicado Apr 30, 2012 Pagado a la entrega
Completado Pagado a la entrega

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.

Ingeniería Arquitectura de software Verificación de software

Nº del proyecto: #2736872

Sobre el proyecto

4 propuestas Proyecto remoto Activo Apr 30, 2012

Adjudicado a:

ovidiuv

See private message.

$10 USD en 1 día
(234 comentarios)
5.6

4 freelancers están ofertando un promedio de $9 por este trabajo

vano101

See private message.

$10.01 USD en 1 día
(418 comentarios)
6.5
admarinfotech

See private message.

$9 USD en 1 día
(76 comentarios)
5.0
klakatos

See private message.

$8 USD en 1 día
(14 comentarios)
4.8
tybah

See private message.

$8 USD en 1 día
(0 comentarios)
0.0