This repository contains all 25 practical programs, explanations, and topic-wise Java starter implementations for the Competitive Coding subject.
It is designed for quick revision, clean understanding, and strong practice of core Data Structures and Algorithms.
This repository includes simple and clear Java starter code for all practicals listed in the syllabus.
Each file contains a template you can extend and test. Use these starters to implement solutions, run tests, and submit lab assignments.
- Build strong problem-solving skills
- Learn real-world usage of data structures
- Improve algorithmic thinking
- Practice coding patterns used in interviews
- Strengthen fundamentals with hands-on programs
-
MINSTACK Implementation
Stack with push, pop, and ability to get the minimum element in O(1) time. -
Expression Evaluation Using Stack
Evaluate postfix/prefix expressions using stack operations. -
Next Greater Element
Find the next greater element for each array element using stack. -
Circular Queue (k)
Implement circular queue with enqueue, dequeue, front, and rear operations. -
Infix to Postfix Conversion
Use the Shunting Yard Algorithm with stack & queue to convert expressions. -
Product of Three Largest Distinct Elements
Use a priority queue (max-heap) to find the product of the top 3 distinct values. -
Merge Two Sorted Linked Lists
Merge two sorted linked lists into a single sorted list. -
Find Merge Point of Two Linked Lists
Detect the node where two linked lists intersect. -
Swap Nodes Pairwise
Swap nodes of a linked list in pairs without swapping values. -
Validate a BST (isValidBST)
Check whether a binary tree satisfies all BST properties. -
Build a BST
Insert nodes and construct a Binary Search Tree. -
Max Depth of Binary Tree
Find the height of a binary tree using recursion. -
Tree Traversals
Implement Preorder, Inorder, and Postorder traversals. -
Boundary Traversal of Binary Tree
Print the boundary nodes: left boundary, leaves, and right boundary. -
Lowest Common Ancestor (LCA)
Find the lowest common ancestor of two nodes in a tree/BST. -
Mirror Tree Check
Check if two trees are mirror images of each other. -
Basic Hash Function
Implement a simple hash function and test key-value storage. -
Hash Table Using Separate Chaining
Create a hash table with insertion, deletion, and search using chaining. -
Two Sum Using HashMap
Return indices of numbers that add up to a target value. -
Trie — Insert, Search, Delete
Implement trie operations for storing and searching words. -
Huffman Coding
Use a min-heap to generate prefix codes for data compression. -
Distinct Substrings
Count all distinct substrings using Trie or hashing. -
Count Words in Trie
Count how many words are stored inside a Trie structure. -
Left View of Binary Tree
Print nodes visible from the left side of a tree. -
Level Order Traversal
Implement BFS on a binary tree using a queue.
Each practical has a starter .java file under the matching folder. Implement methods and add tests inside main.
Example files:
Stack/MinStack.javaStack/ExpressionEvaluation.javaStack/NextGreaterElement.javaQueue/CircularQueue.javaQueue/InfixToPostfix.javaPriorityQueue/ProductOfThreeLargest.javaLinkedList/MergeSortedLinkedLists.javaLinkedList/MergePointLinkedLists.javaLinkedList/SwapNodesPairwise.javaBST/ValidateBST.javaBST/BuildBST.javaTree/MaxDepthBinaryTree.javaTree/TreeTraversals.javaTree/BoundaryTraversal.javaTree/LowestCommonAncestor.javaTree/MirrorTreeCheck.javaHashing/BasicHashFunction.javaHashing/HashTableSeparateChaining.javaHashing/TwoSumHashMap.javaTrie/TrieOperations.javaStrings/HuffmanCoding.javaStrings/DistinctSubstrings.javaTrie/CountWordsInTrie.javaTree/LeftViewBinaryTree.javaTree/LevelOrderTraversal.java
CompetitiveCoding/
│
├── Stack/
├── Queue/
├── PriorityQueue/
├── LinkedList/
├── Tree/
├── BST/
├── Hashing/
├── Trie/
├── Strings/
│
└── README.md
Compile a file:
javac path/to/FileName.javaRun the program:
java FileNameIf class is inside a package, use the package-qualified name.
Syllabus provided with the assignment is included here:
syllabus (CompetitiveCodingSyllabus.pdf)
- LeetCode
- Codeforces
- GeeksforGeeks
- HackerRank
Contributions such as optimized solutions, test cases, or documentation improvements are welcome.
Open a pull request with your changes.