DSA Interview Question

What is an algorithm?

Updated 2026-08-16 · Beginner friendly
Quick answer

An algorithm is a clear, step by step set of instructions for solving a problem or completing a task. A good algorithm is correct, finishes in a finite number of steps, and is efficient in time and memory. Following a recipe to cook a dish is a everyday example of an algorithm.

Key takeaways
  • An algorithm is a clear, finite, step by step set of instructions for solving a problem.
  • A good algorithm is correct, finishes, is well defined, and uses reasonable time and memory.
  • Describing your approach in plain steps before coding helps catch mistakes early.

What makes a good algorithm

In software, algorithms power everything from sorting a list and searching a database to routing a map and ranking search results. Data structures and algorithms go hand in hand, since the right structure often makes the algorithm simple and fast.

In the interview

If asked to describe your approach before coding, state your algorithm in plain steps first. Interviewers value a clear plan, and it helps you catch mistakes before you write a single line.

Frequently asked questions

What is the difference between an algorithm and a data structure?

An algorithm is the method that does the work, while a data structure is how the data is stored. The right structure often makes the algorithm simpler and faster.

What is a greedy algorithm?

A greedy algorithm makes the best local choice at each step hoping for a global best. It is fast but only correct for certain problems.

Want the full DSA guide?

Read every DSA concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the DSA guide All DSA questions