Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an item to the queue.
C Sharp (C#)
Queue<int> numbers = new Queue<int>(); numbers.[1](5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Push instead of Enqueue for queues.
Trying to use Add or Insert which are not queue methods.
✗ Incorrect
Use Enqueue to add an item to a queue in C#.
2fill in blank
mediumComplete the code to remove an item from the stack.
C Sharp (C#)
Stack<string> words = new Stack<string>(); words.Push("hello"); string top = words.[1]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dequeue which is for queues.
Using Peek which does not remove the item.
✗ Incorrect
Use Pop to remove and return the top item from a stack.
3fill in blank
hardFix the error in the code to get the next item from the queue without removing it.
C Sharp (C#)
Queue<char> letters = new Queue<char>(); letters.Enqueue('a'); char next = letters.[1]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Pop which is not a queue method.
Using Dequeue which removes the item.
✗ Incorrect
Use Peek to look at the next item in the queue without removing it.
4fill in blank
hardFill both blanks to create a stack and add an item to it.
C Sharp (C#)
Stack<int> [1] = new [2]<int>(); [1].Push(10);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Queue instead of Stack for the type.
Using inconsistent variable names.
✗ Incorrect
Declare a stack variable named items and create a new Stack<int> instance.
5fill in blank
hardFill all three blanks to create a queue, add an item, and remove it.
C Sharp (C#)
Queue<string> [1] = new Queue<string>(); [1].[2]("apple"); string fruit = [1].[3]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Push or Pop which are stack methods.
Mixing variable names inconsistently.
✗ Incorrect
Create a queue named fruits, add "apple" with Enqueue, then remove it with Dequeue.