Enunciado del problema de implementación de la pila de comprensión
Necesito calcular el elemento peek mid y también el enunciado del problema para implementar este método es el siguiente: -
*returns object which has the middle value among the all objects without removing it from the stack. *returns the object which has the value of following order (size()/2)+1 *e.g. *When the stack has the following values (1, 2, 5, 4, 2, 6) *this method returns 4 and doesn't remove the object.
so mi consulta es: -
Debo considerar el elemento medio en términos de posición, es decir, después de ordenar los elementos de la pila, el elemento medio se obtiene comomid = stack[size()/2+1]
o debería considerarlo en términos de valor, es decir,mid= max+min/2
como en el problema anterior, ambas situaciones son correctas (en mi punto de vista), es decir,
stack[size()/2+1]=stack[6/2+1]=4
ymax+min/2=6+1/2=3.5
y redondeando será igual a 4
amablemente ayúdame a entender la declaración del problema