Structures Questions and Answers 100%
Pass
What is a data structure?
✔✔A data structure is a way to organize and store data for efficient access and modification.
What is a stack in programming?
✔✔A stack is a data structure that follows the Last In, First Out (LIFO) principle.
How do you add an element to a stack in Python?
✔✔You add an element to a stack using the `append()` method.
How do you remove an element from a stack in Python?
✔✔You remove an element from a stack using the `pop()` method.
What is a queue in programming?
✔✔A queue is a data structure that follows the First In, First Out (FIFO) principle.
1
,How do you add an element to a queue in Python?
✔✔You add an element to a queue using the `append()` method.
How do you remove an element from a queue in Python?
✔✔You remove an element from a queue using the `pop(0)` method.
What is the difference between a stack and a queue?
✔✔A stack uses LIFO, while a queue uses FIFO.
What is a linked list?
✔✔A linked list is a data structure made up of nodes, where each node contains data and a
reference to the next node.
What is the head of a linked list?
✔✔The head of a linked list is the first node in the list.
What is a doubly linked list?
2
, ✔✔A doubly linked list is a linked list where each node contains references to both the next and
previous nodes.
How do you traverse a linked list?
✔✔You traverse a linked list by starting at the head and following the references to the next
nodes.
What is a set in Python?
✔✔A set is a collection of unique elements, defined using curly braces or the `set()` function.
How do you add an element to a set in Python?
✔✔You add an element to a set using the `add()` method.
How do you remove an element from a set in Python?
✔✔You remove an element from a set using the `remove()` or `discard()` method.
What is the difference between a list and a set in Python?
✔✔A list allows duplicate elements, while a set contains only unique elements.
3