0
0
C Sharp (C#)programming~10 mins

Queue and Stack behavior in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
APush
BInsert
CAdd
DEnqueue
Attempts:
3 left
💡 Hint
Common Mistakes
Using Push instead of Enqueue for queues.
Trying to use Add or Insert which are not queue methods.
2fill in blank
medium

Complete 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'
APop
BDequeue
CRemove
DPeek
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dequeue which is for queues.
Using Peek which does not remove the item.
3fill in blank
hard

Fix 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'
APop
BDequeue
CPeek
DTop
Attempts:
3 left
💡 Hint
Common Mistakes
Using Pop which is not a queue method.
Using Dequeue which removes the item.
4fill in blank
hard

Fill 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'
Anumbers
BQueue
CStack
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using Queue instead of Stack for the type.
Using inconsistent variable names.
5fill in blank
hard

Fill 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'
Afruits
BEnqueue
CDequeue
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using Push or Pop which are stack methods.
Mixing variable names inconsistently.