Discover millions of audiobooks, ebooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills
Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills
Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills
Ebook514 pages3 hours

Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills

Rating: 0 out of 5 stars

()

Read preview
LanguageEnglish
PublisherPackt Publishing
Release dateAug 12, 2024
ISBN9781836647164
Python Data Structures Pocket Primer: A concise guide to Python data structures to enhance your skills
Author

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

Related to Python Data Structures Pocket Primer

Related ebooks

Trending on #Booktok

Reviews for Python Data Structures Pocket Primer

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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

    Enjoying the preview?
    Page 1 of 1