# Top 10 algorithms in Interview Questions

In this post “Top 10 coding problems of important  topics with their solutions ” are written. If you are preparing for a coding interview, going through these problems is a must.

Topics :

1.

Graph

2.

3.

Dynamic Programming

4.

Sorting And Searching

5.

Tree / Binary Search Tree

6.

Number Theory

7.

BIT Manipulation

8.

String / Array

Graph

1.

2.

Depth First Search (DFS)

3.

Shortest Path from source to all vertices **Dijkstra**

4.

Shortest Path from every vertex to every other vertex **Floyd Warshall**

5.

To detect cycle in a Graph **Union Find**

6.

Minimum Spanning tree **Prim**

7.

Minimum Spanning tree **Kruskal**

8.

Topological Sort

9.

Boggle (Find all possible words in a board of characters)

10.

Bridges in a Graph

1.

Insertion of a node in Linked List (On the basis of some constraints)

2.

Delete a given node in Linked List (under given constraints)

3.

Compare two strings represented as linked lists

4.

5.

6.

Reverse A List In Groups Of Given Size

7.

Union And Intersection Of 2 Linked Lists

8.

Detect And Remove Loop In A Linked List

9.

10.

Select A Random Node from A Singly Linked List

Dynamic Programming

1.

Longest Common Subsequence

2.

Longest Increasing Subsequence

3.

Edit Distance

4.

Minimum Partition

5.

Ways to Cover a Distance

6.

Longest Path In Matrix

7.

Subset Sum Problem

8.

Optimal Strategy for a Game

9.

0-1 Knapsack Problem

10.

Boolean Parenthesization Problem

Sorting And Searching

1.

Binary Search

2.

Search an element in a sorted and rotated array

3.

Bubble Sort

4.

Insertion Sort

5.

Merge Sort

6.

Heap Sort (Binary Heap)

7.

Quick Sort

8.

Interpolation Search

9.

Find Kth Smallest/Largest Element In Unsorted Array

10.

Given a sorted array and a number x, find the pair in array whose sum is closest to x

Tree / Binary Search Tree

1.

Find Minimum Depth of a Binary Tree

2.

Maximum Path Sum in a Binary Tree

3.

Check if a given array can represent Preorder Traversal of Binary Search Tree

4.

Check whether a binary tree is a full binary tree or not

5.

Bottom View Binary Tree

6.

Print Nodes in Top View of Binary Tree

7.

Remove nodes on root to leaf paths of length < K

8.

Lowest Common Ancestor in a Binary Search Tree

9.

Check if a binary tree is subtree of another binary tree

10.

Reverse alternate levels of a perfect binary tree

Number Theory

1.

Modular Exponentiation

2.

Modular multiplicative inverse

3.

Primality Test | Set 2 (Fermat Method)

4.

Eulerâ€™s Totient Function

5.

Sieve of Eratosthenes

6.

Convex Hull

7.

Basic and Extended Euclidean algorithms

8.

Segmented Sieve

9.

Chinese remainder theorem

10.

Lucas Theorem

BIT Manipulation

1.

Maximum Subarray XOR

2.

Magic Number

3.

Sum of bit differences among all pairs

4.

Swap All Odds And Even Bits

5.

Find the element that appears once

6.

Binary representation of a given number

7.

Count total set bits in all numbers from 1 to n

8.

Rotate bits of a number

9.

Count number of bits to be flipped to convert A to B

10.

Find Next Sparse Number

String / Array

1.

Reverse an array without affecting special characters

2.

All Possible Palindromic Partitions

3.

Count triplets with sum smaller than a given value

4.

Convert array into Zig-Zag fashion

5.

Generate all possible sorted arrays from alternate elements of two given sorted arrays

6.

Pythagorean Triplet in an array

7.

Length of the largest subarray with contiguous elements

8.

Find the smallest positive integer value that cannot be represented as sum of any subset of a given array

9.

Smallest subarray with sum greater than a given value

10.