Computer Science
Write an algorithm to insert element into Queue as a list.
Python Queue
3 Likes
Answer
An algorithm to insert element into Queue as a list is as follows:
- START
- Queue = list() or Queue = [] #Initialize a Queue using list
- element = input("Enter the element to be added to the Queue: ")
- Queue.append(element) #Adding element into the list Queue
- STOP
Answered By
2 Likes
Related Questions
A Stack STK and Queue QUE is being maintained. Their maximum size is the same:
(i) check whether they have the same size, i.e., have the same number of elements.
(ii) check for equality of Stack and Queue, i.e.,
- Retrieve an element from the Stack and one element from the Queue.
- Compare the two.
- Stop and report if elements are different.
Write an algorithm to insert element into Stack as a list.
Write a program to create a Stack for storing only odd numbers out of all the numbers entered by the user. Display the content of the Stack along with the largest odd number in the Stack. (Hint. Keep popping out the elements from stack and maintain the largest element retrieved so far in a variable. Repeat till Stack is empty)
Write a program that, depending upon the user's choice, either adds or removes an element from a Stack.