SLR04 - Data Structure Flashcards
(50 cards)
What is a data structure?
A way of organising and storing data in a computer so it can be accessed and modified efficiently.
What is an array?
A static data structure that stores data contiguously in memory and holds one data type.
Difference between array and list?
Arrays are static and store one data type; lists are dynamic and can store multiple data types.
Difference between tuple and list?
Tuple is immutable and fixed-size. list is mutable and changeable.
Why are arrays called static?
Because their size is fixed at the time of creation and cannot be changed later.
What is a binary file?
A non-text file storing data in binary form, often with mixed data types.
How is a real number stored differently in a binary file?
Stored in compact binary form instead of text, using fewer bytes.
What is a static data structure?
A structure with a fixed size where memory allocation doesn’t change during program runtime.
One benefit and drawback of static structures?
Benefit: Easier to program. Drawback: Inefficient use of memory.
What is a dynamic data structure?
A structure that can grow and shrink during runtime.
One benefit and drawback of dynamic structures?
Benefit: Efficient memory use. Drawback: Harder to program.
What is a stack?
A LIFO (Last-In-First-Out) data structure.
What operations are used on a stack?
Push, Pop, Peek.
What is stack overflow and underflow?
Overflow: Pushing to full stack. Underflow: Popping from empty stack.
What does the stack pointer do?
Points to the top item of the stack.
What is a queue?
A FIFO (First-In-First-Out) data structure.
What operations are used on a queue?
Enqueue, Dequeue, Peek.
What is stack overflow and underflow?
Overflow: Pushing to full stack. Underflow: Popping from empty stack.
What does the stack pointer do?
Points to the top item of the stack.
What is a queue?
A FIFO (First-In-First-Out) data structure.
What operations are used on a queue?
Enqueue, Dequeue, Peek.
What is queue overflow and underflow?
Overflow: Enqueue to full queue. Underflow: Dequeue from empty queue.
What are front and back pointers in a queue?
Front: Points to the item to dequeue. Back: Points to where to enqueue.
What problem does a circular queue solve?
Prevents unused space when back reaches the end of the array by looping around.