Skip to content

Image, PDF and QR tools that run in your browser. Your files never leave your phone. Explore tools →

Data Structures and Algorithms Interview Questions for Freshers

Resume & career100% freePrivate

The short answer

DSA rounds check how you think. The 10 questions here include array versus linked list, stack and queue, time complexity, binary search, cycle detection and recursion, each with a note on a good answer. Allow about 90 seconds to explain one.

How do you want to use it?

10 questions. Open one to see what a good answer covers.

What is the difference between an array and a linked list?
Data structures and algorithms

An array has fixed-size, contiguous memory and fast access by index. A linked list has nodes joined by pointers, so inserting and removing is easy but reaching an item means walking the list.

What are a stack and a queue, and where are they used?
Data structures and algorithms

A stack is last in, first out, used for undo and function calls. A queue is first in, first out, used for scheduling and breadth-first search.

What is time complexity, and what are some common examples?
Data structures and algorithms

How the running time grows with the input size, written in Big-O. Array access is O(1), binary search O(log n), a single loop O(n), good sorts O(n log n) and nested loops O(n squared).

How does binary search work?
Data structures and algorithms

On a sorted list, check the middle item and discard the half that cannot hold the target, repeating until found. It takes O(log n) time and needs the data sorted.

How do you detect a cycle in a linked list?
Data structures and algorithms

Use two pointers, one moving one step and the other two steps. If they ever meet there is a cycle, and if the fast one reaches the end there is none. It uses constant extra memory.

What is recursion, and why does it need a base case?
Data structures and algorithms

A function that calls itself on a smaller version of the problem. The base case stops the calls, and without it the function runs until the stack overflows.

What is the difference between BFS and DFS?
Data structures and algorithms

BFS visits nodes level by level using a queue and finds the shortest path in an unweighted graph. DFS goes deep first using a stack or recursion and is useful for paths, cycles and ordering.

How does a hash table handle collisions?
Data structures and algorithms

Two keys can map to the same slot. Chaining keeps a list in each slot, and open addressing looks for another free slot. A good hash function and resizing keep lookups close to constant time.

Compare merge sort and quick sort.
Data structures and algorithms

Merge sort is always O(n log n) and stable but needs extra memory. Quick sort is O(n log n) on average with little extra memory, but its worst case is O(n squared) with bad pivots.

What is a binary search tree?
Data structures and algorithms

A tree where each node's left side holds smaller values and its right side larger ones. Searching, inserting and deleting take O(log n) when it is balanced, but a skewed tree degrades to O(n).

Everything runs in your browser. What you type is not sent anywhere.

How to: Data Structures and Algorithms Interview Questions for Freshers

  1. 1Read the question and draw a small example on paper.
  2. 2Explain the idea aloud before you think about code.
  3. 3Open the tip and see the points you left out.
  4. 4Practise again with the 90-second timer.

At a glance

Questions
10 data structure and algorithm questions
Includes
Arrays, linked lists, stacks, queues, complexity, recursion
Time to aim for
About 90 seconds each

Frequently asked questions

Should I say the complexity of my solution?

Yes, always. State the time and the extra space it needs, and mention a simpler but slower approach if you started there. Interviewers value that you know the trade-off.

What if I am stuck on a problem?

Say what you are thinking and try a small example by hand. Showing your reasoning matters more than a perfect answer, and the interviewer may give a hint.

More quick answers