This topic contains 0 replies, has 0 voices, and was last updated by  EduGorilla 2 years, 6 months ago.

  • Author
    Posts
  • #1427980 Reply
     EduGorilla 
    Keymaster
    Select Question Language :


    A queue can be implemented using 2 stacks. Let stacks used are s1 and s2 and the queue be q.
    Let operations enqueue and dequeue be:
    enqueue(q, x):
    a. push x to s1
    dequeue(q):
    a. if both s1 and s2 are empty, then error
    b. P
    c. Q.
    The possible statement for P and Q are respectively:

    Options :-

    1. pop from s2; if s2 is empty, push everything from s1 to s2
    2. if s2 is empty, push everything from s1 to s2; pop from s2
    3. pop from s1; if s1 is empty, push everything from s2 to s1
    4. if s1 is empty, push everything from s2 to s1; pop from s1
    Post your Training /Course Enquiry
    Are You looking institutes / coaching center for
    • IIT-JEE, NEET, CAT
    • Bank PO, SSC, Railways
    • Study Abroad
    Select your Training / Study category
Reply To: A queue can be implemented using 2 stacks. Let stacks used are s1 and s2 and the queue be q. Let ope….
Your information:




Verify Yourself




Log in with your credentials

or    

Forgot your details?

Create Account