/Data-Structures-and-Algorithms

CPP codes for some popular algorithms

Primary LanguageC++

ALGORITHMS

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.

Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

Given an unsorted array of size n. Array elements are in the range from 1 to n. One number from set {1, 2, …n} is missing and one number occurs twice in the array. Find these two numbers.

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

Given a collection of intervals, merge all overlapping intervals. Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].

DP 1:SINGLE SOURCE SHORTEST DISTANCE USING BELLMAN FORD ALGORITHM

DP 2: CHAIN MATRIX MULTIPLICATION FOR A CHAIN OF MATRICES

DP 3: EDIT DISTANCE:CONVERTING ONE STRING TO ANOTHER

DP 4:FIBONACCI SERIES BY TABULATION

DP 5:FIBONACCI SERIES BY MEMOIZATION

DP 6:ALL PAIRS OF SHORTEST PATH(FLOYD WARSHALL ALGORITHM)

DP 7:LONGEST COMMON SUBSEQUENCE IN A GIVEN PAIR OF STRINGS

DP 8:LONGEST INCREASING SUBSEQUENCE IN A GIVEN ARRAY OF INTEGERS

DP 9:FINDING PATH WITH MINIMUM COST

DP 10:TRAVELLING SALESMAN PROBLEM

DP 11:0-1 KNAPSACK PROBLEM

GA 1:SINGLE SOURCE SHORTEST PATH USING DIJKSTRA'S ALGORITHM

GA 2:FRACTIONAL KNAPSACK PROBLEM

GA 3:JOB SEQUENCING WITH DEADLINE

BT 1:HAMILTONIAN CYCLES IN A GRAPH

BT 2:N-QUEEN PROBLEM

BT 3:GRAPH COLOURING ALGORITHM

DC 1:BINARY SEARCH

DC 2:MERGE SORT

DC 3:QUICK SORT

AS 1:HEAP SORT

SM 1:KNUTH-MORRIS-PRATT ALGORITHM:

MOCKVITA 2020 : Swayambhar

MOCKVITA 2020 : Digit Pair