Python Data Structures and Algorithms

Overview

Python Data Structures and Algorithms

No non-sense solutions to common Data Structure and Algorithm interview questions in Python. Follows a consistent approach throughout problems.

Objective

There are a plenty of resources when it comes to interview preparations on the internet. What prompted me to create this project was the dissimilarity across different approaches and the infused complexity of the code.

Feel free to contribute but please follow the Contributing Guidelines as I want to maintain the uniformity of the implementation of data structures and algorithms. Last time around, people bombarded with me with Pull Requests, Issues and Emails insisting me to merge their changes

The open source community has helped me a lot during my interview preparations and studies while I was in my undergrad. I always wanted to give something back to the community. In my endeavour to contribute something back, I will be uploading data structures and algorithms questions in Python in this repo. Feel free to contribute and get in touch!

Structure of the repository

As of now, the repository contains 3 main directories: Bookmarks, Data Structures and Algorithms.

Data Structures

Contains all data structure questions categorised into sub-directories like stack, queue, etc according to their type.

  1. Array
  2. Dictionary
  3. Binary Search Tree
  4. Linked List
  5. Stack
  6. Graphs
  7. Circular Linked List
  8. Doubly Linked List

Algorithms

This directory contains various types of algorithm questions like Dynamic Programming, Sorting, Greedy, etc. The current structure of this directory is as follows:

  1. Dynamic Programming
  2. Graphs
  3. Greedy
  4. Math
  5. Misc
  6. Sorting
  7. Bit Manipulation

Bookmarks

You can find useful links in this repository in the different markdown files. Below is a table of contents.

Category Link
Articles Click Here
Books Click Here
Topics Click Here
Tutorials Click Here
Videos Click Here
Misc. Click Here

Things need to be done

As you can see, the repo is still in its infancy. Here are some key things in the to-do.

  1. Queue questions
  2. Algorithms
  3. More questions in data structures, especially for graph, circular linked list, trees, heaps and hash.

Contributing

Contributions are always welcomed. Feel free to raise new issues, file new PRs. Consider giving it a star and fork this repo!

To follow the guidelines, refer to Contributing.md

License

MIT License

Comments
  • Create a logo for the repository's readme

    Create a logo for the repository's readme

    The readme will look better with a logo. We just need a minimalist and simple logo (only text) with the words python-ds.

    Feel free to file a PR :smiley:

    documentation help wanted good first issue Hacktoberfest design 
    opened by prabhupant 9
  • Create an index.md file for every sub-directory

    Create an index.md file for every sub-directory

    Having an index for every sub-directory will ease navigation around the repository. Here is the structure I think will do good

    - Data Structures
       - array
          - index.md
       - stack
          - index.md
    

    and so on.

    Please feel free to suggest improvements anywhere you feel like and contribute :smiley:

    documentation help wanted good first issue Hacktoberfest 
    opened by prabhupant 6
  • Create mkdocs or readthedocs explaining all data structures

    Create mkdocs or readthedocs explaining all data structures

    This is a big goal and will definitely take months. But if we want this repository to be a single source for interview prep and studying about data structures and algorithms, then having a comprehensive doc about each data structure with its theory like time complexities and use cases will definitely be a great thing.

    I will start working on this in order to give it some direction and momentum.

    Please feel free to suggest any improvements, open issues, point my short comings or contribute :smiley:

    documentation help wanted good first issue Hacktoberfest long-goal 
    opened by prabhupant 5
  • Deque Implementation

    Deque Implementation

    Description

    Added Deque implementation that uses python list. Deque is data structure. Personally me, I like it very much and use it often. It is like stack but has some advantages, you can add elements in both sides, as in back, also in front. I think it's very useful data structure.

    Please include a summary of the change and which issue is fixed or what question/feature you have added.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [ ] New feature/question

    Checklist:

    • [ ] My code follows the style guidelines of this project i.e. Pep8
    • [ ] I have performed a self-review of my own code
    opened by shotanozadze 4
  • Adding Kruskal_Minimum_spanning_tree.py

    Adding Kruskal_Minimum_spanning_tree.py

    Description

    Added greedy algorithm

    1. Sort all the edges in non-decreasing order of their weight.
    2. Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If cycle is not formed, include this edge. Else, discard it.
    3. Repeat step#2 until there are (V-1) edges in the spanning tree. Fixes # (issue) None

    Type of change

    Code Addition

    Please delete options that are not relevant.

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature/question
    • [ ] This change requires a documentation update
    • [ ] Bookmark link

    Checklist:

    • [ ] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] Any dependent changes have been merged and published in downstream modules
    • [ ] I have squashed unnecessary commits
    opened by whitehawk0011 4
  • min_product fix

    min_product fix

    Description

    min_product was broken - variable name mismatch - fixed it.

    Fixes # (issue)

    There was a variable name mismatch. count_negative should have been used instead of count_neg. Removed an unused variable. Also fixes one of the lint checks.

    Type of change

    • [x] Bug fix (non-breaking change which fixes an issue)

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] Any dependent changes have been merged and published in downstream modules
    • [x] I have squashed unnecessary commits
    opened by Harshal96 3
  • Added a question in dynamic programming

    Added a question in dynamic programming

    Description

    Added a new Dynamic Programming quesion.

    Fixes #279

    Type of change

    Please delete options that are not relevant.

    • [x] New feature/question

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] Any dependent changes have been merged and published in downstream modules
    • [x] I have squashed unnecessary commits
    opened by imehar 3
  • middle_element.py

    middle_element.py

    middle element by swapnil

    Description

    Please include a summary of the change and which issue is fixed or what question/feature you have added.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature/question
    • [ ] This change requires a documentation update
    • [ ] Bookmark link

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [ ] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] Any dependent changes have been merged and published in downstream modules
    • [ ] I have squashed unnecessary commits
    opened by swapnil112 3
  • Gnome sort

    Gnome sort

    Description

    Please include a summary of the change and which issue is fixed or what question/feature you have added.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [x] New feature/question

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have squashed unnecessary commits
    opened by Hyde46 3
  • implement gnome sort algorithm

    implement gnome sort algorithm

    Description

    implement gnome sort algorithm with examples.

    Fixes #361

    Please delete options that are not relevant. [ ] New feature/question

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] Any dependent changes have been merged and published in downstream modules
    • [x] I have squashed unnecessary commits
    opened by beqakd 2
  • division factors

    division factors

    Description

    Natural number divisors and prime factors.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [ ] New feature/question
    • [ ] Bookmark link

    Checklist:

    • [ ] My code follows the style guidelines of this project i.e. Pep8
    • [ ] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] Any dependent changes have been merged and published in downstream modules
    • [ ] I have squashed unnecessary commits
    opened by shotanozadze 2
  • An alternate way without using sys module

    An alternate way without using sys module

    Description

    Most online compilers do not support the sys module which is the reason I have added an alternate way to solve this question. #Hacktoberfest

    opened by Tiagupt03 0
  • Created next_highest_pow_2.py

    Created next_highest_pow_2.py

    Description

    Please include a summary of the change and which issue is fixed or what question/feature you have added.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [x] New feature/question

    Checklist:

    • [x] I have performed a self-review of my own code
    opened by rayavarapuvikram1 0
  • Added Rabin_karp Algorithm

    Added Rabin_karp Algorithm

    Description

    Added Python Program -> Rabin-Karp Algorithm for Pattern Searching in data_structures/strings

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [x] New feature/question

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] Any dependent changes have been merged and published in downstream modules
    • [x] I have squashed unnecessary commits
    opened by codingis4noobs2 0
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • data_structures/array/all_numbers_divisible.py
    • data_structures/array/index.md
    • data_structures/binary_trees/children_sum_property.py
    • data_structures/graphs/cycle_in_directed_graph_using_colors.py
    • data_structures/graphs/cycle_in_directed_graph_using_colors_recursive.py
    • data_structures/graphs/dag_longest_path.py
    • data_structures/heap/max_heap.py
    • data_structures/strings/KMP_Pattern_Search.py

    Fixes:

    • Should read initial rather than inital.
    • Should read equal rather than eqaul.
    • Should read satisfies rather than statisfies.
    • Should read divisible rather than divisble.
    • Should read comparison rather than comparision.
    • Should read children rather than childen.
    • Should read calculate rather than caluclate.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • add test for coin change function

    add test for coin change function

    Description

    Please include a summary of the change and which issue is fixed or what question/feature you have added.

    Fixes # (issue)

    Type of change

    Please delete options that are not relevant.

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature/question
    • [ ] This change requires a documentation update
    • [ ] Bookmark link

    Checklist:

    • [x] My code follows the style guidelines of this project i.e. Pep8
    • [x] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] Any dependent changes have been merged and published in downstream modules
    • [ ] I have squashed unnecessary commits
    opened by tranlinh19021320 1
Owner
Prabhu Pant
Hacker | Philosopher
Prabhu Pant
This repository is for adding codes of data structures and algorithms, leetCode, hackerrank etc solutions in different languages

DSA-Code-Snippet This repository is for adding codes of data structures and algorithms, leetCode, hackerrank etc solutions in different languages Cont

DSCSRMNCR 3 Oct 22, 2021
Data Structures and algorithms package implementation

Documentation Simple and Easy Package --This is package for enabling basic linear and non-linear data structures and algos-- Data Structures Array Sta

null 1 Oct 30, 2021
This repo is all about different data structures and algorithms..

Data Structure and Algorithm : Want to learn data strutrues and algorithms ??? Then Stop thinking more and start to learn today. This repo will help y

Priyanka Kothari 7 Jul 10, 2022
A collection of data structures and algorithms I'm writing while learning

Data Structures and Algorithms: This is a collection of data structures and algorithms that I write while learning the subject Stack: stack.py A stack

Dhravya Shah 1 Jan 9, 2022
One-Stop Destination for codes of all Data Structures & Algorithms

CodingSimplified_GK This repository is aimed at creating a One stop Destination of codes of all Data structures and Algorithms along with basic explai

Geetika Kaushik 21 Sep 26, 2022
Webtesting for course Data Structures & Algorithms

Selenium job to automate queries to check last posts of Module Data Structures & Algorithms Web-testing for course Data Structures & Algorithms Struct

null 1 Dec 15, 2021
pyprobables is a pure-python library for probabilistic data structures

pyprobables is a pure-python library for probabilistic data structures. The goal is to provide the developer with a pure-python implementation of common probabilistic data-structures to use in their work.

Tyler Barrus 86 Dec 25, 2022
Svector (pronounced Swag-tor) provides extension methods to pyrsistent data structures

Svector Svector (pronounced Swag-tor) provides extension methods to pyrsistent data structures. Easily chain your methods confidently with tons of add

James Chua 5 Dec 9, 2022
Python library for doing things with Grid-like structures

gridthings Python library for doing things with Grid-like structures Development This project uses poetry for dependency management, pre-commit for li

Matt Kafonek 2 Dec 21, 2021
Supporting information (calculation outputs, structures)

Supporting information (calculation outputs, structures)

Eric Berquist 2 Feb 2, 2022
Final Project for Practical Python Programming and Algorithms for Data Analysis

Final Project for Practical Python Programming and Algorithms for Data Analysis (PHW2781L, Summer 2020) Redlining, Race-Exclusive Deed Restriction Lan

Aislyn Schalck 1 Jan 27, 2022
Basic sort and search algorithms written in python.

Basic sort and search algorithms written in python. These were all developed as part of my Computer Science course to demonstrate understanding so they aren't 100% efficent

Ben Jones 0 Dec 14, 2022
Leetcode solutions - All algorithms implemented in Python 3 (for education)

Leetcode solutions - All algorithms implemented in Python 3 (for education)

Vineet Dhaimodker 3 Oct 21, 2022
RLStructures is a library to facilitate the implementation of new reinforcement learning algorithms.

RLStructures is a lightweight Python library that provides simple APIs as well as data structures that make as few assumptions as possibl

Facebook Research 262 Nov 18, 2022
Integrating C Buffer Data Into the instruction of `.text` segment instead of on `.data`, `.rodata` to avoid copy.

gcc-bufdata-integrating2text Integrating C Buffer Data Into the instruction of .text segment instead of on .data, .rodata to avoid copy. Usage In your

Jack Ren 1 Jan 31, 2022
My notes on Data structure and Algos in golang implementation and python

My notes on DS and Algo Table of Contents Arrays LinkedList Trees Types of trees: Tree/Graph Traversal Algorithms Heap Priorty Queue Trie Graphs Graph

Chia Yong Kang 0 Feb 13, 2022
Data Structure With Python

Data-Structure-With-Python- Python programs also include in this repo Stack A stack is a linear data structure that stores items in a Last-In/First-Ou

Sumit Nautiyal 2 Jan 9, 2022
This repo represents all we learned and are learning in Data Structure course.

DataStructure Journey This repo represents all we learned and are learning in Data Structure course which is based on CLRS book and is being taught by

Aprime Afr (Alireza Afroozi) 3 Jan 22, 2022
IADS 2021-22 Algorithm and Data structure collection

A collection of algorithms and datastructures introduced during UoE's Introduction to Datastructures and Algorithms class.

Artemis Livingstone 20 Nov 7, 2022