Famous Algorithms: Sorting Algorithms
Famous Algorithms: Sorting Algorithms
ASKED:
Famous Algorithms:
1. Sorting Algorithms:
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Heap Sort
2. Searching Algorithms:
Linear Search
Binary Search
3. Graph Algorithms:
Breadth-First Search (BFS)
Depth-First Search (DFS)
Dijkstra's Algorithm
Bellman-Ford Algorithm
Floyd-Warshall Algorithm
4. Dynamic Programming Algorithms:
Fibonacci Series
Longest Common Subsequence
Shortest Path Problems
5. Greedy Algorithms:
Huffman Coding
Activity Selection Problem
6. Divide and Conquer Algorithms:
Merge Sort
Quick Sort
Binary Search
Reverse Array:
// Example solution
public class ReverseArray {
public static void reverse(int[] arr) {
int left = 0;
int right = arr.length - 1;
while (left < right) {
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}
class Node {
int data;
Node next;
class Node {
int key;
Node left;
Node right;
public Node(int key) {
this.key = key;
}
}
Implement Graph using Adjacency List:
// Example solution
public class Graph {
private Map<Integer, List<Integer>> adjacencyList;
public Graph() {
adjacencyList = new HashMap<>();
}