Question 1NCERT PDF page 6
counter, i.e. they form a queue - enqueue operation queue?
is performed two times.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 2NCERT PDF page 6
• As soon as the person at the front is serviced, he will
be removed from the queue - thus dequeue operation
is performed. Cashier calls Next to serve the next
Activity 4.2 person who is now at the front of the queue.
What if the content of
the complete queue • Cashier wants to know the length of the queue - size
is to be listed? of the queue is checked.
Write a function
for it. • Meanwhile, a few more people walk in the bank, and
three of them join the queue at the cash counter, i.e.
enqueue happens 3 times.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 3NCERT PDF page 6
• Another person gets served and leaves the counter,
i.e. dequeue is performed. Cashier calls Next to serve
another person.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 4NCERT PDF page 6
• The Next three people get served one after another,
i.e. dequeue is performed thrice.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 5NCERT PDF page 6
• Cashier calls Next and realises that there are no more
people to be served - underflow situation happens
Now, let us write the code for the above scenario of
the bank.
Program 4-1
myQueue = list()
# each person to be assigned a code as P1, P2, P3,...
element = input("enter person’s code to enter in queue :”)
enqueue(myQueue,element)
element = input("enter person’s code for insertion in queue :")
enqueue(myQueue,element)
print("person removed from queue is:", dequeue(myQueue))
print(“Number of people in the queue is :”,size(myQueue))
element = input("enter person’s code to enter in queue :")
enqueue(myQueue,element)
element = input("enter person’s code to enter in queue :")
enqueue(myQueue,element)
element = input("enter person’s code to enter in queue :")
enqueue(myQueue,element)
58 Computer Science - Class XII
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 6NCERT PDF page 6
is to be listed? of the queue is checked.
Write a function
for it. • Meanwhile, a few more people walk in the bank, and
three of them join the queue at the cash counter, i.e.
enqueue happens 3 times.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 7NCERT PDF page 8
1) Queue ctrl+shift+T, the most recently closed URL is opened
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 8NCERT PDF page 8
2) Stack first. As the number of URLs which can be stored in 3) List
history is fixed, so when this list of URLs becomes 4) None of the
above large, URLs from the end of the list (i.e. which were
least visited) gets deleted.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 9NCERT PDF page 8
• Same happens for providing the Do and Undo option
in any text editor.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 10NCERT PDF page 8
• To check whether a given string is palindrome or not?
Activity 4.4 Process string left to right (character wise) and insert
it in deque from tail/rear like a normal queue. Once In a deque, if insertion
and deletion of the entire string is processed (i.e. inserted in deque)
elements is done from we will take out (delete) a character from both the
the opposite end, it will ends and match them till there is no character left
behave as or only one character left in deque. In either case,
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 11NCERT PDF page 8
1) Queue string is palindrome. 2) Stack
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 12NCERT PDF page 8
3) List 4.4.2 Operations on Deque 4) None of the
above • INSERTFRONT: This operation is used to insert a
new element at the front of the deque.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 13NCERT PDF page 8
• INSERTREAR: This operation is the same as a
normal queue, i.e. insert a new element at the rear
of the deque.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 14NCERT PDF page 8
• DELETIONFRONT: This operation is the same as
normal queue, i.e. to remove an element from the
front of the deque.
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.
Question 15NCERT PDF page 8
• DELETIONREAR: This operation is used to remove
one element at a time from the rear of the deque.
60 Computer Science - Class XII
Answer
State the algorithm or concept, trace the logic step by step, and provide syntactically correct code, SQL or output where requested.
Check: Verify the result for the stated input and mention the relevant constraint or complexity.