GithubHelp home page GithubHelp logo

ktj94 / data-structures-algorithms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anubhavshrimal/data-structures-algorithms

0.0 1.0 0.0 162 KB

My implementation of 80+ popular data structures and algorithms and interview questions in Python 3 and C++

License: MIT License

C++ 3.14% Python 96.86%

data-structures-algorithms's Introduction

Data Structures and Algorithms

My implementation of some popular data structures and algorithms and interview questions relating to them in Python 3 and C++

Index:


Content:

Bit Manipulation

Contains some popular questions based on bit manipulations.

Topic/Question Code in Python Code in C++
Check whether a given number n is a power of 2 or 0 py cpp
Count number of bits needed to be flipped to convert A to B py cpp
Find the two non-repeating elements in an array of repeating elements py -
Find the next greater and next smaller number with same number of set bits py -

Dynamic Programming

Contains some popular questions based on dynamic programming approach.

Topic/Question Code in Python Code in C++
0-1 Knapsack Problem py -
Cutting Rod problem py -
minimum number of edits (operations) required to convert ‘str1’ into ‘str2’ py -
Given a 2-D matrix of 0s and 1s, find the Largest Square which contains all 1s in itself py -
Given two sequences, print the longest subsequence present in both of them. py -
Length of the longest subsequence in an array such that all elements of the subsequence are sorted in increasing order py -
Find minimum cost path in a matrix from (0,0) to given point (m,n) py -
Partition a set into two subsets such that the difference of subset sums is minimum py -
Determine if there is a subset of the given set with sum equal to given sum py -
Maximum Subarray Problem py -
Given a distance ‘dist, count total number of ways to cover the distance with 1, 2 and 3 steps py -

Graph

Contains implementation of Graph data structure and some common questions and algorithms related to it.

Topic/Question Code in Python Code in C++
Find all possible words in a board of characters py -
Breadth First Search Traversal py -
Depth First Search Traversal py -
Detect Cycle in directed graph py -
Detect cycle in undirected graph py -
Dijkstra’s Shortest Path Algorithm py -
Find shortest distances between each pair of vertices in a given edge weighted directed Graph py -
Graph implementation py -
Kruskal's Algorithm for Minimum Spanning Tree py -
Topological Sort py -

Heaps

Contains implementation of Heap data structure and some common questions and algorithms related to it.

Topic/Question Code in Python Code in C++
Heap Sort algorithm py -
Max Heap implementation py -
Min Heap implementation py -
Find the median for an incoming stream of numbers after each insertion in the list of numbers py -

Linked List

Contains implementation of Linked List data structure and some common questions and algorithms related to it.

Singly Linked List
Topic/Question Code in Python Code in C++
Clone a linked list with next and random pointer py -
Given a linked list of line segments, remove middle points if any py -
Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes. py -
Merge a linked list into another linked list at alternate positions py -
Perform Merge Sort py -
Find Middle Node py -
Point to next higher value node in a linked list with an arbitrary pointer py -
Find if linked list contains any cycle py -
To select a random node in a singly linked list py -
Find and remove cycle if any py -
Reverse sub list of K nodes each py -
Reverse alternate sub list of K nodes each py -
Reverse a linked list py -
Bring even valued nodes to the front py -
Implementation of Singly Linked List py cpp
Skip M nodes and then delete N nodes alternately py -

Mathematics

Contains implementation of some common questions and algorithms related to Mathematics.

Topic/Question Code in Python Code in C++
Fine the number of trailing zeros in factorial of a number py cpp
Find the greatest common divisor of 2 numbers py -
print all prime factors of a given number py -
Sieve of Eratosthenes (find prime numbers up to n efficiently) py -

Matrix

Contains some common algorithms and questions based on Matrix.

Topic/Question Code in Python Code in C++
Given the Coordinates of King and Queen on a chessboard, check if queen threatens the king py -
Search in a row wise and column wise sorted matrix py -
Given a 2D array, print it in spiral form py -

Misc

Contains some miscellaneous questions and algorithms.

Topic/Question Code in Python Code in C++
Given a dictionary, write a function to flatten it py -

String or Array

Contains some common questions and algorithms related to strings or 1-d arrays.

Topic/Question Code in Python Code in C++
Find the longest substring with k unique characters in a given string py -
Find a pattern in a string using KMP search algorithm py -
Find the Kth smallest element in the array py -
Find a pair in an array with sum x py -
Print all valid (properly opened and closed) combinations of n pairs of parentheses py -
reverse the order of the words in the array py -
Find index of given number in a sorted array shifted by an unknown offset py -
Print all permutations of a given string py -

Searching

Topic/Question Code in Python Code in C++
Linear Search in an array py -
Binary Search in an array py -
Interpolation Search in an array py -

Sorting

Topic/Question Code in Python Code in C++
Bubble sort Algorithm py -
Counting sort Algorithm (non-comparision based sorting) py -
Insertion sort Algorithm py -
Sort an array where each element is at most k places away from its sorted position py -
Merge Sort Algorithm py -
Quick Sort Algorithm using last element as pivot py -
Selection sort Algorithm py -

Tree

Contains implementation of Tree data structure and some common questions and algorithms related to it.

Binary Search Tree
Topic/Question Code in Python Code in C++
Binary Search Tree implementation py -
Check if a given array can represent Preorder Traversal of Binary Search Tree py -
Find the in-order ancestor of a given node in BST py -
Find the Lowest Common Ancestor py -
Given a sorted array, create a BST with minimal height py -
Binary Tree
Topic/Question Code in Python Code in C++
Print Nodes in Bottom View of Binary Tree py -
Check if a binary tree is height balanced py -
Check whether a binary tree is a full binary tree or not py -
Given two binary trees, check if the first tree is subtree of the second one py -
Find the Lowest Common Ancestor in a Binary Tree py -
Create a list of all nodes at each depth py -
Find the maximum path sum i.e. max sum of a path in a binary tree py -
Find minimum depth of a binary tree py -
Remove nodes on root to leaf paths of length < K py -
Given a Perfect Binary Tree, reverse the alternate level nodes of the tree py -
Print Nodes in Top View of Binary Tree py -
Trie
Topic/Question Code in Python Code in C++
Implementation of Trie data structure py -

data-structures-algorithms's People

Contributors

anubhavshrimal avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.