AITeky Learn

Data structures and algorithms

Arrays and linked lists, stacks and queues, trees, hashing, sorting, Big O. 20 questions with model answers.

1. What is the difference between an array and a linked list? Basic

An array stores items next to each other in memory, so you can reach any item by index in O(1), but inserting or deleting in the middle means shifting items, O(n), and its size is often fixed. A linked list stores items in nodes, each pointing to the next, so inserting or deleting at a known node is O(1) and it grows easily, but reaching the nth item means walking from the start, O(n), and each node uses extra memory for the pointer.

What the interviewer listens for

  • Contiguous memory versus nodes with pointers
  • Access by index O(1) versus O(n)
  • Insert and delete cost
  • Memory and cache behaviour

They may ask next: When would you choose a linked list over an array?

2. What is the difference between a stack and a queue? Basic

A stack is last in, first out: you push and pop at the same end, like a pile of plates. It is used for function calls, undo, and checking balanced brackets. A queue is first in, first out: you add at the back and remove from the front, like a ticket line. It is used for scheduling, printers and breadth-first search. Both do their main operations in O(1).

What the interviewer listens for

  • LIFO versus FIFO
  • Push and pop versus enqueue and dequeue
  • Real uses of each
  • O(1) operations

They may ask next: How would you build a queue using two stacks?

3. What is time complexity? What does Big O mean? Basic

Time complexity describes how the running time of an algorithm grows as the input size n grows. Big O gives an upper bound on that growth, ignoring constants: O(1) constant, O(log n) such as binary search, O(n) a single loop, O(n log n) good sorting, O(n squared) two nested loops. It lets us compare algorithms without running them.

What the interviewer listens for

  • Growth with input size
  • Big O as upper bound, constants dropped
  • Common classes with examples

They may ask next: What is space complexity? Give the space complexity of merge sort.

These are 3 of the 20 questions. The rest, and practice rounds with Ari, come with Campus Ready.

Sign up free to take the placement tests and see your readiness

It takes a minute with your email. AiTeky Pass (₹999/month or ₹9,999/year) is free for your first 30 days.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in