GithubHelp home page GithubHelp logo

juandarr / algorithms-data-structures Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 16.52 MB

Exploration of algorithms and data structures in Python 3

Python 83.60% Jupyter Notebook 12.90% HTML 3.50%

algorithms-data-structures's Introduction

Algorithms and data structures

In this repository I explore algorithms and data structures in different programming languages. My goal is to create a summary of major findings and implementations. Some of the implementations here are a re-exploration of topics and already known about in the past, but will include new lessons learned about best practices and programming techniques.

Sorting algorithms

Bubble sort

Insertion sort

Mergesort

Quicksort

More

Here is a visualization of different sorting algorithms with its speed in different conditions.

Graphs

Graphs are data structures defined by nodes (also called vertices) and edges. Edges connect two nodes to each other. Graphs are the canonical representation of networks and can be used for a wide variety of purposes such as finding the shortest/largest path, find the connected regions in a network, or getting instructions about how to move from point A to point B. There are two fundamental algorithms used to traverse a graph (search): one es Breath First Search (a.k.a. BFS) which goes layer by layer. The second one is Depth First Search (a.k.a. DFS), which traverses the networy by recursively going to the deepest layer and coming back. The generic graph search algorithm consists of a two step goal:

  1. Find everything findable from a given start vertex
  2. Don't explore anything twice Generally with time complexity O(m+n), m the number of vertices and n the number of edges explored. And these are the fundalmental ideas followed in the BFS and DFS, the difference being how the graph is traversed every time a new node (vertex) is explored.

BFS (Breath First Search)

  • Explore nodes in "layers".
  • The graph is traversed by FIFO sequence (First In First Out): every vortex in one layer is explored before to the next one.
  • The queue is the natural data structure to follow such sequence. A queue can be implemented using doubled linked listed for example. An array is also an option.
  • Running time:
    • O(m+n), linear time.
  • Use cases:
    • Can compute shortest paths.
    • Can find connected components of undirected graphs.

DFS (Depth Fisrt Search)

  • Explore layer after layer (depth) aggressively, only backtrack when necessary.
  • The graph is traverse in a LIFO sequence (Last In First Out): vertices are explored in depth, as opposed to depth (BFS).
  • The stack is the natural data structure to follow such sequence. A stack can be easily represented by an array.
  • Running time:
    • O(m+n), linear time.
  • Use cases:
    • Compute a topological ordering of a directed acyclic graph.
    • Finds strongly connected components of directed graphs.

Misc

HackerRank

I am solving problems from HackerRank. Right now mostly focused on the interview ooriented challenges. Will be documenting more aspects of the these challenges in the future.

Search

Several problems solved involving binary search and other search techniques. Sometimes, they require hash maps and sets to make the algorithm more efficient.

Hangman

Card deck

algorithms-data-structures's People

Contributors

juandarr avatar

Watchers

 avatar  avatar

Forkers

codealigned

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.