Skip to content

Programs and notes for Competitive Coding. Covers important data structures and algorithms like stacks, queues, linked lists, trees, hashing, tries, and basic problem-solving tasks. Ideal for quick practice and revision.

Notifications You must be signed in to change notification settings

Withakash/Competitive-Coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Competitive Coding — Practical Programs & Notes (303105259)

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.


Introduction

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.


Syllabus Focus

  • 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

Practical Explanations (1–25)

  1. MINSTACK Implementation
    Stack with push, pop, and ability to get the minimum element in O(1) time.

  2. Expression Evaluation Using Stack
    Evaluate postfix/prefix expressions using stack operations.

  3. Next Greater Element
    Find the next greater element for each array element using stack.

  4. Circular Queue (k)
    Implement circular queue with enqueue, dequeue, front, and rear operations.

  5. Infix to Postfix Conversion
    Use the Shunting Yard Algorithm with stack & queue to convert expressions.

  6. Product of Three Largest Distinct Elements
    Use a priority queue (max-heap) to find the product of the top 3 distinct values.

  7. Merge Two Sorted Linked Lists
    Merge two sorted linked lists into a single sorted list.

  8. Find Merge Point of Two Linked Lists
    Detect the node where two linked lists intersect.

  9. Swap Nodes Pairwise
    Swap nodes of a linked list in pairs without swapping values.

  10. Validate a BST (isValidBST)
    Check whether a binary tree satisfies all BST properties.

  11. Build a BST
    Insert nodes and construct a Binary Search Tree.

  12. Max Depth of Binary Tree
    Find the height of a binary tree using recursion.

  13. Tree Traversals
    Implement Preorder, Inorder, and Postorder traversals.

  14. Boundary Traversal of Binary Tree
    Print the boundary nodes: left boundary, leaves, and right boundary.

  15. Lowest Common Ancestor (LCA)
    Find the lowest common ancestor of two nodes in a tree/BST.

  16. Mirror Tree Check
    Check if two trees are mirror images of each other.

  17. Basic Hash Function
    Implement a simple hash function and test key-value storage.

  18. Hash Table Using Separate Chaining
    Create a hash table with insertion, deletion, and search using chaining.

  19. Two Sum Using HashMap
    Return indices of numbers that add up to a target value.

  20. Trie — Insert, Search, Delete
    Implement trie operations for storing and searching words.

  21. Huffman Coding
    Use a min-heap to generate prefix codes for data compression.

  22. Distinct Substrings
    Count all distinct substrings using Trie or hashing.

  23. Count Words in Trie
    Count how many words are stored inside a Trie structure.

  24. Left View of Binary Tree
    Print nodes visible from the left side of a tree.

  25. Level Order Traversal
    Implement BFS on a binary tree using a queue.


Java Starter Files

Each practical has a starter .java file under the matching folder. Implement methods and add tests inside main.

Example files:

  • Stack/MinStack.java
  • Stack/ExpressionEvaluation.java
  • Stack/NextGreaterElement.java
  • Queue/CircularQueue.java
  • Queue/InfixToPostfix.java
  • PriorityQueue/ProductOfThreeLargest.java
  • LinkedList/MergeSortedLinkedLists.java
  • LinkedList/MergePointLinkedLists.java
  • LinkedList/SwapNodesPairwise.java
  • BST/ValidateBST.java
  • BST/BuildBST.java
  • Tree/MaxDepthBinaryTree.java
  • Tree/TreeTraversals.java
  • Tree/BoundaryTraversal.java
  • Tree/LowestCommonAncestor.java
  • Tree/MirrorTreeCheck.java
  • Hashing/BasicHashFunction.java
  • Hashing/HashTableSeparateChaining.java
  • Hashing/TwoSumHashMap.java
  • Trie/TrieOperations.java
  • Strings/HuffmanCoding.java
  • Strings/DistinctSubstrings.java
  • Trie/CountWordsInTrie.java
  • Tree/LeftViewBinaryTree.java
  • Tree/LevelOrderTraversal.java

Folder Structure

CompetitiveCoding/
│
├── Stack/
├── Queue/
├── PriorityQueue/
├── LinkedList/
├── Tree/
├── BST/
├── Hashing/
├── Trie/
├── Strings/
│
└── README.md

How to Compile & Run (Java)

Compile a file:

javac path/to/FileName.java

Run the program:

java FileName

If class is inside a package, use the package-qualified name.


Included Syllabus PDF

Syllabus provided with the assignment is included here:
syllabus (CompetitiveCodingSyllabus.pdf)


Recommended Platforms

  • LeetCode
  • Codeforces
  • GeeksforGeeks
  • HackerRank

Contribute

Contributions such as optimized solutions, test cases, or documentation improvements are welcome.
Open a pull request with your changes.


About

Programs and notes for Competitive Coding. Covers important data structures and algorithms like stacks, queues, linked lists, trees, hashing, tries, and basic problem-solving tasks. Ideal for quick practice and revision.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages