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

  • Home
  • SEARCH
  • 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 914243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:41:14+00:00 2026-05-15T17:41:14+00:00

Is my professor asking me to draw the stack? Does he want me to

  • 0

Is my professor asking me to draw the stack? Does he want me to draw it in action? I feel stupid but it’s not like anyone ever told me! Thank you for your help.

Wow you guys are quick. Thank you already. The complete question is: Consider two stacks, each of size n (i.e., each one can hold a maximum of n elements). If the sum of the number of elements in the two stacks is n, then any additional PUSH operation should result in an overflow error. (Note: Your implementation should take care of the fact that elements
should POP opposite to the order in which they are PUSHed).

***I’m not asking for the answer I’m just wondering… what do you think he’s asking me to do? Cause he still hasn’t answered my email and I need it done by midnight.

  • 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-15T17:41:14+00:00Added an answer on May 15, 2026 at 5:41 pm

    “Implement” generally means write, pure and simple. Your educator wants you to write code that can do what the assignment says.

    Stacks of fixed size (n) can be easily implemented as an array with a current stack depth but you have an extra twist to your assignment inasmuch as you’re only alowed to have n elements on both stacks combined rather than each stack.

    I would implement it as follows (pseudo-code only since it’s homework and, in any case, you haven’t specified a language):

    # Create the two stacks, each of size sz.
    init_stack (sz):
        allocate stack1 as array[1 to sz] of integer
        allocate stack2 as array[1 to sz] of integer
        set stack1sz to 0
        set stack2sz to 0
        set maxsz to sz
    

     

    # Push the value val onto stack stk.
    push_stack (stk,val):
        if stk is not equal to 1 or 2:
            return error
        if stack1sz + stack2sz is equal to maxsz:
            return error
        if stk is 1:
            add 1 to stack1sz
            set element stack1sz of stack1 to val
        else:
            add 1 to stack2sz
            set element stack2sz of stack2 to val
    

     

    # Pop a value off stack stk.
    pop_statkck (stk):
        if s is not equal to 1 or 2:
            return error
        if stk is 1:
            if stack1sz is 0:
                return error
            set val to element stack1sz of stack1
            subtract 1 from stack1sz
        else:
            if stack2sz is 0:
                return error
            set val to element stack2sz of stack2
            subtract 1 from stack2sz
        return val
    

    The variables stack1, stack2, stack1sz, stack2sz and maxsz should be declared in such a way that they survive in between function calls (i.e., not locals). All others are transitory.

    If you have troubles converting that to a specific language, leave a comment and I’ll provide pointers on what to look for.

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

Sidebar

Related Questions

I am taking a class in C++ programming and the professor told us that
My professor assigned a project where a simulation is ran through a GUI. To
In my Computer Science II class, the professor considers ++,--,*=, etc. to be 2
In our embedded system (using a PowerPC processor), we want to disable the processor
I am outputting RTF from a word processor component. This is working well, but
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
My credit card processor requires I send a two-digit year from the credit card
I've seen that a Processor Pack is available for Visual Studio 6, however it
I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought
The Gang of Four's Design Patterns uses a word processor as an example for

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.