What a stack and a queue are

Understanding stacks and queues is essential for managing data and optimizing algorithms in computer science.

AmeliaClark8p·12 flashcards·12 vragen
high schoolcomputer_sciencealgorithms
0
Ken ik
1 / 12
0
Aan het leren
Voorkant

What is a stack?

Tik om om te draaien
Achterkant

A stack is a data structure that follows Last In First Out (LIFO) order.

Tik om om te draaien
Ken ik
Aan het leren

Quiz(12 vragen)

Vraag 1 van 12

1. What is the main characteristic of a stack?

Termen in deze set(12)

What is a stack?

A stack is a data structure that follows Last In First Out (LIFO) order.

What is a queue?

A queue is a data structure that follows First In First Out (FIFO) order.

True or false: A stack allows random access to elements.

False, because stacks only allow access to the top element.

Difference between stack and queue

Stack: LIFO. Queue: FIFO. They manage data differently.

Fill the blank: In a queue, the ________ element is removed first.

first

Common stack operations?

Push (add), Pop (remove), Peek (view top).

Common queue operations?

Enqueue (add), Dequeue (remove), Peek (view front).

Question: Which is more suitable for undo operations?

Stack, because it reverses to the last action taken.

True or false: Queue operations are faster than stack operations.

False, both have similar time complexity on average.

Which structure uses a 'rear' and 'front'?

Queue uses both to manage elements.

What is 'pushing' in stacks?

Adding an element to the top of the stack.

What is 'dequeueing' in queues?

Removing the front element from the queue.

Vragen in deze set(12)

1. What is the main characteristic of a stack?

A.Last In First Out
B.First In First Out
C.Random Access
D.None of the above

2. Which operation adds an element to a stack?

A.Pop
B.Enqueue
C.Push
D.Dequeue

3. In which structure do elements get removed from the front?

A.Stack
B.Queue
C.List
D.Tree

4. Which is NOT an operation associated with stacks?

A.Push
B.Pop
C.Enqueue
D.Peek

5. What does 'dequeue' mean?

A.Add to stack
B.Remove from stack
C.Add to queue
D.Remove from queue

6. Which data structure would you use for a print queue?

A.Stack
B.Queue
C.Array
D.Linked List

7. Which statement is true about stacks?

A.They support random access.
B.They are FIFO.
C.They are LIFO.
D.They have no limit.

8. What happens when you 'pop' a stack?

A.View the top element
B.Remove the top element
C.Add a new element
D.Remove all elements

9. Which structure would you use for tracking browser history?

A.Queue
B.Stack
C.Tree
D.Graph

10. Which of the following is true about queues?

A.LIFO order
B.FIFO order
C.Supports random access
D.Elements are unordered

11. How do you add an element to a queue?

A.Push
B.Pop
C.Enqueue
D.Dequeue

12. What is the time complexity of stack operations?

A.O(1)
B.O(n)
C.O(log n)
D.O(n^2)

Gerelateerde sets

Maak je eigen studieset

Upload een PDF, plak je notities of beschrijf een onderwerp – AI genereert flashcards, quizzen en meer in seconden.