← Learning Hub
Beginner

DSA Introduction and Big-O

Data Structures and Algorithms (DSA) is about storing data in the right shape and solving problems in smart, fast steps. It is the main topic of coding interviews and placement tests in India.

Data structures and algorithms are the toolkit for solving problems efficiently. Choosing the right structure (a dictionary instead of a list) can turn a program that takes hours into one that takes milliseconds. Product companies test DSA in interviews because it shows how you think about problems, not just which syntax you know.

  • A data structure is a way to keep data: a list, a dictionary, a stack, a tree...
  • An algorithm is a step-by-step method: searching, sorting, finding a path...

We use Python in these lessons because it is short and easy to read. The ideas are the same in Java, C++ or JavaScript.

Big-O: how fast does it grow?

Big-O describes how the work grows when the input gets bigger. It ignores small details and keeps the main trend.

  • O(1) - constant: same time for 10 or 10 million items (reading items[5])
  • O(log n) - halves the work each step (binary search)
  • O(n) - looks at every item once (finding the maximum)
  • O(n log n) - good sorting (merge sort, Python's sort())
  • O(n²) - a loop inside a loop (comparing every pair) - slow for big inputs
Example
You can edit this code.

For 100,000 numbers, the slow version does about 5 billion comparisons; the fast one about 100,000. That's the power of choosing the right data structure.

Space complexity is the same idea for memory. The fast version uses O(n) extra memory for the set - a common trade: more memory for more speed.
Key points
  • DSA = ways to store data + step-by-step methods to solve problems.
  • Big-O describes how time grows with input size.
  • Practise patterns, not memorised answers.

📝 Test yourself

1. What is the Big-O of a loop inside a loop over the same list?
2. Which is fastest for big inputs?
3. Fill in the Python structure that checks 'have I seen this?' in O(1):
seen = ()