100% found this document useful (1 vote)
138 views

Complete Download Data Structures & Algorithms in Python 1st Edition John Canning PDF All Chapters

Structures

Uploaded by

machtgoddui2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
138 views

Complete Download Data Structures & Algorithms in Python 1st Edition John Canning PDF All Chapters

Structures

Uploaded by

machtgoddui2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Download the Full Version of ebook for Fast Typing at ebookmass.

com

Data Structures & Algorithms in Python 1st Edition


John Canning

https://ebookmass.com/product/data-structures-algorithms-in-
python-1st-edition-john-canning/

OR CLICK BUTTON

DOWNLOAD NOW

Download More ebook Instantly Today - Get Yours Now at ebookmass.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Data Structures & Algorithms in Python 1st Edition John


Canning

https://ebookmass.com/product/data-structures-algorithms-in-
python-1st-edition-john-canning/

ebookmass.com

Data Structures and Algorithms in C++ 2nd Edition

https://ebookmass.com/product/data-structures-and-algorithms-in-c-2nd-
edition/

ebookmass.com

A Textbook of Data Structures and Algorithms, Volume 2:


Mastering Nonlinear Data Structures Vijayalakshmi Pai

https://ebookmass.com/product/a-textbook-of-data-structures-and-
algorithms-volume-2-mastering-nonlinear-data-structures-vijayalakshmi-
pai/
ebookmass.com

Data Structure and Algorithms With Python: The Ultimate


Guide Towards Coding John Thomas

https://ebookmass.com/product/data-structure-and-algorithms-with-
python-the-ultimate-guide-towards-coding-john-thomas/

ebookmass.com
Absolute Beginner's Guide to Algorithms: A Practical
Introduction to Data Structures and Algorithms in
JavaScript Kirupa Chinnathambi
https://ebookmass.com/product/absolute-beginners-guide-to-algorithms-
a-practical-introduction-to-data-structures-and-algorithms-in-
javascript-kirupa-chinnathambi/
ebookmass.com

Fundamentals Of Python: Data Structures 2nd Edition


Kenneth A. Lambert

https://ebookmass.com/product/fundamentals-of-python-data-
structures-2nd-edition-kenneth-a-lambert/

ebookmass.com

Absolute Beginner’s Guide to Algorithms: A Practical


Introduction to Data Structures and Algorithms in
JavaScript (for True Epub) Kirupa Chinnathambi
https://ebookmass.com/product/absolute-beginners-guide-to-algorithms-
a-practical-introduction-to-data-structures-and-algorithms-in-
javascript-for-true-epub-kirupa-chinnathambi/
ebookmass.com

A Textbook of Data Structures and Algorithms, Volume 1 G.


A. Vijayalakshmi Pai

https://ebookmass.com/product/a-textbook-of-data-structures-and-
algorithms-volume-1-g-a-vijayalakshmi-pai/

ebookmass.com

A Textbook of Data Structures and Algorithms, Volume 2 G.


A. Vijayalakshmi Pai

https://ebookmass.com/product/a-textbook-of-data-structures-and-
algorithms-volume-2-g-a-vijayalakshmi-pai/

ebookmass.com
Data Structures & Algorithms in Python
Data Structures & Algorithms in
Python

John Canning
Alan Broder
Robert Lafore

Boston • Columbus • New York • San Francisco • Amsterdam • Cape Town


Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City
São Paulo • Sidney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
Many of the designations used by manufacturers and sellers to distinguish their products are claimed
as trademarks. Where those designations appear in this book, and the publisher was aware of a
trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which
may include electronic versions; custom cover designs; and content particular to your business,
training goals, marketing focus, or branding interests), please contact our corporate sales department
at corpsales@pearsoned.com or (800) 382-3419.
For government sales inquiries, please contact governmentsales@pearsoned.com.
For questions about sales outside the U.S., please contact intlcs@pearson.com.
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2022910068
Copyright © 2023 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited reproduction,
storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or likewise. For information regarding permissions, request forms and the
appropriate contacts within the Pearson Education Global Rights & Permissions Department, please
visit www.pearsoned.com/permissions/.
ISBN-13: 978-0-13-485568-4
ISBN-10: 0-13-485568-X
ScoutAutomatedPrintCode
Editor-in-Chief
Mark Taub
Director, ITP Product Management
Brett Bartow
Acquisitions Editor
Kim Spenceley
Development Editor
Chris Zahn
Managing Editor
Sandra Schroeder
Project Editor
Mandie Frank
Copy Editor
Chuck Hutchinson
Indexer
Proofreader
Editorial Assistant
Cindy Teeters
Designer
Chuti Prasertsith
Compositor
codeMantra
Pearson’s Commitment to
Diversity, Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the diversity
of all learners. We embrace the many dimensions of diversity, including but
not limited to race, ethnicity, gender, socioeconomic status, ability, age,
sexual orientation, and religious or political beliefs.
Education is a powerful force for equity and change in our world. It has the
potential to deliver opportunities that improve lives and enable economic
mobility. As we work with authors to create content for every product and
service, we acknowledge our responsibility to demonstrate inclusivity and
incorporate diverse scholarship so that everyone can achieve their potential
through learning. As the world’s leading learning company, we have a duty
to help drive change and live up to our purpose to help more people create a
better life for themselves and to create a better world.
Our ambition is to purposefully contribute to a world where
• Everyone has an equitable and lifelong opportunity to succeed
through learning
• Our educational products and services are inclusive and represent the
rich diversity of learners
• Our educational content accurately reflects the histories and
experiences of the learners we serve
• Our educational content prompts deeper discussions with learners and
motivates them to expand their own learning (and worldview)
While we work hard to present unbiased content, we want to hear from you
about any concerns or needs with this Pearson product so that we can
investigate and address them.
Please contact us with concerns about any potential bias at
https://www.pearson.com/report-bias.html.
To my mother, who gave me a thirst for knowledge, to my father, who
taught me the joys of engineering, and to June, who made it possible to
pursue both.

John Canning

For my father Sol Broder, a computer science pioneer, who inspired me to


follow in his footsteps.

To my mother Marilyn Broder, for showing me the satisfaction of teaching


others.

To Fran, for making my life complete.

Alan Broder
Contents
1. Overview

2. Arrays

3. Simple Sorting

4. Stacks and Queues

5. Linked Lists

6. Recursion

7. Advanced Sorting

8. Binary Trees

9. 2-3-4 Trees and External Storage

10. AVL and Red-Black Trees

11. Hash Tables

12. Spatial Data Structures

13. Heaps

14. Graphs

15. Weighted Graphs

16. What to Use and Why


Appendix A. Running the Visualizations

Appendix B. Further Reading

Appendix C. Answers to Questions


Table of Contents
1. Overview
What Are Data Structures and Algorithms?
Overview of Data Structures
Overview of Algorithms
Some Definitions
Programming in Python
Object-Oriented Programming
Summary
Questions
Experiments

2. Arrays
The Array Visualization Tool
Using Python Lists to Implement the Array Class
The Ordered Array Visualization Tool
Python Code for an Ordered Array Class
Logarithms
Storing Objects
Big O Notation
Why Not Use Arrays for Everything?
Summary
Questions
Experiments
Programming Projects

3. Simple Sorting
How Would You Do It?
Bubble Sort
Selection Sort
nsertion Sort
Comparing the Simple Sorts
Summary
Questions
Experiments
Programming Projects

4. Stacks and Queues


Different Structures for Different Use Cases
Stacks
Queues
Priority Queues
Parsing Arithmetic Expressions
Summary
Questions
Experiments
Programming Projects

5. Linked Lists
Links
The Linked List Visualization Tool
A Simple Linked List
Linked List Efficiency
Abstract Data Types and Objects
Ordered Lists
Doubly Linked Lists
Circular Lists
terators
Summary
Questions
Experiments
Programming Projects
6. Recursion
Triangular Numbers
Factorials
Anagrams
A Recursive Binary Search
The Tower of Hanoi
Sorting with mergesort
Eliminating Recursion
Some Interesting Recursive Applications
Summary
Questions
Experiments
Programming Projects

7. Advanced Sorting
Shellsort
Partitioning
Quicksort
Degenerates to O(N2) Performance
Radix Sort
Timsort
Summary
Questions
Experiments
Programming Projects

8. Binary Trees
Why Use Binary Trees?
Tree Terminology
An Analogy
How Do Binary Search Trees Work?
Finding a Node
nserting a Node
Traversing the Tree
Finding Minimum and Maximum Key Values
Deleting a Node
The Efficiency of Binary Search Trees
Trees Represented as Arrays
Printing Trees
Duplicate Keys
The BinarySearchTreeTester.py Program
The Huffman Code
Summary
Questions
Experiments
Programming Projects

9. 2-3-4 Trees and External Storage


ntroduction to 2-3-4 Trees
The Tree234 Visualization Tool
Python Code for a 2-3-4 Tree
Efficiency of 2-3-4 Trees
-3 Trees
External Storage
Summary
Questions
Experiments
Programming Projects

10. AVL and Red-Black Trees


Our Approach to the Discussion
Balanced and Unbalanced Trees
AVL Trees
The Efficiency of AVL Trees
Red-Black Trees
Using the Red-Black Tree Visualization Tool
Experimenting with the Visualization Tool
Rotations in Red-Black Trees
nserting a New Node
Deletion
The Efficiency of Red-Black Trees
-3-4 Trees and Red-Black Trees
Red-Black Tree Implementation
Summary
Questions
Experiments
Programming Projects

11. Hash Tables


ntroduction to Hashing
Open Addressing
Separate Chaining
Hash Functions
Hashing Efficiency
Hashing and External Storage
Summary
Questions
Experiments
Programming Projects

12. Spatial Data Structures


Spatial Data
Computing Distances Between Points
Circles and Bounding Boxes
Searching Spatial Data
Lists of Points
Grids
Quadtrees
Theoretical Performance and Optimizations
Practical Considerations
Further Extensions
Summary
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of The blowing
away of Mr. Bushy Tail
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

title: The blowing away of Mr. Bushy Tail

author: Edith B. Davidson

illustrator: Clara E. Atwood

release date: April 29, 2024 [eBook #73490]

language: English

original publication: New York: Duffield and Company, 1910

credits: Aaron Adrignola, Joeri de Ruiter and the Online Distributed


Proofreading Team at https://www.pgdp.net (This file was
produced from images generously made available by The
Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK THE BLOWING


AWAY OF MR. BUSHY TAIL ***
The Blowing away of Mr.
Bushy Tail
THE
BLOWING AWAY OF
MR. BUSHY TAIL

By
EDITH B. DAVIDSON
Pictures by
CLARA E. ATWOOD

NEW YORK
DUFFIELD AND COMPANY
1910
i. and when she got there the cupboard was bare 9
ii. not a creature was stirring, not even a mouse 21
iii. mr. bushy tail goes tobogganing 29
iv. on the wings of the north wind 39
v. at the top of the south pole 51
vi. a quilly acquaintance 63
vii. the snortling of the ring-tailed snorter 75
viii. the gentle south wind 87
And when she got there
The cupboard was bare
It had been an exceptionally cold winter, and Mr. and Mrs. Bushy
Tail had found it very difficult to keep themselves and their two small
children warm.
They had finally moved into Grandmother Chipmunk’s house tree,
which seemed to be more protected from the high winds and the
heavy snow-storms, than their own pretty little nest. The rooms
were rather small, however, and Grandmother Chipmunk snored
most awfully, so that for several nights Baby Bushy Tail could not
sleep.

One cold snowy day, Mrs. Bushy Tail came into the living-room
with a very sober face.
“My dear,” she said to her husband, “the acorns and pine-cones
are nearly gone, and with the exception of a few dried apples and
lettuce leaves, there is nothing left in the cupboard.”
“Ttt, Ttt,” said Grandma Chipmunk, laying down her knitting, and
looking over her spectacles. “Whatever shall we do? Starve?”
Thereupon little Frisky, the oldest boy, set up a fearsome
squeaking, for he liked good things to eat, and did not want to
starve.
Of course that started the baby off, and for a few moments no one
could hear themselves think, much less talk.
Frisky having been sent out of the room, and the baby being
pacified with an acorn-cup to play with, Mr. Bushy Tail spoke:
“There’s only one thing to do;” said he, “go across the frozen
pond, and through the woods, to either my cousin Red Squirrel’s or
else to the Chipmunks’. They will gladly lend me corn or oats enough
to feed us for another month, and by that time let us hope that
Spring will have come.”
“You’ll freeze in the deep snow,” said his wife, “or else you will be
blown to the North Pole by the fierce wind. Then I shall be a widow,
and what will the children do? Oh dear! Oh dear!” and she began to
cry.
Mr. Bushy Tail comforted her as best he could, saying that he
knew the path well, that the trees would protect him from the fierce
wind, and that he was too nimble and quick to sink and freeze in the
deep snow.
At last, he promised not to go the next morning, unless the
weather was fine, so they all went to bed in their soft mossy nests.
Not a Creature was Stirring
Not Even a Mouse
Bright and early the next morning, Mr. Bushy Tail was up, had
washed his little face and paws, and brushed out his pretty soft fur,
of which he was justly a trifle vain. The sun was shining, and
although the air was very cold, he decided it was best for him to
start for his cousin Red Squirrel’s.
His wife bundled him up in a warm sweater and socks, which she
had made him for a Christmas present. Over his shoulder he slung a
bag for the corn, and promising surely to be back in two days time,
he trotted away, after having kissed the entire family three times all
around.
The traveling was much better than he had feared it would be;
and he was fortunate enough to find a bush full of late rose-hips,
from which he made a good dinner.

Just as it was growing dark, he reached his cousin Red Squirrel’s


house tree, and knocked on the door. Receiving no answer, he went
in, for the neighborhood was a very honest one, and nobody locked
their front doors, or their back ones either.

Poor Mr. Bushy Tail went from room to room, but to his sorrow he
found no one, not even a mouse. There were some acorns and dried
apples stowed away in one corner, so he made a passable supper,
but he was worried by the thought, that the next day he must go on
to the Chipmunks’ for the corn, and so might be unable to reach
home the same night, as he had promised his little wife.
However, there was no use in borrowing trouble, so he curled
himself up in a warm corner, covered his back with his broad bushy
tail, and was soon fast asleep, and dreaming that he had carried
home a whole barrel full of food.
Mr. Bushy Tail goes Tobogganing
The next morning as soon as it was light enough to start, Mr.
Bushy Tail set off through the woods to the Chipmunks’ house. He
arrived long before dinner time, and found to his amazement, that
his cousin Red Squirrel with his wife and children, were making the
Chipmunks’ a visit.
They were all delighted to see Mr. Bushy Tail but very sorry to
hear that his winter provisions had given out. However Mr. Chipmunk
had a very large supply, and he at once filled his friend’s bag full of
corn, rolled oats and dried peas. Willingly would he have given him
twice as much, had Mr. Bushy Tail been able to carry it.

The family urged him to stay to dinner, but the sky looked grey
and threatening, and Bushy Tail had a long journey before him, so
he ate a hasty luncheon, thanked Mr. Chipmunk once more for his
kindness, and with his heavy bag over his shoulder, he scurried off
as fast as he could go.
Very soon the snow began to fall, first, in large single flakes, and
then faster and thicker. Scarcely could Mr. Bushy Tail see the way;
and after bumping into first a tree, and then a big bush, he lost his
footing, scrambled about for a minute in the deep snow, and then
sank down, down, DOWN, and landed kerplunk!

For an instant he was half-stunned, then he sat up and looked


about him.
“Thank goodness, my bag is safe,” thought he, as he spied it in a
corner, where it had rolled. “What should I have done if I had lost
that? I could not possibly have walked up that toboggan slide to find
it.”
Then he saw that he was sitting in a bed of soft ashes, and
realized that he had fallen down somebody’s chimney.
“Lucky there wasn’t a fire,” said he, to himself, “or there would
have been toasted squirrel for supper.”
On the Wings of the North Wind
When Mr. Bushy Tail scrambled out of the fire-place, he found
himself in a strange little underground room, from which low
passage ways branched out in every direction.
He ran down one of the passage ways, but finding no one, he
came back and tried another. At the end of this one, in a cosy little
room, he came unexpectedly upon an old acquaintance, Mrs. Mole,
who was taking a comfortable afternoon nap.
She awoke with such a start of surprise at seeing Mr. Bushy Tail,
that she nearly fell out of her rocking-chair.
“I did not hear you knock,” said she.

“I did not knock, I dropped,” said he.


Then he told her of his accident, and apologized most politely, for
falling so unceremoniously down her chimney.
Mrs. Mole assured him that he was a welcome visitor at any time,
and only regretted that her chimney had tripped him up.
She was very sorry that her husband and sons were away on
business, but urged him strongly to stay to supper.
With many thanks Mr. Bushy Tail was obliged to decline her polite
invitation, but he assured her that, considering his hungry family, he
must hurry home with his bag of food as soon as possible, and
begged her to kindly show him the nearest way out of her maze-like
house.
When, after following Mrs. Mole through a number of long,
winding, passages, Mr. Bushy Tail came at last to the surface of the
ground, it was snowing hard, and the dreaded North wind was
blowing half a gale.

He found himself outside the shelter of the woods, on a broad


plain, and he felt that his only safety lay in getting back among the
trees.
He started off at full speed, and had gone some distance, when
suddenly the North wind struck him, and lifted him completely off his
four little paws.
There was no use in struggling, so he lay quite still, and was
whirled away, faster and faster. Miles and miles was he blown, until
finally he fell asleep from sheer exhaustion and fright.
When he awoke it was night, and still the wild wind was carrying
him far, far away.
His precious bag was still on his shoulder, for he had clung to it
even in his terror, but the string had become untied, and most of the
food had been blown away.
He ate a little of the corn, but he was too frightened to be hungry,
and very soon, numb and dazed with the cold, he fell asleep again.
At the Top of the South Pole
All the next day and night, the fierce North wind kept on blowing a
gale, but towards morning of the third day, it seemed to Mr. Bushy
Tail that he was going more slowly, and just as the sun rose, he was
suddenly dropped.

What he rested on he could not tell, but in a few minutes, as it


grew lighter, he looked about him, and saw it was a very high
wooden post. Then he knew he was sitting on top of the South Pole,
where the North wind has to stop blowing, or else it becomes a
South wind.
It was beautifully warm, and poor Bushy Tail stretched himself
most comfortably in the sunshine, and thawed out his half-frozen
little paws.
He felt very much shaken-up and alone in the world, and, with
tears in his eyes, he thought of his little wife and hungry babies, and
wondered if he should ever get home to them.
In the first place, he could not see any possible way of getting
down from his lofty perch. The sides of the Pole were very smooth
and slippery, and the Pole itself was much too high for comfort or
safety, if you tried jumping off.

While he was pondering ways and means of descent, he heard a


high squeaky voice say:
“Try the middle course.”
Peering over the edge of the Pole, Mr. Bushy Tail espied on the
ground, far below, a funny little creature, such as he had never seen
before. It was covered with long blue quills, and moved slowly, and
with much dignity.
“What is the middle course?” asked Mr. Bushy Tail, timidly.

“Why the middle of the Pole, you goose!” replied the squeaky
voice.
Mr. Bushy Tail thought this mode of address not strictly polite,
especially to a stranger, but he said nothing, and looked about him
on top of the Pole.
Sure enough, right in the middle was a little winding staircase,
down which he scrambled into darkness.
A Quilly Acquaintance
The little staircase seemed very dark and pokey to Mr. Bushy Tail,
and he devoutly hoped that nothing would jump out and bite him.
After a number of windings, however, he saw a faint light below
him, and a few moments later, he stepped through a low doorway,
and found himself close beside his quilly acquaintance.

“How do you do, and where did you drop from?” asked Squeaky
Voice.
“I am sure I don’t know where I dropped from,” replied Mr. Bushy
Tail, “but I came a long distance, at a very high rate of speed.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like