Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6365747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:58+00:00 2026-05-25T00:19:58+00:00

I need to compute the peek mid element also the problem statement for implementing

  • 0

I need to compute the peek mid element also the problem statement for implementing this method is as follows:-

*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 my query is:-

should i consider the middle element in terms of position i.e. after sorting the elements of the stack the mid element is obtained as mid = stack[size()/2+1]
or should i consider it in terms of value i.e. mid= max+min/2

as in above problem both the situations are correct( in my point of view) i.e.

stack[size()/2+1]=stack[6/2+1]=4

and max+min/2=6+1/2=3.5 and rounding off will be equal to 4

kindly help me understanding the problem statement

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:19:58+00:00Added an answer on May 25, 2026 at 12:19 am

    A stack is a data structure, and as such in the most generic case should be able to store any data type. The fact that you are dealing with ints is just a simplification for your assignment. Data structure wise, it makes sense that you consider the middle element, and not perform any computation on element values (that is too specific for a data structure).

    It seems like what you want is the ((n/2) + 1) th element, therefore the element at index (n/2) in this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To solve some problem I need to compute a variant of the pascal's triangle
I can't find any PHP script to compute Krippendorff's Alpha . I need this
I need to compute a numeric representation of a string which is bi-direction. For
I have this two strings of equal length, which I need to compare. I
I need to be able to compute differences between two data/time values which represent
I'm writing some software in which I need to compute bivariate densities of an
I need to compute hashes of multiple blocks of data independently. Something like this:
I need to compute imaginary exponential in C. As far as I know, there
I need to compute the area of the region of overlap between two triangles
I need to compute combinatorials (nCr) in Python but cannot find the function to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.