A collection of data structures and algorithms I'm writing while learning

Overview

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 algorithm is a data structure that is like a pack of cards - a stack. Stack has the following properties:

Push

Adds element to the top of the stack

Pop

Removes element from the top of the stack

Peek

Returns the element at the top of the stack

Size and is_empty are just helper functions

Stuff Done with stack:

  • Checking if a bracket string is balanced Explanation:

    • Add all brackets in the stack one by one
    • on reaching a closing bracket, check if the top of the stack is a matching bracket
    • if it is, pop the top of the stack and check the next bracket
    • rinse and repeat
    • if the stack is empty, the string is balanced
    • otherwise, the string is not balanced in the end
  • Reverse algorithm Explanation:

    • Add all characters in the string to the stack
    • make a new string - which will hold the return value
    • pop the top of the stack until its empty and add it to the string
    • Voila! the string has been reversed
  • Int to binary conversion Explanation:

    • Divide the integer by 2 and add the remainder to the stack
    • the quotient obtained from the division is what we'll use to get the next remainder
    • Keep repeating until the quotient is 0
    • Reverse the stack by popping its values to obtain the binary string
        ___________________________
        |Quotient: 2 Remainder: 1  | - remainder added (Current stack: 1)
        |Quotient: 1 Remainder: 0  | - remainder added (Current stack: 10)
        |Quotient: 0 Remainder: 1  | - remainder added (Current stack: 101)
        ____________________________
        Answer will be the reverse of this stack : 101
    
You might also like...
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

IADS 2021-22 Algorithm and Data structure collection

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

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

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

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

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

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

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

My notes on Data structure and Algos in golang implementation and python
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

An esoteric data type built entirely of NaNs.

NaNsAreNumbers An esoteric data type built entirely of NaNs. Installation pip install nans_are_numbers Explanation A floating point number is just co

Owner
Dhravya Shah
Hi, I'm Dhravya (aka SpaceDoggo) ! 👋 I am a 16 year old interested in software development. I am mainly specialised in Python automation, discord bots, De
Dhravya Shah
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
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
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