Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Coding/Programming Interviews:Active Template Library (ATL)ActiveXApplication DeveloperArtificial intelligenceAssemblyAssociate Software EngineerAWKAWTC ProgrammingC++ ProgrammingCGI PerlCGI ProgrammingCMMICobolCritical ReasoningData Structures TreesDCOM COMDelphiDTDE4XExtensible Stylesheet Language (XSL)FortranFull-Stack DeveloperHaskellHTML DOMILUIPhone DeveloperJasper Reports DeveloperJava DeveloperLisp ProgrammingLotus NotesMicrosoft Foundation Class (MFC)Mobile DeveloperMVC DeveloperNode.jsOOPPascalPerl ProgrammingPHPPHP DeveloperProgrammingProgramming AlgorithmsProgramming ConceptsPythonRubyRuby on RailsRuby on Rails DeveloperSenior Front End DeveloperSenior Software DeveloperSignature ProgramSOASocket ProgrammingSoftware Development EngineerSoftware engineeringSr. PHP ProgrammerStack And QueueSTLSwift DeveloperTCL (Tool Command Language)Team Leader Android DeveloperUMLUnity 2D Games DeveloperUnity 3D DeveloperUnity DeveloperVBA (Visual Basic for Applications)Visual Basic (VB)Visual C++Web DevelopmentWin32APIWindows ProgramingWordPress DevelopmentWSDLXFormsXHTMLXLinkXMLXPathXQueryXSL-FOXSLT
Copyright © 2018. All Rights Reserved
Programming Concepts Interview Question:
How to implement "Queue" functionality by using "2 Stacks"?
Submitted by: Administrator1. Take 2 empty stacks.
2. Fill the 1st stack with some items (eg: input 100, 101, 102, 103)
3. Now read the items from 1st stack in LIFO order and write to 2nd stack.
(By this the 2nd stack will get the items in the order .. 103, 102, 101, 100)
4. Now read the items from 2nd stack in LIFO order i.e. the output will be
100, 101, 102, 103.
(this is the queue order FIFO with respect to the actual items entered in 1st
stack.)
Submitted by: Administrator
2. Fill the 1st stack with some items (eg: input 100, 101, 102, 103)
3. Now read the items from 1st stack in LIFO order and write to 2nd stack.
(By this the 2nd stack will get the items in the order .. 103, 102, 101, 100)
4. Now read the items from 2nd stack in LIFO order i.e. the output will be
100, 101, 102, 103.
(this is the queue order FIFO with respect to the actual items entered in 1st
stack.)
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.