[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Queue Questions

Home > Technical Aptitude > Data Structures > Queue > General Questions
NA
SHSTTON
379
Solv. Corr.
517
Solv. In. Corr.
896
Attempted
1 M:55 S
Avg. Time

21 / 42

Choose the correct option.

Consider you have a stack whose elements in it are as follows.
5 4 3 2 << top
Where the top element is 2.
You need to get the following stack
6 5 4 3 2 << top
The operations that needed to be performed are (You can perform only push and pop):


APush(pop()), push(6), push(pop())

BPush(pop()), push(6)

CPush(pop()), push(pop()), push(6)

DPush(6)

Answer: Option A

Explanation:

By performing push(pop()) on all elements on the current stack to the next stack you get 2 3 4 5 << top.Push(6) and perform push(pop()) you’ll get back 6 5 4 3 2 << top. You have actually performed enQueue operation using push and pop.

Workspace

NA
SHSTTON
305
Solv. Corr.
591
Solv. In. Corr.
896
Attempted
0 M:30 S
Avg. Time

22 / 42

Choose the correct option.

Given only a single array of size 10 and no other memory is available. Which of the following operation is not feasible to implement (Given only push and pop operation)?


APush

BPop

CEnqueue

DReturntop

Answer: Option C

Explanation:

To perform Enqueue using just push and pop operations, there is a need of another array of same size. But as there is no extra available memeory, the given operation is not feasible.

Workspace

NA
SHSTTON
27
Solv. Corr.
499
Solv. In. Corr.
526
Attempted
0 M:26 S
Avg. Time

23 / 42

Choose the correct option.

Given an array of size n, let’s assume an element is ‘touched’ if and only if some operation is performed on it(for example, for performing a pop operation the top element is ‘touched’). Now you need to perform Dequeue operation. Each element in the array is touched atleast?


AOnce

BTwice

CThrice

DFour times

Answer: Option D

Explanation:

First each element from the first stack is popped, then pushed into the second stack, dequeue operation is done on the top of the stack and later the each element of second stack is popped then pushed into the first stack. Therfore each element is touched four times.

Workspace

NA
SHSTTON
463
Solv. Corr.
294
Solv. In. Corr.
757
Attempted
0 M:6 S
Avg. Time

24 / 42

Choose the correct option.

To implement a stack using queue(with only enqueue and dequeue operations), how many queues will you need?


A1

B2

C3

D4

Answer: Option B

Explanation:

Either the push or the pop has to be a costly operation, and the costlier operation requires two queues.

Workspace

NA
SHSTTON
144
Solv. Corr.
348
Solv. In. Corr.
492
Attempted
0 M:29 S
Avg. Time

25 / 42

Choose the correct option.

Making the push operation costly, select the code snippet which implements the same.(let q1 and q2 be two queues)

I. public void push(int x)
{
if(empty())
{
q1.offer(x);
}
else{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
}
}

II. public void push(int x)
{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q1.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
else if(q2.size()>0)
{
q2.offer(x);
int size = q2.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
}
}

III. public void push(int x)
{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q1.offer(q2.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
}
}

IV. public void push(int x)
{
if(empty())
{
q1.offer(x);
}
else
{
if(q1.size()>0)
{
q2.offer(x);
int size = q1.size();
while(size>0)
{
q2.offer(q2.poll());
size--;
}
}
else if(q2.size()>0)
{
q1.offer(x);
int size = q2.size();
while(size>0)
{
q2.offer(q1.poll());
size--;
}
}
}
}


AI

BII

CIII

DIV

Answer: Option A

Explanation:

Stack follows LIFO principle, hence a new item added must be the first one to exit, but queue follows FIFO principle, so when a new item is entered into the queue, it will be at the rear end of the queue. If the queue is initially empty, then just add the new element, otherwise add the new element to the second queue and dequeue all the elements from the second queue and enqueue it to the first one, in this way, the new element added will be always in front of the queue. Since two queues are needed to realize this push operation, it is considered to be costlier.

Workspace

NA
SHSTTON
105
Solv. Corr.
184
Solv. In. Corr.
289
Attempted
0 M:3 S
Avg. Time

26 / 42

Choose the correct option.

Making the push operation costly, select the code snippet which implements the pop operation.

I. public void pop()
{
if(q1.size()>0)
{
q2.poll();
}
else if(q2.size()>0)
{
q1.poll();
}
}

II. public void pop()
{
if(q1.size()>0)
{
q1.poll();
}
else if(q2.size()>0)
{
q2.poll();
}
}

III. public void pop()
{
q1.poll();
q2.poll();
}

IV. public void pop()
{
if(q2.size()>0)
{
q1.poll();
}
else
{
q2.poll();
}
}


AI

BII

CIII

DIV

Answer: Option B

Explanation:

As the push operation is costly, it is evident that the required item is in the front of the queue, so just dequeue the element from the queue.

Workspace

NA
SHSTTON
166
Solv. Corr.
233
Solv. In. Corr.
399
Attempted
0 M:4 S
Avg. Time

27 / 42

Choose the correct option.

Select the code snippet which returns the top of the stack.

I. public int top()
{
if(q1.size()>0)
{
return q1.poll();
}
else if(q2.size()>0)
{
return q2.poll();
}
return 0;
}

II. public int top()
{
if(q1.size()==0)
{
return q1.peek();
}
else if(q2.size()==0)
{
return q2.peek();
}
return 0;
}

III. public int top()
{
if(q1.size()>0)
{
return q1.peek();
}
else if(q2.size()>0)
{
return q2.peek();
}
return 0;
}

IV. public int top()
{
if(q1.size()>0)
{
return q2.peek();
}
else if(q2.size()>0)
{
return q1.peek();
}
return 0;
}


AI

BII

CIII

DIV

Answer: Option C

Explanation:

Assuming its a push costly implementation, the top of the stack will be in the front end of the queue, note that peek() just returns the front element, while poll() removes the front element from the queue.

Workspace

NA
SHSTTON
73
Solv. Corr.
712
Solv. In. Corr.
785
Attempted
0 M:17 S
Avg. Time

28 / 42

Choose the correct option.

With what data structure can a priority queue be implemented?


AArray

BList

CHeap

DTree

Answer: Option D

Explanation:

Priority queue can be implemented using an array, a list, a binary search tree or a heap, although the most efficient one being the heap.

Workspace

NA
SHSTTON
135
Solv. Corr.
344
Solv. In. Corr.
479
Attempted
0 M:33 S
Avg. Time

29 / 42

Choose the correct option.

What is not a disadvantage of priority scheduling in operating systems?


AA low priority process might have to wait indefinitely for the CPU

BIf the system crashes, the low priority systems may be lost permanently

CInterrupt handling

DIndefinite blocking

Answer: Option C

Explanation:

The lower priority process should wait until the CPU completes the processing higher priority process. Interrupt handling is an advantage as interrupts should be given more priority than tasks at hand so that interrupt can be serviced to produce desired results.

Workspace

NA
SHSTTON
149
Solv. Corr.
397
Solv. In. Corr.
546
Attempted
0 M:9 S
Avg. Time

30 / 42

Choose the correct option.

Which of the following is not an advantage of priority queue?


AEasy to implement

BProcesses with different priority can be efficiently handled

CApplications with differing requirements

DEasy to delete elements in any case

Answer: Option D

Explanation:

In worst case, the entire queue has to be searched for the element having highest priority. This will take more time than usual. So deletion of elements is not an advantage.

Workspace

Data Structures Queue Questions and Answers pdf

At Data Structures topic Queue page No: 3 you will find list of 10 practice questions, tips/trick and shortcut to solve questions, solved questions, quiz, and download option to download the whole question along with solution as pdf format for offline practice. You can practice all the listed Data Structures Queue topic questions offline too, by downloading the MCQs practice question of Queue with detail solution, with formula/Tips & Tricks, with Solved examples and with top-rated users answers, which will give you best answer ascross webs. It is one of the perfect Queue e-book pdf covering all types of questions in detail. These Data Structures test with answers pdf cover all types of question asked in IIFT, XAT, SNAP, GRE, GMAT, NMAT, CMAT, MAT or for IT companies written exam like Wipro, HCL, Infosys, Accenture, Government exams, IBPS Exams etc. There are multiple formats to download your online free Data Structures Queue e-book, like fully solved, unsolved questions with Answers sheet. Even you can customize your ebook format by adjusting the given options in the download section to make it your one of the best Data Structures topic-based ebook. It is recommended to bookmark this page Data Structures Queue for your preparation. Most of the students and fresher candidates finding it hard to clear the Data Structures section in exams. Here Given Queue practice questions, quiz, fully solved questions, tips & trick and Mock tests, which include question from each topic will help you to excel in Queue. Each test has all the basics questions to advanced questions with answer and explanation for your clear understanding, you can download the test result as pdf for further reference.

At Data Structures topic Queue, you will get multiple online quiz difficulty wise, which will have a total of 6 quizzes, categorized as easy, medium, and moderate level. While preparing for any Queue, take all the list quiz and check your preparation level for that topic. Each quiz have 10 different question, which needs to be answered in 20 min., all the listed quiz here is free, however, you will get only one chance for each quiz to attempt(Take Quiz seriously), so it is always recommended to take one quiz in each section before you start solving Queue MCQs practice question, and one after solving all the question of the respective level, you can refer back your Queue quiz result any time or you can download it as pdf for reference.

Data Structures Queue Customize Online Mock Test

This is own type of mock test, where At this Data Structures Queue MCQs mock test section, you will able to attempt only the questions related to Queue, in that question will be a different level, important, and all the questions will be part of some of the mock tests across Q4interview FREE Mock test. You need to choose the topic as Queue, and click on Double click to generate your customize mock test. While attempting the mock test you need to choose any of the one options out of given option. It is recommended to go through the direction given along with each question, as these questions will be randomly and so that same direction will not be applicable across the entire test. Once you submit your mock test, the result will be generated for Queue Customize mock test, where your performance point points will be highlighted. Q4interview analysis every single point which helps you to improve your topic understanding and help you to know your type of mistakes and way to improve Queue questions, by providing the same type of practice questions from practice exercise. The best part of this Queue, all these mock tests listed here are free and you can take as Many time, as many you want. When you continue to give Queue Customize Online Mock Test here regularly, then you will understand how much you have developed your accuracy on a topic, after that you will be able to decide how much attention you need to focus on. Your continued practice will increase your confidence, speed and thinking ability intensely, the Queue Customize topic on which you will practice more will beneficial for you in future during campus placement.Queue Mock Tests

Data Structures Queue Quiz Online Test

The details of the Data Structures Queue quiz are as follows. There are 10 questions for you. You have to answer them in 20 minutes. Within 20 minutes you have to see the errors in the sentences given as a question. Four options are also given to you, and you have to choose your opinion. You must be confident in your answer that the choices are difficult. Therefore, below we provide you with some information about Data Structures Queue that you see and keep them in mind while answering questions.

Data Structures Queue MCQs Practice Questions with Answer

On this Queue section of page you will find the easiest quickest ways to solve a question, formulas, shortcuts and tips and tricks to solve various easiest methods to solve Queue Question Quickly. It contains all the Data Structures topic Queue questions which are common in any of the preliminary exams of any company. The solution is provided along with the questions. The practice of these questions is a must as they are easy as well as scoring and asked in all the exams They will confirm the selection if all the questions attempted wisely with little practice. It is recommanded to Take Mock test based on Data Structures topic and Queue topic based quiz.

Data Structures Queue solved examples question

Clarity of concepts is a must if you want to master the skill of solving Data Structures problems. This page contains sample Data Structures Queue questions and answers for freshers and competitive exams. Queue Questions with the detailed description, the explanation will help you to master the topic. Here solved examples with detailed answer description, explanations are given and it would be easy to understand. How to solve qQueueData Structures? Here are some examples solved with the Common Rules/tricks/tips of Data Structures. Enhance your chance to score maximum marks in Data Structures sections through. Error Spotting Grammar Questions Online Test for Free. Fully solved Sentence Formation MCQs questions with detailed answer description. Data Structures is an important topic for any exams but most aspirants find it difficult. You need to learn various tricks tips, rules, etc to solve quickly. At this page, you will find frequently asked Queue questions or problems with solutions, shortcuts, formulas for all-important competitive exams like IT companies exams, interviews. It is always a best practice to go through the example and understand the types of question and way to solve it, so let's do some examples to calculate efficiency, read through all the given here solved examples. You can post your solution, tips, trick and shortcut if you have any in respect to questions.

You can get here fully solved Queue examples with a detailed answer and description. You can solve Queue problems with solutions, the questions by companies wise by filtering the questions, additionally, you can check what type of questions are being asked in IT companies Written Round from Queue. Queue became one of the most important sections in the entire competitive exams, Companies Campus, and entrance online test. Go through Queue Examples, Queue sample questions. You can Evaluate your level of preparation in Queue by Taking the Q4Interivew Queue Online Mock Test based on most important questions. All the Queue practice questions given here along with answers and explanations are absolutely free, you can take any number of time any mock Test.

Why Data Structures Queue?

In this practice section, you can practice Data Structures Questions based on "Queue" and improve your skills in order to face the interview, competitive examination, IT companies Written exam, and various other entrance tests (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

Where can I get Data Structures Queue questions and answers with explanation?

Q4Interview provides you lots of fully solved Data Structures (Queue) questions and answers with Explanation. Solved examples with detailed answer description, explanation are given and it would be easy to understand. You can download Data Structures Queue quiz questions with answers as PDF files and eBooks.

Where can I get Data Structures Queue Interview Questions and Answers (objective type, multiple-choice, quiz, solved examples)?

Here you can find objective type Data Structures Queue questions and answers for interview and entrance examination. Multiple choice and true or false type questions are also provided.