DSA Programming Solutions

Data Structures & Algorithms | Instructor: Prof. N L Bhanu Murthy

Authors

PARTH MUNJAL

AKARSH JAIN

Published

March 30, 2026

Overview

Welcome to the Data Structures & Algorithms (DSA) solution repository. This section provides comprehensive C implementations for all tutorial and lab sheet problems, now organized by topic for better accessibility.

TipKey Features
  • Dynamic Memory: All solutions use malloc and free for efficient resource management.
  • Enhanced I/O: Sample test cases are clearly demarcated using callouts.
  • Optimized Algorithms: Key problems like “Sum of Subarray Minimums” use O(N) approaches.
ImportantExecution Note

These C solutions are designed for local compilation and execution. While Quarto provides a beautiful web interface, C code blocks with interactive stdin (like scanf) cannot be executed directly within the browser/rendered page. To test these solutions: 1. Copy the code into a local file (e.g., solution.c). 2. Compile using a C compiler: gcc solution.c -o solution. 3. Run the executable: ./solution.

Lab Sheets

Click on the links below to view the solutions for each lab sheet:

Lab Sheet 1: Basics & Arrays

  • Structs and Students Merit System
  • Matrix Multiplication
  • Text Analysis and Set Operations
  • Array Rotations and Frequency Counting

Lab Sheet 2: Linked Lists

  • Palindrome Checks (In-place)
  • Segregating Even/Odd nodes
  • List Rotations and Pair Swapping
  • Incremental Subsequences

Lab Sheet 3: Binary Search & Sorting

  • Student Ranking with Tie Handling
  • Finding Peak Elements
  • Minimum Eating Speed (Binary Search on Answer)
  • Rotated Array Search
  • Inversion Count (Merge Sort)

Lab Sheet 4: Advanced Search & Sorting

  • 2D Matrix Search (O(M+N))
  • Zig-Zag Group Sorting
  • Bitwise Strength Sort
  • Missing Frequency and Painting Timelines
  • Fair Tax Cap Optimization

Lab Sheet 5: Advanced Topics

  • 2D Prefix Sums (Rectangle Sum)
  • Arithmetic Progression identification
  • XOR Balancing
  • Quick Select (Kth Largest)
  • Radix Sort

Lab Sheet 6: Stacks

  • Monotonic Stacks (Stock Span, Daily Temp)
  • Largest Rectangle in Histogram
  • Expression Evaluation (Postfix)
  • String Decoding and Stack Permutations
  • Sparse Matrix to Adjacency List