A DSA repository but everything is in python.

Related tags

Data Structures DSA
Overview

DSA

Status

Travis (.org) Codacy grade Donate  GitHub repo size Lines of code

GitHub pull requests GitHub issues GitHub forks GitHub Repo stars GitHub watchers GitHub

Contents

Ugh, not another DSA repository but anyway. What the fork is this?

This repository is the implementation of the contents DSA self paced series by yours truly but in Python

Aren't we supposed to learn DSA in say C++?

YOU SHOULD but we both know you won't or can't write C++

So, what's up with your code? Why should I look into it?

Yours truly for each topic he came across has written the code in 1-2 or more than 2 methods which perform the exact same task. So that you could choose whichever method works for you. Each method is tested under the tests/ with pytest

So what's the difference between method 1 and 2?

Well, if you look closely, I mean really closely you could see the timeit module in __main__ which shows the time taken by that particular function to run

def method1(n: int) -> int:
    return len(str(n)) if n >= 0 else len(str(n)) - 1


def method2(n: int) -> int:
    import math

    return int(math.log10(n) + 1 if n > 0 else (1 if n == 0 else math.log10(-n) + 1))


if __name__ == "__main__":
    """
    from timeit import timeit
    print(timeit(lambda: method1(1234567890), number=10000)) # 0.0022839140001451597
    print(timeit(lambda: method2(1234567890), number=10000)) # 0.004222848001518287
    """

So is the time taken by timeit reliable?

Fork no, but still for the best result I ran the methods 10 thousand times each. My machine is Asus-UX425JA with Fedora 33 on kernel 5.9 with several stackoverflow tabs and a spotify tab open when I ran each timeit

TODO:

Contributors

You might also like...
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

A Python library for electronic structure pre/post-processing
A Python library for electronic structure pre/post-processing

PyProcar PyProcar is a robust, open-source Python library used for pre- and post-processing of the electronic structure data coming from DFT calculati

Programming of a spanning tree algorithm with Python : In depth first with a root node.

ST Algorithm Programming of a spanning tree algorithm with Python : In depth first with a root node. Description This programm reads informations abou

A Python dictionary implementation designed to act as an in-memory cache for FaaS environments

faas-cache-dict A Python dictionary implementation designed to act as an in-memory cache for FaaS environments. Formally you would describe this a mem

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

🔬 Fixed struct serialization system, using Python 3.9 annotated type hints

py-struct Fixed-size struct serialization, using Python 3.9 annotated type hints This was originally uploaded as a Gist because it's not intended as a

Final Project for Practical Python Programming and Algorithms for Data Analysis
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

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

A Python implementation of red-black trees

Python red-black trees A Python implementation of red-black trees. This code was originally copied from programiz.com, but I have made a few tweaks to

Comments
  • Added algorithm to find the saddle point of a matrix

    Added algorithm to find the saddle point of a matrix

    This pull request is for hacktoberfest.

    A saddle point is an element of the matrix such that it is the minimum element in its row and maximum in its column

    opened by Princeton21 2
  • Add comments in programs for better understanding

    Add comments in programs for better understanding

    Right now almost none of the program have comments which is bad as anyone would know. It'd be better for everyone if comments were added that would act as a flow through to what a program is supposed to do and what's it about.

    opened by thisisshub 7
Owner
Shubhashish Dixit
Beep bop. Boop beep?
Shubhashish Dixit
This Repository consists of my solutions in Python 3 to various problems in Data Structures and Algorithms

Problems and it's solutions. Problem solving, a great Speed comes with a good Accuracy. The more Accurate you can write code, the more Speed you will

SAMIR PAUL 1.3k Jan 1, 2023
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
This repository contains code for CTF platform.

CTF-platform Repository for backend of CTF hosting website For starting the project first time : Clone the repo in which you have to work in your syst

Yash Jain 3 Feb 18, 2022
Array is a functional mutable sequence inheriting from Python's built-in list.

funct.Array Array is a functional mutable sequence inheriting from Python's built-in list. Array provides 100+ higher-order methods and more functiona

null 182 Nov 21, 2022
Common sorting algorithims in Python

This a Github Repository with code for my attempts for commonly used sorting algorithims, tested on a list with 3000 randomly generated numbers.

Pratham Prasoon 14 Sep 2, 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
Python collections that are backended by sqlite3 DB and are compatible with the built-in collections

sqlitecollections Python collections that are backended by sqlite3 DB and are compatible with the built-in collections Installation $ pip install git+

Takeshi OSOEKAWA 11 Feb 3, 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
nocasedict - A case-insensitive ordered dictionary for Python

nocasedict - A case-insensitive ordered dictionary for Python Overview Class NocaseDict is a case-insensitive ordered dictionary that preserves the or

PyWBEM Projects 2 Dec 12, 2021
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