Prepare Interview

Mock Exams

Make Homepage

## Freshers / Beginner level questions & answers

### Ques 1. What is the difference between BFS and DFS?

BFS explores nodes level by level, while DFS explores as far as possible along each branch before backtracking. BFS uses a queue, and DFS uses a stack or recursion.

### Ques 2. Explain the concept of Big-O notation.

Big-O notation describes the upper bound of an algorithm's time or space complexity in the worst-case scenario. It provides an asymptotic growth rate, ignoring constant factors and lower-order terms.

### Ques 3. Explain the concept of a binary search tree (BST).

A binary search tree is a binary tree where the left subtree of a node contains only nodes with keys less than the node's key, and the right subtree contains only nodes with keys greater than the node's key.

### Ques 4. Explain the concept of divide and conquer.

Divide and conquer is a problem-solving strategy that involves breaking a problem into smaller subproblems, solving each subproblem independently, and then combining the solutions to solve the original problem.

### Ques 5. What is the difference between depth-first search and breadth-first search?

DFS explores as far as possible along each branch before backtracking, while BFS explores nodes level by level. DFS uses a stack or recursion, and BFS uses a queue.

### Ques 6. How does the Merge Sort algorithm work?

Merge Sort is a divide and conquer algorithm that divides the input array into two halves, recursively sorts each half, and then merges the sorted halves to produce a sorted array.

### Ques 7. Explain the concept of memoization.

Memoization is an optimization technique where the results of expensive function calls are stored and reused, avoiding redundant computations. It is often used in dynamic programming.

### Ques 8. What is the difference between depth-first search and depth-limited search?

Depth-first search explores as far as possible along each branch before backtracking, while depth-limited search restricts the depth of exploration to a specified limit before backtracking.

### Ques 9. Explain the concept of the Manhattan distance.

Manhattan distance, also known as L1 distance or taxicab distance, is the sum of the absolute differences between the corresponding coordinates of two points. It is often used in grid-based pathfinding algorithms.

### Ques 10. Explain the concept of the two-pointer technique.

The two-pointer technique involves maintaining two pointers (indexes) that traverse an array or sequence at different speeds. It is often used in algorithms that involve searching for pairs, detecting cycles, or optimizing sliding window problems.

### Ques 11. Explain the concept of the Sieve of Eratosthenes.

The Sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to a given limit. It works by iteratively marking the multiples of each prime, starting from 2.

### Ques 12. Explain the concept of the Levenshtein distance.

Levenshtein distance measures the minimum number of single-character edits (insertions, deletions, or substitutions) required to transform one string into another. It is used in spell checking and DNA analysis.

### Ques 13. Explain the concept of the Depth-First Search (DFS) tree.

In a DFS traversal, the DFS tree is a tree structure that represents the parent-child relationships between the vertices visited during the traversal. It is used in graph analysis and connectivity.