/DSAPractice

Java implementation of various Data Structures and Algorithms problems.

Primary LanguageJava

Data Structures and Algorithms in JAVA

This repo contains my implementation of various DSA questions.

Arrays

  • Array Insertion.
  • Array Delete.
  • Find largest element index.
  • Check if array is sorted.
  • Remove duplicates from sorted array.
  • Move all zeroes to the end.
  • Left rotate array by one.
  • Rotate array 'D' times.
  • Shift all negative elements to left side.
  • Spiral print Matrix.
  • Next Permutaion.
  • Max Sum Subarray (Kadane's Algorithm).
  • Set Matrix Zeros.
  • Factorial of a Large Number.

Recursion

  • Print 1 to N using recursion.
  • Factorial of a number
  • Count digits in a number
  • Sum of digits
  • Print elements of array using recursion
  • Sum of N natural numbers
  • Print Nth Fibonacci Number
  • nCr [Combinations: Choose R objects from N objects]
  • Check is a number is palindrome
  • Euclid's GCD Algorithm
  • Binary Exponentiation
  • Tower of Hanoi Move Count

Backtracking

  • Print all combinations with sum equal to given target
  • Print all permutations of an array
  • Print all combinations of K elements form an array
  • Pritn all anagrams of a given string
  • Break a string into words defined in a dictionary
  • Generate all combinations of well-formed parentheses.

Dynamic Programming

  • nTh Fibonacci
  • nCr [Combinations: Choose R objects from N objects]
  • Knapsack Problem
  • House Painting Problem
  • Number of ways to travel MxN Grid.

Hashing

  • Count non repeating elements
  • Print non repeating character in a string

Strings

  • Count words in a string
  • Convert to Lower Case
  • Convert to Upper Case
  • String Validation
  • Check is string is a panagram
  • Find missing characters from panagram
  • Reverse a string
  • Check if two strings are anagrams
  • Find if there is an anagram of given pattern present in given string

Searching

  • Binary Search [Iterative]
  • Binary Search [Recursive]
  • Find first occurence of element using binary search [Iterative]
  • Find first occurence of element using binary search [Recusrive]
  • Find majority element (That appears more than n/2 times)
  • Find square root floor of given number

Sorting

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort

Linked Lists

Implemented generic Singly Linked List class with following functions:

  • Add an element
  • Add an element in the beginning
  • Add an element in the end
  • Add an element at a given index
  • Delete the first element
  • Delete the last element
  • Check if Linked List is empty
  • Find the size of the list
  • Print the list
  • Search for an element in the list
  • Get middle element of the list
  • Get nTh node from the end.
  • Reverse the linked list
  • Remove all duplicates from a sorted linked list
  • Delete at given index

Implemented generic Circular Linked List class with following functions:

  • Add at the beginning of a circular linked list
  • Add at the end of a circular linked list
  • Delete the head of circular linked list
  • Print cicular linked list
  • Delete kTh node.

Implemented generic Doubly Linked List class with following functions:

  • Add at the beginning of a Doubly linked list
  • Add at the end of a Doubly linked list
  • Delete the head of Doubly linked list
  • Delete the tail of Doubly linked list
  • Reverse doubly linked list
  • Print Doubly linked list

Stack

  • Implementation of stack using Array
  • Implementation of stack using Linked List
  • Balanced Paranthesis Check
  • Reverse array using stack
  • Infix to Postfix Conversion
  • Evaluation of Postfix Expressions

Queue

  • Implementation of Queue using two Stacks
  • Rotate DeQueue by K

Binary Tree

  • Pre Order Traversal [Depth First]
  • In Order Traversal [Depth First]
  • Post Order Traversal [Depth First]
  • Level Order Traversal [Breadth First]
  • Height of a binary tree
  • Print Top View of a Binary Tree

Binary Search Tree

  • Insert in BST
  • Search in BST
  • Delete from BST
  • Range Sum

Binary Heap

  • Min Heap Implementation
  • Heap Sort Algorithm
  • kTh Largest Element using Priority Queue.
  • kTh Smallest Element using Priority Queue.

Disjoint Set

  • Implementation of Disjoint set - Union by Rank and Path Compression.

Graphs

  • Adjacency List Implementation.
  • BFS (Breadth First Search).
  • BFS for Disconnected Graphs and No Source Given.
  • Count connected components in an Undirected Graph (Count Islands in a Graph).
  • DFS (Depth First Search).
  • Kruskal's Algorithm for finding Minimum Spanning Tree.
  • Topological Sort