GithubHelp home page GithubHelp logo

bfaure / python3_data_structures Goto Github PK

View Code? Open in Web Editor NEW
124.0 6.0 134.0 10 KB

Code from Youtube Tutorial Series

Python 100.00%
avl-tree bst python linked-list bst-validator binary-search-tree youtube

python3_data_structures's Introduction

Python3_Data_Structures

Code from Youtube Tutorial Series. Each lesson begins by introducing the idea behind the data structure then, after explaining some basic concepts, moves over to coding the actual Python class. The code in this repository is all implemented in Python 3, for Python 2 see 'Python_Data_Structures'.

The AVL Tree is an improvement upon the traditional Binary Search Tree (BST) that implements an auto-balancing feature, with the hopes to keep tree operations closer to O(logn) rather than O(n). After insertions and deletions that cause the tree to become unbalanced, special functions are called to manage the situation by rebalancing any nodes they find to be unbalanced. If you don't have experience with traditional BSTs you should start with the tutorial covering those.

The BST validator is a function whose purpose is to check whether the input BST adheres to the rules of a binary search tree, namely that for every node, the subtree rooted at its left child contains only smaller values, and the subtree rooted at its right child contains only larger values. The code for this lesson is simple once explained but is not that easy to come up with from scratch.

The most popular data structure, the binary search tree is an intuitive way of storing sortable data that provides faster-than-linear search capabilities. Values in a BST are wrapped in a 'node' class used to link the tree together. Given a certain node 'n' with value 'v', all nodes to the right of 'n' contain values larger than 'v', and all nodes to the left contain values smaller than 'v'.

The linked list is a useful data structure providing similar functionality to an array, but in a dynamic package. Albeit, not as useful in Python as in statically typed languages, the linked list is still an interesting project to undertake. Similar to BST, values in a linked list are wrapped in an instance of a 'node' class containing a pointer, allowing the whole list to be linked together by distributed references.

python3_data_structures's People

Contributors

bfaure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python3_data_structures's Issues

Some bugs

Your linked_list.lenght has a bug for list of size 1. Also, your get calls length which does an extra O(n) iteration just to check if index is valid.

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.