This is the code repository for 40 Algorithms Every Programmer Should Know , published by Packt.

Overview

40 Algorithms Every Programmer Should Know

40 Algorithms Every Programmer Should Know

This is the code repository for 40 Algorithms Every Programmer Should Know , published by Packt.

Hone your problem-solving skills by learning different algorithms and their implementation in Python

What is this book about?

Algorithms have always played an important role in both the science and practice of computing. Beyond traditional computing, the ability to use algorithms to solve real-world problems is an important skill that any developer or programmer must have. This book will help you not only to develop the skills to select and use an algorithm to solve real-world problems but also to understand how it works.

This book covers the following exciting features:

  • Explore existing data structures and algorithms found in Python libraries
  • Implement graph algorithms for fraud detection using network analysis
  • Work with machine learning algorithms to cluster similar tweets and process Twitter data in real time
  • Predict the weather using supervised learning algorithms
  • Use neural networks for object detection
  • Create a recommendation engine that suggests relevant movies to subscribers
  • Implement foolproof security using symmetric and asymmetric encryption on Google Cloud Platform (GCP)

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Errata

  • Page 37: The sentences "In the preceding code, the transformer is multiplication by two. So, we are using the map function to multiply each element in the list by two." must be read as "In the preceding code, the transformer is squaring the element. So, we are using the map function to square each element in the list."
  • Page 64: The sentence "The total number of passes is shown in the following diagram:" and the following diagram are included by mistake on this page and must be ignored/omitted.

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

define swap(x, y)
    buffer = x
    x = y
    y = buffer

Following is what you need for this book: This book is for the serious programmer! Whether you are an experienced programmer looking to gain a deeper understanding of the math behind the algorithms or have limited programming or data science knowledge and want to learn more about how you can take advantage of these battle-tested algorithms to improve the way you design and write code, you’ll find this book useful. Experience with Python programming is a must, although knowledge of data science is helpful but not necessary.

With the following software and hardware list you can run all code files present in the book (Chapter 1-14).

Software and Hardware List

Chapter Software required OS required
1-14 Python version 3.7.2 or later Windows/Linux/Mac

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Imran Ahmad is a certified Google Instructor and has been teaching for Google and Learning Tree for the last many years. The topics Imran teaches include Python, Machine Learning, Algorithms, Big Data and Deep Learning. In his PhD, he proposed a new linear programming based algorithm called ATSRA , which can be used to optimally assign resources in a cloud computing environment. For the last 4 years, Imran is working in a high-profile machine learning project at the advanced analytics lab of the Canadian Federal Government. The project is to develop machine learning algorithms that can automate the process of immigration. Imran is currently working on developing algorithms to use GPUs optimally to train complex machine learning models.

Suggestions and Feedback

Click here if you have any feedback or suggestions.

Comments
  • errata: Chapter 2

    errata: Chapter 2

    I am reading chapter two. On page 43, the output of the code below should be different:

    [1]: yellow = {'dandelions', 'fire hydrant', 'leaves'}
    [2]: red = {'fire hydrant', 'blood', 'rose', 'leaves'}
    [3]:  yellow&red
    

    In the book, it is written {'fire hydrant'}, but it should be {'leaves', 'fire hydrant'}.

    opened by khosrogh 3
  • erratum: chapter 4

    erratum: chapter 4

    • Page 83: in the numbered list, at number 2, Mapping' definition, it reads: "Any operation that can run independently on a split is called a map. In the preceding diagram, the map operation coverts ..." I think there is a typo for the word coverts should be converts. Would you please check this?

    • Page 86: in the greedy algorithm defining list number 2, it is talked about Union(S, e). I couldn't find out what is e? A bit of definition would suffice.

    • Page 88: do the code in the middle of the page is complete? I think there are at least two misplaced lines of code and need changes:

    for i in range(len(aTour)))
    and
    for c in range(number_of_cities))
    
    opened by khosrogh 2
  • erratum: chapter 3

    erratum: chapter 3

    • Page 69: in the code for linear search, an indentation is needed in the else statement part. It works well for items that are in the searched list, but for items that aren't in the searched list, it goes to an infinite loop and needs to interrupt the kernel. The code on page 69 is:
    def LinearSearch(list, item):
        index = 0
        found = False
    # Match the value with each data element
        while index < len(list) and found is False:
            if list[index] == item:
                found = True
        else:
            index = index + 1
        return found
    

    The code above should be indented like below:

    def LinearSearch(list, item):
        index = 0
        found = False
    # Match the value with each data element
        while index < len(list) and found is False:
            if list[index] == item:
                found = True
            else:
                index = index + 1
        return found
    

    Codes in here are OK.

    opened by khosrogh 1
  • erratum: chapter 2

    erratum: chapter 2

    • Page 43, the output of the code below should be different:
     [1]: yellow = {'dandelions', 'fire hydrant', 'leaves'}
    
     [2]: red = {'fire hydrant', 'blood', 'rose', 'leaves'}
    
     [3]: yellow&red
    

    In the book, it is written {'fire hydrant'}, but it should be {'leaves', 'fire hydrant'}.

    • Page 54: in the Terminology table, the Sibling nodes' definition reads: "Two nodes in a tree are called siblings if they are at the same level." By this definition, in the page 55 image, nodes E and F are also siblings, which is incorrect. I found out siblings node definition in here and here. I think the definition should be changed in one of these ways:

      • Sibling nodes are nodes on the same hierarchical level under the same parent node.

      • Child nodes with the same parent are sibling nodes.

    opened by khosrogh 1
  • Erratum chapter 8

    Erratum chapter 8

    In chapter 8 - page 235 - first code block This is part where you explain how to define a Keras model using mnist dataset as example.

    In page 235 you define : inputs = tf.keras.Input(shape=(128, 128)) But the mnist dataset is 28x28.

    The correct instruction should be: inputs = tf.keras.Input(shape=(28, 28))

    opened by normanalie 0
  • review chapter 3

    review chapter 3

    • don't call your variables list, list is a build in type and you loose the constructor
    • in bubble sort add a test if done a swap in a pass, if not => data is sorted
    • no need to return the list because a list is a mutable data structure, make a copy of the list (data[:]) if needed to have different sorted list
    • in insertion sort test for (j >= 0) before testing value in list, -1 is a valid list index
    opened by rioj7 0
  • Interpolation search missing condition?

    Interpolation search missing condition?

    I am reading your book and for the interpolation search there is one point I don't understand I compared with that link and found a missing condition which is the case when list[mid] > x . Shouldn't the code be like ?

    def IntPolsearch(list,x ):
       idx0 = 0
       idxn = (len(list) - 1)
       found = False
       while idx0 <= idxn and x >= list[idx0] and x <= list[idxn]:
          # Find the mid point
          mid = idx0 +int(((float(idxn - idx0)/( list[idxn] - list[idx0])) *( x - list[idx0])))
          # Compare the value at mid point with search value
          if list[mid] == x:
             found = True
             return found
          if list[mid] < x:
             idx0 = mid + 1
          if list[mid] > x:
             idxn = mid - 1
    return found
    
    opened by javaskater 1
Owner
Packt
Providing books, eBooks, video tutorials, and articles for IT developers, administrators, and users.
Packt
Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life.

Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life. The algorithm is designed to replicate the natural selection process to carry generation, i.e. survival of the fittest of beings.

Mahdi Hassanzadeh 4 Dec 24, 2022
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Prabhu Pant 1.9k Jan 1, 2023
Repository for Comparison based sorting algorithms in python

Repository for Comparison based sorting algorithms in python. This was implemented for project one submission for ITCS 6114 Data Structures and Algorithms under the guidance of Dr. Dewan at the University of North Carolina at Charlotte, Fall 2021.

Devashri Khagesh Gadgil 1 Dec 20, 2021
Sorting-Algorithms - All information about sorting algorithm you need and you can visualize the code tracer

Sorting-Algorithms - All information about sorting algorithm you need and you can visualize the code tracer

Ahmed Hossam 15 Oct 16, 2022
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Keon 22k Jan 9, 2023
All Algorithms implemented in Python

The Algorithms - Python All algorithms implemented in Python (for education) These implementations are for learning purposes only. Therefore they may

The Algorithms 150.6k Jan 3, 2023
:computer: Data Structures and Algorithms in Python

Algorithms in Python Implementations of a few algorithms and datastructures for fun and profit! Completed Karatsuba Multiplication Basic Sorting Rabin

Prakhar Srivastav 2.9k Jan 1, 2023
Algorithms implemented in Python

Python Algorithms Library Laurent Luce Description The purpose of this library is to help you with common algorithms like: A* path finding. String Mat

Laurent Luce 264 Dec 6, 2022
Algorithms and data structures for educational, demonstrational and experimental purposes.

Algorithms and Data Structures (ands) Introduction This project was created for personal use mostly while studying for an exam (starting in the month

null 50 Dec 6, 2022
A command line tool for memorizing algorithms in Python by typing them.

Algo Drills A command line tool for memorizing algorithms in Python by typing them. In alpha and things will change. How it works Type out an algorith

Travis Jungroth 43 Dec 2, 2022
Python sample codes for robotics algorithms.

PythonRobotics Python codes for robotics algorithm. Table of Contents What is this? Requirements Documentation How to use Localization Extended Kalman

Atsushi Sakai 17.2k Jan 1, 2023
Solving a card game with three search algorithms: BFS, IDS, and A*

Search Algorithms Overview In this project, we want to solve a card game with three search algorithms. In this card game, we have to sort our cards by

Korosh 5 Aug 4, 2022
🧬 Performant Evolutionary Algorithms For Python with Ray support

?? Performant Evolutionary Algorithms For Python with Ray support

Nathan 49 Oct 20, 2022
Nature-inspired algorithms are a very popular tool for solving optimization problems.

Nature-inspired algorithms are a very popular tool for solving optimization problems. Numerous variants of nature-inspired algorithms have been develo

NiaOrg 215 Dec 28, 2022
All algorithms implemented in Python for education

The Algorithms - Python All algorithms implemented in Python - for education Implementations are for learning purposes only. As they may be less effic

null 1 Oct 20, 2021
Implementation of Apriori algorithms via Python

Installing run bellow command for installing all packages pip install -r requirements.txt Data Put csv data under this directory "infrastructure/data

Mahdi Rezaei 0 Jul 25, 2022
A simple python application to visualize sorting algorithms.

Visualize sorting algorithms A simple python application to visualize sorting algorithms. Sort Algorithms Name Function Name O( ) Bubble Sort bubble_s

Duc Tran 3 Apr 1, 2022
Programming Foundations Algorithms With Python

Programming-Foundations-Algorithms Algorithms purpose to solve a specific proplem with a sequential sets of steps for instance : if you need to add di

omar nafea 1 Nov 1, 2021
Planning Algorithms in AI and Robotics. MSc course at Skoltech Data Science program

Planning Algorithms in AI and Robotics course T2 2021-22 The Planning Algorithms in AI and Robotics course at Skoltech, MS in Data Science, during T2,

Mobile Robotics Lab. at Skoltech 6 Sep 21, 2022