What is a data structure?
A way of organizing and storing data so it can be used efficiently.
Why are data structures important?
They make programs faster, more efficient, and easier to manage.
What is an array?
A list-like data structure that stores items in a specific order and allows access by index.
What is an example of an array?
A list of numbers like [2, 4, 6, 8] where each element has a position (index).
What are the advantages of arrays?
Fast access to elements by position and easy iteration.
What are the disadvantages of arrays?
Fixed size in some languages and slow insertion/deletion in the middle.
What is a stack in computer science?
A data structure that follows the “Last In, First Out” (LIFO) rule — the last item added is the first removed.
What is an example of a stack in real life?
A stack of plates — you take the top plate off first.
What are common stack operations?
push (add an item) and pop (remove the most recent item).
What is a queue?
A data structure that follows the “First In, First Out” (FIFO) rule — the first item added is the first removed.
What’s a real-life example of a queue?
A line at a store checkout — first person in line gets served first.
What are common queue operations?
enqueue (add to the back) and dequeue (remove from the front).
What’s the difference between a stack and a queue?
A stack removes the newest item first; a queue removes the oldest item first.
What does “Big-O notation” measure?
How the performance (speed or memory use) of an algorithm changes as data size grows.
Why does Big-O matter?
It helps compare which algorithms are more efficient and scalable.
What does O(1) mean?
Constant time — the operation takes the same amount of time no matter the data size.
What does O(n) mean?
Linear time — the time grows in direct proportion to the size of the data.
What does O(n²) mean?
Quadratic time — time increases much faster as the data grows (like nested loops).
What is the goal when analyzing algorithms with Big-O?
To find the most efficient approach possible for large-scale data.
What is a compiler?
A program that translates human-written code (high-level) into machine code before running it.
What is an interpreter?
A program that reads and executes code line by line without pre-compiling.
What’s a key difference between compilers and interpreters?
Compilers translate all at once; interpreters translate on the fly as the program runs.
Give an example of a compiled language.
C or C++.
Give an example of an interpreted language.
Python or JavaScript.