This repository contains solutions for the Data Structures and Algorithms (DSA) practical exam for 4th semester B.Tech students. The solutions are organized week-wise and include various searching, sorting, graph, and dynamic programming algorithms.
- Name: Aditya Pandey
- Semester: 4th
- Branch: B.Tech (CSE)
- Course: Data Structures and Algorithms
- Instructor: Suraj Sir
- Linear Search Implementation
- Binary Search Implementation
- Jump Search Implementation
- Binary Search with Duplicate Elements
- Finding Three Indices (i, j, k) such that
arr[i] + arr[j] = arr[k]
- Counting Pairs with Given Difference
- Insertion Sort with Comparisons and Shifts
- Selection Sort with Comparisons and Swaps
- Duplicate Element Detection using Sorting
- Merge Sort with Comparisons and Inversions
- Quick Sort with Random Pivot
- Kth Smallest/Largest Element Finding
- Maximum Occurring Alphabet
- Pair Sum Problem
- Common Elements in Two Sorted Arrays
- Path Existence Check using DFS
- Bipartite Graph Check using BFS
- Cycle Detection in Directed Graph
- Dijkstra's Algorithm
- Bellman-Ford Algorithm
- Shortest Path with K Edges
- Prim's Algorithm
- Kruskal's Algorithm
- Maximum Spanning Tree
- Floyd-Warshall Algorithm
- Fractional Knapsack
- File Merging
- Activity Selection
- Task Scheduling with Deadlines
- Majority Element and Median
- Matrix Chain Multiplication
- Coin Change
- Equal Sum Partition
Input:
T (number of test cases)
For each test case:
n (size of array)
n space-separated integers
key (element to search)
Output:
For each test case:
"Present" or "Not Present"
Number of comparisons
Input:
T (number of test cases)
For each test case:
n (size of array)
n space-separated integers
Output:
For each test case:
Sorted array
Number of comparisons
Number of swaps/shifts/inversions
Each program follows a specific input/output format as described in the respective week's README.md file. Please refer to those files for detailed information about:
- Input format
- Output format
- Example test cases
- Time and space complexities
- Clone the repository:
git clone https://github.com/yourusername/dsa-4th-sem-mid-practical.git
- Navigate to the specific week's folder:
cd week1 # or week2, week3, etc.
- Compile and run the programs:
g++ -std=c++11 program.cpp -o program
./program
Algorithm | Best Case | Average Case | Worst Case |
---|---|---|---|
Linear Search | O(1) | O(n) | O(n) |
Binary Search | O(1) | O(log n) | O(log n) |
Jump Search | O(√n) | O(√n) | O(√n) |
Insertion Sort | O(n) | O(n²) | O(n²) |
Selection Sort | O(n²) | O(n²) | O(n²) |
Merge Sort | O(n log n) | O(n log n) | O(n log n) |
Quick Sort | O(n log n) | O(n log n) | O(n²) |
Each week's README.md file contains a detailed table of time and space complexities for all implemented algorithms.
Feel free to contribute to this repository by:
- Forking the repository
- Creating a new branch
- Making your changes
- Submitting a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Coding! 🚀