computer science A level ocr Data structures stack,queue tuples Flashcards

(69 cards)

1
Q

Define stack.

A

A linear data structure that follows the Last In First Out (LIFO) principle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the primary operation of a queue?

A

To add elements at the back and remove elements from the front.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false: A stack allows insertion and deletion at both ends.

A

FALSE

A stack only allows operations at one end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: A queue is also known as a _______ data structure.

A

FIFO (First In First Out)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does LIFO stand for?

A

Last In First Out, a principle of stack operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define tuple.

A

An ordered collection of elements, which can be of different types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false: Tuples are mutable in Python.

A

FALSE

Tuples cannot be changed after creation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the main use of a stack?

A

To manage function calls and undo mechanisms in applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fill in the blank: In a queue, the first element added is the first to be _______.

A

removed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a priority queue?

A

A type of queue where elements are removed based on priority rather than order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define enqueue.

A

The operation of adding an element to the back of a queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define dequeue.

A

The operation of removing an element from the front of a queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or false: Stacks can be implemented using arrays or linked lists.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the top operation in a stack?

A

It retrieves the last element added without removing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Fill in the blank: A stack uses _______ to manage its elements.

A

push and pop operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the length of a tuple?

A

The number of elements it contains.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

True or false: A tuple can contain duplicate elements.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the difference between a list and a tuple?

A

Lists are mutable, while tuples are immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Define push.

A

The operation of adding an element to the top of a stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does pop do in a stack?

A

Removes and returns the top element of the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Fill in the blank: A deque is a double-ended _______.

A

queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a circular queue?

A

A queue where the last position is connected back to the first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

True or false: Tuples can be nested within other tuples.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the first operation in a queue?

A

Enqueue, which adds an element to the back.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Define **front** in the context of a queue.
The position of the first element that will be removed.
26
What is a **stack overflow**?
An error that occurs when too many elements are added to a stack.
27
Fill in the blank: A **queue** can be implemented using a _______.
linked list or array
28
What is the **last** operation in a stack?
Pop, which removes the top element.
29
True or false: A stack can be used to reverse a string.
TRUE
30
Define **peek** in a stack.
To view the top element without removing it.
31
What is the **size** of a stack?
The number of elements currently in the stack.
32
Fill in the blank: A **tuple** is defined using _______ in Python.
parentheses
33
What is the **pop** operation in a queue?
Queues do not have a pop operation; they use dequeue instead.
34
True or false: Stacks are often used in recursive algorithms.
TRUE
35
Define **overflow** in a stack.
Occurs when trying to add an element to a full stack.
36
What is the **underflow** condition in a stack?
Occurs when trying to remove an element from an empty stack.
37
Fill in the blank: A **queue** can be implemented using _______ data structures.
arrays or linked lists
38
What is the **length** of a queue?
The number of elements currently in the queue.
39
True or false: A tuple can contain lists as elements.
TRUE
40
Define **FIFO**.
First In First Out, a principle of queue operations.
41
What is a **stack frame**?
A section of the stack that contains function call information.
42
Fill in the blank: The **enqueue** operation adds an element to the _______ of a queue.
back
43
What is the **dequeue** operation?
Removes the front element from a queue.
44
True or false: A stack can be used to evaluate expressions.
TRUE
45
Define **immutable**.
An object that cannot be changed after its creation.
46
What is a **linked list**?
A data structure consisting of nodes that point to the next node.
47
Fill in the blank: A **tuple** can hold _______ types of data.
multiple
48
What does **pop** return in a stack?
The last element added to the stack.
49
True or false: A queue can be empty.
TRUE
50
Define **data structure**.
A way to organize and store data for efficient access and modification.
51
What is the **main** use of tuples?
To group related data together in a single compound data type.
52
Fill in the blank: The **top** of a stack is the _______ element.
last added
53
What is a **dynamic array**?
An array that can grow and shrink in size as needed.
54
True or false: A stack can be implemented using a queue.
TRUE
55
Define **abstract data type**.
A model for a data type where the implementation is hidden.
56
What is the **main** characteristic of a queue?
Elements are processed in the order they were added.
57
Fill in the blank: A **stack** is often used in _______ algorithms.
depth-first search
58
What is a **hash table**?
A data structure that maps keys to values for efficient retrieval.
59
True or false: Tuples can be used as dictionary keys.
TRUE
60
Define **singly linked list**.
A linked list where each node points to the next node only.
61
What is a **doubly linked list**?
A linked list where nodes point to both the next and previous nodes.
62
Fill in the blank: A **stack** can be implemented using a _______.
linked list
63
What is the **main** advantage of using a linked list?
Dynamic size and efficient insertions/deletions.
64
True or false: A queue can be implemented using two stacks.
TRUE
65
Define **array**.
A collection of elements identified by index or key.
66
What is the **main** disadvantage of arrays?
Fixed size, which limits flexibility.
67
Fill in the blank: A **tuple** is _______ than a list.
faster to access
68
What is a **stack overflow** error?
Occurs when too many items are pushed onto a stack.
69
True or false: Queues are used in breadth-first search algorithms.
TRUE