Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills
()
Mercury Learning and Information
MERCURY LEARNING and INFORMATION publishes content in the areas of science and medicine, technology and computing, engineering, and mathematics designed for the professional/reference, trade, library, higher education, career school, and online training markets.
Read more from Mercury Learning And Information
TensorFlow 2 Pocket Primer: A Quick Reference Guide for TensorFlow 2 Developers Rating: 0 out of 5 stars0 ratingsPython for TensorFlow Pocket Primer: A Quick Guide to Python Libraries for TensorFlow Developers Rating: 0 out of 5 stars0 ratingsPython 3 and Data Analytics Pocket Primer: A Quick Guide to NumPy, Pandas, and Data Visualization Rating: 0 out of 5 stars0 ratingsAngular and Deep Learning Pocket Primer: A Comprehensive Guide to AI and Expert Systems for Professionals Rating: 0 out of 5 stars0 ratingsAngular and Machine Learning Pocket Primer: A Comprehensive Guide to Angular and Integrating Machine Learning Rating: 0 out of 5 stars0 ratingsC Programming Pocket Primer: An Essential Guide to C Programming Basics Rating: 0 out of 5 stars0 ratings
Related to Python Data Structures Pocket Primer
Related ebooks
Data Structures and Algorithms with Python Rating: 0 out of 5 stars0 ratingsData Structure in Python: Essential Techniques Rating: 0 out of 5 stars0 ratingsData Structure in Python: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsPython Data Structures Explained: A Practical Guide with Examples Rating: 0 out of 5 stars0 ratingsAdvanced Data Structures in Python: Mastering Complex Computational Patterns Rating: 0 out of 5 stars0 ratingsMastering Algorithm in Python Rating: 0 out of 5 stars0 ratingsBeginner's guide to mastering python Rating: 0 out of 5 stars0 ratingsC Programming Pocket Primer: An Essential Guide to C Programming Basics Rating: 0 out of 5 stars0 ratingsMastering Data Structures and Algorithms with Python: Unlock the Secrets of Expert-Level Skills Rating: 0 out of 5 stars0 ratingsPython Internals for Developers: Practice Python 3.x Fundamentals, Including Data Structures, Asymptotic Analysis, and Data Types Rating: 0 out of 5 stars0 ratingsMastering Python Programming: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsMastering Data Structures and Algorithms in Python & Java Rating: 0 out of 5 stars0 ratingsAdvanced Algorithm Mastery: Elevating Python Techniques for Professionals Rating: 0 out of 5 stars0 ratingsC Programming For Dummies Rating: 0 out of 5 stars0 ratingsPython Data Structures and Algorithms Rating: 5 out of 5 stars5/5Mastering Data Structures: Core Concepts and Principles Rating: 0 out of 5 stars0 ratingsData Manipulation with Python Step by Step: A Practical Guide with Examples Rating: 0 out of 5 stars0 ratingsMastering Algorithms and Data Structures Rating: 0 out of 5 stars0 ratingsAlgorithms and Data Structures: An Easy Guide to Programming Skills Rating: 0 out of 5 stars0 ratingsTeach Yourself VISUALLY Python Rating: 0 out of 5 stars0 ratingsPython Essentials Rating: 5 out of 5 stars5/5SQL Mastery: The Masterclass Guide to Become an SQL ExpertMaster The SQL Programming Language In This Ultimate Guide Today! Rating: 0 out of 5 stars0 ratingsBasic Core Python Programming: A Complete Reference Book to Master Python with Practical Applications (English Edition) Rating: 0 out of 5 stars0 ratingsPython Algorithms Step by Step: A Practical Guide with Examples Rating: 0 out of 5 stars0 ratingsIntroduction to Python Programming: Do your first steps into programming with python Rating: 0 out of 5 stars0 ratingsBasics of Python Programming: Learn Python in 30 days (Beginners approach) - 2nd Edition Rating: 0 out of 5 stars0 ratings
Trending on #Booktok
Powerless Rating: 4 out of 5 stars4/5The Assassin and the Pirate Lord: A Throne of Glass Novella Rating: 4 out of 5 stars4/5Icebreaker: A Novel Rating: 4 out of 5 stars4/5A Court of Mist and Fury Rating: 5 out of 5 stars5/5It Ends with Us: A Novel Rating: 4 out of 5 stars4/5A Little Life: A Novel Rating: 4 out of 5 stars4/5Pride and Prejudice Rating: 4 out of 5 stars4/5The Secret History: A Read with Jenna Pick: A Novel Rating: 4 out of 5 stars4/5If We Were Villains: A Novel Rating: 4 out of 5 stars4/5Once Upon a Broken Heart Rating: 4 out of 5 stars4/5The Summer I Turned Pretty Rating: 4 out of 5 stars4/5Funny Story Rating: 4 out of 5 stars4/5Crime and Punishment Rating: 4 out of 5 stars4/5Normal People: A Novel Rating: 4 out of 5 stars4/5Happy Place Rating: 4 out of 5 stars4/5The Love Hypothesis Rating: 4 out of 5 stars4/5Seven Stones to Stand or Fall: A Collection of Outlander Fiction Rating: 4 out of 5 stars4/5Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones Rating: 4 out of 5 stars4/5Fire & Blood: 300 Years Before A Game of Thrones Rating: 4 out of 5 stars4/5Beauty and the Beast Rating: 4 out of 5 stars4/5Divine Rivals: A Novel Rating: 4 out of 5 stars4/5Better Than the Movies Rating: 4 out of 5 stars4/5The 48 Laws of Power Rating: 4 out of 5 stars4/5The Little Prince: New Translation Version Rating: 5 out of 5 stars5/5Rich Dad Poor Dad Rating: 4 out of 5 stars4/5Dune Rating: 4 out of 5 stars4/5The Lord Of The Rings: One Volume Rating: 5 out of 5 stars5/5Finnegans Wake Rating: 4 out of 5 stars4/5Beach Read Rating: 4 out of 5 stars4/5Milk and Honey: 10th Anniversary Collector's Edition Rating: 4 out of 5 stars4/5
Reviews for Python Data Structures Pocket Primer
0 ratings0 reviews
Book preview
Python Data Structures Pocket Primer - Mercury Learning and Information
PREFACE
WHAT IS THE PRIMARY VALUE PROPOSITION FOR THIS BOOK?
This book contains a fast-paced introduction to as much relevant information about data structures that within reason can possibly be included in a book of this size. In addition, this book has a task-oriented approach, so you will see code samples that use data structures to solve various tasks.
Chapter 1 starts with an introduction to Python for beginners, recursion is discussed in Chapter 2, strings and arrays are covered in Chapter 3, search and sort algorithms are discussed in Chapter 4, various types of linked lists and explained in Chapter 5 and Chapter 6, and then queues and stacks are covered in Chapter 7.
Please keep in mind that a full treatment of all the topics in this book could easily triple the length of this book (and besides, such books are already available).
THE TARGET AUDIENCE
This book is intended primarily for people who have a limited background in data structures. This book is also intended to reach an international audience of readers with highly diverse backgrounds. While many readers know how to read English, their native spoken language is not English (which could be their second, third, or even fourth language). Consequently, this book uses standard English rather than colloquial expressions in order to maximize clarity.
WHAT WILL I LEARN FROM THIS BOOK?
The introductory section of the preface contains a brief outline of the topics in each of the chapters of this book. As the title suggests, you will acquire a basic level of knowledge about a variety of data structures.
Incidentally, you will discover that many code samples contain commented out
code snippets, which are usually Python print() statements. Feel free to uncomment
those code snippets, which will enable you to see the various execution paths in the code. In essence, you will see the debugging process that was used during the development of the code samples.
WHY ARE THE CODE SAMPLES PRIMARILY IN PYTHON?
Most of the code samples are short (usually less than one page and sometimes less than half a page), and if necessary, you can easily and quickly copy/paste the code into a new Jupyter notebook. Moreover, the code samples execute quickly, so you won’t need to avail yourself of the free GPU that is provided in Google Colaboratory.
DO I NEED TO LEARN THE THEORY PORTIONS OF THIS BOOK?
Alas, an understanding of the theoretical underpinnings of data structures does not translate into the ability to solve tasks involving data structures: it’s necessary knowledge (but not necessarily sufficient). Strive for an understanding of concepts and minimize the amount of memorization of code samples. For example, you can determine whether or not a positive integer n is a power of 2 with a single line of code:
(n > 0) and (n & (n-1)) == 0
Although the preceding code snippet might seem nonintuitive, you can convince yourself that this is true by setting n=8 and then observe the following:
n: 1000
n-1: 0111
The key point is this: the binary representation of a power of 2 has a single 1 in the left-most position, and zeroes to the right of the digit 1 (for n>=2), whereas the number n-1 contains a 0 in the left-most position, and all 1s to the right of the digit 0. Therefore, the logical and of n and (n-1) is clearly 0.
Now that you understand the key idea, there is no need to memorize anything, and you can write the solution in any programming language for which you have a very modest level of experience.
The theoretical aspects will help you improve your conceptual understanding of the differences and similarities (if any) among various types of data structures. However, you will gain confidence and also a better understanding of data structures by writing code because knowledge is often gained through repetition of tasks that provide reinforcement of concepts.
GETTING THE MOST FROM THIS BOOK
Some programmers learn well from prose, others learn well from sample code (and lots of it), which means that there’s no single style that can be used for everyone.
Moreover, some programmers want to run the code first, see what it does, and then return to the code to delve into the details (and others use the opposite approach).
Consequently, there are various types of code samples in this book: some are short, some are long, and other code samples build
from earlier code samples.
WHAT DO I NEED TO KNOW FOR THIS BOOK?
Current knowledge of Python 3.x is useful because all the code samples are in Python. Knowledge of data structures will enable you to progress through the related chapters more quickly. The less technical knowledge you have, the more diligence will be required in order to understand the various topics that are covered.
If you want to be sure that you can grasp the material in this book, glance through some of the code samples to get an idea of how much is familiar to you and how much is new for you.
DOES THIS BOOK CONTAIN PRODUCTION-LEVEL CODE SAMPLES?
The primary purpose of the code samples in this book is to show you solutions to tasks that involve data structures. Therefore, clarity has higher priority than writing more compact or highly optimized code, For example, inspect the loops in the Python code sample to see if they can be made more efficient. Suggestion: treat such code samples as opportunities for you to optimize the code samples in this book.
If you decide to use any of the code in this book in a production website, you ought to subject that code to the same rigorous analysis as the other parts of your code base.
WHAT ARE THE NONTECHNICAL PREREQUISITES FOR THIS BOOK?
Although the answer to this question is difficult to quantify, it’s especially important to have a strong desire to learn about data analytics, along with the motivation and discipline to read and understand the code samples.
HOW DO I SET UP A COMMAND SHELL?
If you are a Mac user, there are three ways to set up a command shell. The first method is to use Finder to navigate to Applications > Utilities and then double click on the Utilities application. Next, if you already have a command shell available, you can launch a new command shell by typing the following command:
open /Applications/Utilities/Terminal.app
A second method for Mac users is to open a new command shell on a MacBook from a command shell that is already visible simply by clicking command+n in that command shell, and your Mac will launch another command shell.
If you are a PC user, you can install Cygwin (open source https://cygwin.com/) that simulates bash commands, or use another toolkit such as MKS (a commercial product). Please read the online documentation that describes the download and installation process. Note that custom aliases are not automatically set if they are defined in a file other than the main start-up file (such as .bash_login).
COMPANION FILES
All the code samples in this book may be obtained by writing to the publisher at [email protected].
WHAT ARE THE NEXT STEPS
AFTER FINISHING THIS BOOK?
The answer to this question varies widely, mainly because the answer depends heavily on your objectives. If you are interested primarily in learning more about data structures, then this book is a stepping stone
to other books that contain more complex data structures as well as code samples for the tasks that are not covered in this book (such as deleting a node from a tree or a doubly linked list).
If you are primarily interested in machine learning, there are some subfields of machine learning, such as deep learning and reinforcement learning (and deep reinforcement learning) that might appeal to you. Fortunately, there are many resources available, and you can perform an Internet search for those resources. One other point: the aspects of machine learning for you to learn depend on who you are—the needs of a machine learning engineer, data scientist, manager, student, or software developer all differ from one