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

Algorithmic Thinking 2nd Edition A Problem Based Introduction Daniel Zingaro download

Algorithmic Thinking, 2nd Edition by Daniel Zingaro is a comprehensive guide aimed at enhancing coding skills through problem-based learning. The book covers various algorithmic concepts including hash tables, trees, dynamic programming, and graph algorithms, providing detailed explanations and practical problem-solving techniques. It is designed for readers looking to improve their technical skills for programming interviews or competitive programming.

Uploaded by

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

Algorithmic Thinking 2nd Edition A Problem Based Introduction Daniel Zingaro download

Algorithmic Thinking, 2nd Edition by Daniel Zingaro is a comprehensive guide aimed at enhancing coding skills through problem-based learning. The book covers various algorithmic concepts including hash tables, trees, dynamic programming, and graph algorithms, providing detailed explanations and practical problem-solving techniques. It is designed for readers looking to improve their technical skills for programming interviews or competitive programming.

Uploaded by

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

Algorithmic Thinking 2nd Edition A Problem Based

Introduction Daniel Zingaro download

https://textbookfull.com/product/algorithmic-thinking-2nd-
edition-a-problem-based-introduction-daniel-zingaro/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Algorithmic Thinking. Learn Algorithms...Your Coding


Skills 2ed 2024 Zingaro D.

https://textbookfull.com/product/algorithmic-thinking-learn-
algorithms-your-coding-skills-2ed-2024-zingaro-d/

Problem based Behavioral Science and Psychiatry 2nd


Edition Daniel Alicata

https://textbookfull.com/product/problem-based-behavioral-
science-and-psychiatry-2nd-edition-daniel-alicata/

PHP and Algorithmic Thinking for the Complete Beginner


2nd Edition Learn to Think Like a Programmer Bouras

https://textbookfull.com/product/php-and-algorithmic-thinking-
for-the-complete-beginner-2nd-edition-learn-to-think-like-a-
programmer-bouras/

Creative Thinking And Problem Solving Fabian

https://textbookfull.com/product/creative-thinking-and-problem-
solving-fabian/
Derivative Pricing a Problem Based Primer First Edition
Lo

https://textbookfull.com/product/derivative-pricing-a-problem-
based-primer-first-edition-lo/

Derivative Pricing: A Problem-Based Primer Ambrose Lo

https://textbookfull.com/product/derivative-pricing-a-problem-
based-primer-ambrose-lo/

Algorithmic Democracy: A Critical Perspective Based on


Deliberative Democracy 1st Edition García-Marzá

https://textbookfull.com/product/algorithmic-democracy-a-
critical-perspective-based-on-deliberative-democracy-1st-edition-
garcia-marza/

Thinking Fast and Slow Kahneman Daniel

https://textbookfull.com/product/thinking-fast-and-slow-kahneman-
daniel/

Strategic Thinking in Complex Problem Solving 1st


Edition Arnaud Chevallier

https://textbookfull.com/product/strategic-thinking-in-complex-
problem-solving-1st-edition-arnaud-chevallier/
PRAISE FOR
ALGORITHMIC THINKING, 2ND EDITION
“Algorithmic Thinking will empower you–whether you’re looking to get a
leg up on technical interviews, enter the world of competitive programming,
or just want to sharpen your skills.”

— JOSH LOSPINOSO, PHD, AUTHOR OF


C++ CRASH COURSE

“This book . . . is by far the quickest way to get hands-on experience with
algorithms, and is also a great supplement to more theoretical expositions.”

— RICHARD PENG, ASSOCIATE PROFESSOR AT THE UNIVERSITY OF WATERLOO’S


CHERITON SCHOOL OF COMPUTER SCIENCE

“Algorithmic Thinking provides the theoretical background and detailed


problem explanations required to stay ahead of our human and robotic
competitors.”

— DUNCAN SMITH, SENIOR SOFTWARE ENGINEER AT MICROSOFT

“Not only does Algorithmic Thinking guide readers on how to approach


tackling problems, but Zingaro also helps them understand why these
approaches work.”

— SUSHANT SACHDEVA, PHD, ALGORITHMS PROFESSOR AT THE UNIVERSITY OF


TORONTO

“The step-by-step solution explanations are so detailed, it feels like Zingaro


is directly teaching us, his readers. This second edition is a worthy update to
an already excellent text.”

— DR STEVEN HALIM, SENIOR LECTURER AT NATIONAL UNIVERSITY OF SINGAPORE

“Algorithmic Thinking discusses many interesting problems from


programming contests and presents useful techniques that are not often
included in algorithm textbooks.”
— ANTTI LAAKSONEN, UNIVERSITY OF HELSINKI
ALGORITHMIC THINKING
2ND EDITION

Learn Algorithms to Level up Your Coding Skills

by Daniel Zingaro

San Francisco
ALGORITHMIC THINKING, 2ND EDITION. Copyright © 2024 by
Daniel Zingaro.

All rights reserved. No part of this work may be reproduced or transmitted in


any form or by any means, electronic or mechanical, including
photocopying, recording, or by any information storage or retrieval system,
without the prior written permission of the copyright owner and the
publisher.

First printing

27 26 25 24 23 12345

ISBN-13: 978-1-7185-0322-9 (print)


ISBN-13: 978-1-7185-0323-6 (ebook)

Published by No Starch Press®, Inc.


245 8th Street, San Francisco, CA 94103
phone: +1.415.863.9900
www.nostarch.com; info@nostarch.com

Publisher: William Pollock


Managing Editor: Jill Franklin
Production Manager: Sabrina Plomitallo-González
Production Editor: Sydney Cromwell
Developmental Editor: Alex Freed
Cover Illustrator: Rob Gale
Interior Design: Octopod Studios
Technical Reviewers: Naaz Sibia and Larry Yueli Zhang
Copyeditor: George Hale
Proofreader: Elizabeth Littrell

The Library of Congress has catalogued the first edition as follows:


Name: Zingaro, Daniel, author.
Title: Algorithmic thinking : a problem-based introduction / by Daniel Zingaro.
Includes bibliographical references and index.
Identifiers: LCCN 2020031510 (print) | LCCN 2020031511 (ebook) | ISBN 9781718500808
(paperback) |
ISBN 1718500807 (paperback) | ISBN 9781718500815 (ebook)
Subjects: LCSH: Computer algorithms--Problems, exercises, etc. | Computer programming--Problems,
exercises, etc.
Classification: LCC QA76.9.A43 Z56 2020 (print) | LCC QA76.9.A43 (ebook) | DDC 005.13--dc23
LC record available at https://lccn.loc.gov/2020031510
LC ebook record available at https://lccn.loc.gov/2020031511

For customer service inquiries, please contact info@nostarch.com. For


information on distribution, bulk sales, corporate sales, or translations:
sales@nostarch.com. For permission to translate this work:
rights@nostarch.com. To report counterfeit copies or piracy:
counterfeit@nostarch.com.

No Starch Press and the No Starch Press logo are registered trademarks of
No Starch Press, Inc. Other product and company names mentioned herein
may be the trademarks of their respective owners. Rather than use a
trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the
trademark owner, with no intention of infringement of the trademark.

The information in this book is distributed on an “As Is” basis, without


warranty. While every precaution has been taken in the preparation of this
work, neither the author nor No Starch Press, Inc. shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in it.
To Doyali
About the Author
Dr. Daniel Zingaro is an associate teaching professor of computer science
and award-winning teacher at the University of Toronto. His main area of
research is computer science education, where he studies how students learn
computer science material.
About the Technical Reviewer
Naaz Sibia is an MSc student of computer science at the University of
Toronto with an interest in computer science education research and human
computer interaction (HCI). Her research focuses on identifying challenges
faced by students in computing and utilizing HCI principles to design
interventions that improve their learning experience.
About the First Edition Technical Reviewer
Larry Yueli Zhang is an assistant professor of computer science in the
Department of Electrical Engineering and Computer Science at York
University’s Lassonde School of Engineering. His teaching and research
span a wide range of topics, including introductory programming,
algorithms, data structures, operating systems, computer networks, and
social network analysis, all underscored by a passion for computing
education. Larry holds a PhD in computer science from the University of
Toronto.
BRIEF CONTENTS
Foreword

Acknowledgments

Introduction

Chapter 1: Hash Tables

Chapter 2: Trees and Recursion

Chapter 3: Memoization and Dynamic Programming

Chapter 4: Advanced Memoization and Dynamic Programming

Chapter 5: Graphs and Breadth-First Search

Chapter 6: Shortest Paths in Weighted Graphs

Chapter 7: Binary Search

Chapter 8: Heaps and Segment Trees

Chapter 9: Union-Find

Chapter 10: Randomization

Afterword

Appendix A: Algorithm Runtime

Appendix B: Because I Can’t Resist

Appendix C: Problem Credits

Index
CONTENTS IN DETAIL
FOREWORD

ACKNOWLEDGMENTS

INTRODUCTION

What We’ll Do

New to the Second Edition

Who This Book Is For

Our Programming Language

Why Use C?

Static Keyword

Include Files

Freeing Memory

Topic Selection

Programming Judges

Anatomy of a Problem Description

Starter Problem: Food Lines

The Problem

Solving the Problem

Online Resources

Notes
1

HASH TABLES

Problem 1: Unique Snowflakes

The Problem

Simplifying the Problem

Solving the Core Problem

Solution 1: Pairwise Comparisons

Solution 2: Doing Less Work

Hash Tables

Hash Table Design

Why Use Hash Tables?

Problem 2: Login Mayhem

The Problem

Solution 1: Looking at All Passwords

Solution 2: Using a Hash Table

Problem 3: Spelling Check

The Problem

Thinking About Hash Tables

An Ad Hoc Solution

Summary
Notes

TREES AND RECURSION

Problem 1: Halloween Haul

The Problem

Binary Trees

Solving the Sample Instance

Representing Binary Trees

Collecting All the Candy

A Completely Different Solution

Walking the Minimum Number of Streets

Reading the Input

Why Use Recursion?

Problem 2: Descendant Distance

The Problem

Reading the Input

Number of Descendants from One Node

Number of Descendants from All Nodes

Sorting Nodes

Outputting the Information


The main Function

Summary

Notes

MEMOIZATION AND DYNAMIC PROGRAMMING

Problem 1: Burger Fervor

The Problem

Forming a Plan

Characterizing Optimal Solutions

Solution 1: Recursion

Solution 2: Memoization

Solution 3: Dynamic Programming

Memoization and Dynamic Programming

Step 1: Structure of Optimal Solutions

Step 2: Recursive Solution

Step 3: Memoization

Step 4: Dynamic Programming

Problem 2: Moneygrubbers

The Problem

Characterizing Optimal Solutions


Solution 1: Recursion

The main Function

Solution 2: Memoization

Problem 3: Hockey Rivalry

The Problem

About Rivalries

Characterizing Optimal Solutions

Solution 1: Recursion

Solution 2: Memoization

Solution 3: Dynamic Programming

A Space Optimization

Summary

Notes

ADVANCED MEMOIZATION AND DYNAMIC PROGRAMMING

Problem 1: The Jumper

The Problem

Working Through an Example

Solution 1: Backward Formulation

Solution 2: Forward Formulation


Problem 2: Ways to Build

The Problem

Working Through an Example

Solution 1: Using “Exactly” Subproblems

Solution 2: Adding More Subproblems

Summary

Notes

GRAPHS AND BREADTH-FIRST SEARCH

Problem 1: Knight Chase

The Problem

Moving Optimally

Best Knight Outcome

The Knight Flip-Flop

A Time Optimization

Graphs and BFS

What Are Graphs?

Graphs vs. Trees

BFS on Graphs

Graphs vs. Dynamic Programming


Problem 2: Rope Climb

The Problem

Solution 1: Finding the Moves

Solution 2: A Remodel

Problem 3: Book Translation

The Problem

Reading the Language Names

Building the Graph

The BFS

The Total Cost

Summary

Notes

SHORTEST PATHS IN WEIGHTED GRAPHS

Problem 1: Mice Maze

The Problem

Moving On from BFS

Finding Shortest Paths in Weighted Graphs

Building the Graph

Implementing Dijkstra’s Algorithm


Two Optimizations

Dijkstra’s Algorithm

Runtime of Dijkstra’s Algorithm

Negative-Weight Edges

Problem 2: Grandma Planner

The Problem

Adjacency Matrix

Building the Graph

Working Through a Weird Test Case

Task 1: Shortest Paths

Task 2: Number of Shortest Paths

Summary

Notes

BINARY SEARCH

Problem 1: Feeding Ants

The Problem

A New Flavor of Tree Problem

Reading the Input

Testing Feasibility
Searching for a Solution

Binary Search

Runtime of Binary Search

Determining Feasibility

Searching a Sorted Array

Problem 2: River Jump

The Problem

A Greedy Idea

Testing Feasibility

Searching for a Solution

Reading the Input

Problem 3: Living Quality

The Problem

Sorting Every Rectangle

Using Binary Search

Testing Feasibility

A Quicker Way to Test Feasibility

Problem 4: Cave Doors

The Problem

Solving a Subtask
Using Linear Search

Using Binary Search

Summary

Notes

HEAPS AND SEGMENT TREES

Problem 1: Supermarket Promotion

The Problem

Solution 1: Maximum and Minimum in an Array

Max-Heaps

Min-Heaps

Solution 2: Heaps

Heaps

Two More Applications

Choosing a Data Structure

Problem 2: Building Treaps

The Problem

Recursively Outputting Treaps

Sorting by Label

Solution 1: Recursion
Range Maximum Queries

Segment Trees

Solution 2: Segment Trees

Segment Trees

Problem 3: Two Sum

The Problem

Filling the Segment Tree

Querying the Segment Tree

Updating the Segment Tree

The main Function

Summary

Notes

UNION-FIND

Problem 1: Social Network

The Problem

Modeling as a Graph

Solution 1: BFS

Union-Find

Solution 2: Union-Find
Optimization 1: Union by Size

Optimization 2: Path Compression

Union-Find

Relationships: Three Requirements

Choosing Union-Find

Optimizations

Problem 2: Friends and Enemies

The Problem

Augmenting Union-Find

The main Function

Find and Union

SetFriends and SetEnemies

AreFriends and AreEnemies

Problem 3: Drawer Chore

The Problem

Equivalent Drawers

The main Function

Find and Union

Summary

Notes
10

RANDOMIZATION

Problem 1: Yōkan

The Problem

Randomly Choosing a Piece

Generating Random Numbers

Determining Number of Pieces

Guessing Flavors

How Many Attempts Do We Need?

Filling the Flavor Arrays

The main Function

Randomization

Monte Carlo Algorithms

Las Vegas Algorithms

Deterministic vs. Randomized Algorithms

Problem 2: Caps and Bottles

The Problem

Solving a Subtask

Solution 1: Recursion

Solution 2: Adding Randomization


Quicksort

Implementing Quicksort

Worst-Case and Expected Runtime

Summary

Notes

AFTERWORD

ALGORITHM RUNTIME

The Case for Timing . . . and Something Else

Big O Notation

Linear Time

Constant Time

Another Example

Quadratic Time

Big O in This Book

BECAUSE I CAN’T RESIST

Unique Snowflakes: Implicit Linked Lists

Burger Fervor: Reconstructing a Solution

Knight Chase: Encoding Moves


Dijkstra’s Algorithm: Using a Heap

Mice Maze: Tracing with Heaps

Mice Maze: Implementation with Heaps

Compressing Path Compression

Step 1: No More Ternary If

Step 2: Cleaner Assignment Operator

Step 3: Understand the Recursion

Caps and Bottles: In-Place Sorting

PROBLEM CREDITS

INDEX
FOREWORD
For the novice tennis player, keeping the ball in the court is hard enough
(especially from the backhand side). Only after months of practice, once the
basic rallying skills have been mastered, does the sport and its addictive
nature begin to reveal itself. You add to your repertoire more advanced tools
—a slice backhand, a kick serve, a drop volley. You strategize at a higher
level of abstraction—serve and volley, chip and charge, hug the baseline.
You develop intuition for which tools and strategies will be most effective
against different types of opponents—there’s no silver-bullet approach that
works well against everyone.

Programming is like tennis. For the beginning coder, coaxing the computer
to understand what you want it to do—to execute your solution to a problem
—is hard enough. Graduate from this white-belt level and the true problem-
solving fun begins: How do you come up with the solution in the first place?
While there’s no silver-bullet approach that solves every computational
problem efficiently, there are enduringly useful, advanced tools and
strategies: hash tables, search trees, recursion, memoization, dynamic
programming, graph search, and more. And to the trained eye, many
problems and algorithms offer dead giveaways as to which tools are the right
ones. Does your algorithm perform repeated lookups or minimum
computations? Speed it up with a hash table or min-heap, respectively! Can
you build a solution to your problem from solutions to smaller subproblems?
Use recursion! Do the subproblems overlap? Speed up your algorithm with
memoization!

Be it tennis or programming, you can’t up your game to the next level


without two things: practice and a good coach. To this end, I give you
Algorithmic Thinking: Learn Algorithms to Level up Your Coding Skills and
Daniel Zingaro. This book teaches all the concepts that I’ve mentioned, but
it is no mere laundry list. With Zingaro as a tutor by your side, you’ll learn,
through practice on challenging competition problems, a repeatable process
for figuring out and deftly applying the right algorithmic tools for the job.
And you’ll learn it all from a book that exudes clarity, humor, and just the
right dose of Canadian pride. Happy problem-solving!
Tim Roughgarden
New York, NY
May 2020
ACKNOWLEDGMENTS
What an idyllic experience it was to work with the folks at No Starch Press.
They’re all laser-focused on writing books to help readers learn. I’ve found
my people! Liz Chadwick supported my book from the start (and
unsupported another one—I’m grateful for that!). It is a gift to have worked
with Alex Freed, my developmental editor. She’s patient, kind, and always
eager to help me improve how I write instead of just fixing my mistakes. I
thank all those involved in the production of the second edition of this book,
including my copyeditor, George Hale; production editor, Sydney Cromwell;
and cover designer, Rob Gale.

I thank the University of Toronto for offering me the time and space to write.
I thank Naaz Sibia, my technical reviewer, for her careful review of the
manuscript and for finding the time to help me.

I thank Tim Roughgarden for authoring the book’s foreword. Tim’s books
and videos are examples of the kind of clarity that we need to strive for
when teaching algorithms.

I thank my colleagues Larry Zhang, Jan Vahrenhold, and Mahika Phutane


for their review of draft chapters.

I thank everyone who contributed to the problems that I used in this book
and to competitive programming in general. I thank the DMOJ
administrators for their support of my work. Special thanks to Tudor
Brindus, Radu Pogonariu, and Maxwell Cruickshanks for their help in
improving and adding problems.

I thank my parents for handling everything—everything. All they asked me


to do was learn. I thank Doyali, my partner, for giving some of our time to
this book and for modeling the care it takes to write.

Finally, I thank all of you for reading this book and wanting to learn.
Random documents with unrelated
content Scribd suggests to you:
them. When Owlglass received the money he made his accomplice a
handsome present and went on his way, leaving the purchasers to
try the virtue of the hat.

Owlglass paying the Landlady.


XII.

How Owlglass, by means of a false Confession, cheated the Priest of


Riesenburgh out of his Horse; and how he steals another Priest’s
Snuff-box.

FTER this adventure, Owlglass went to Riesenburgh, where


he lodged with the Priest, whom he knew, having been
there several times before. This priest had a very pretty
maid-servant and a beautiful little horse, which horse the
Duke of Brunswick much wished to have, and offered a considerable
sum of money for its possession; but though the offer was often
repeated the Priest as often refused, for he was scarcely less fond of
his horse than of his maid. Owlglass having heard this, and soon
after hearing that the Duke was in the town, went to him, and said,
“What will your Highness give me if I get you the Priest’s horse?” “If
you can do that,” the Duke answered, “I will give you the coat I now
have on.” Now this coat was of scarlet velvet, ornamented with
pearls.
After this Owlglass pretended to be ill; and taking to his bed,
moaned and sighed so piteously that both the Priest and his maid
were much grieved, and knew not what to do. As he daily seemed to
grow worse, the Priest admonished him to confess, as he had many
sins to answer for. Owlglass answered, that he was anxious to
confess himself, for though he did not feel guilty of any grievous sin,
yet there was one which weighed heavily on his mind, but that he
could not confess to him, and therefore earnestly begged he would
fetch him another priest. When the Priest heard this, there seemed
something strange in it, and his curiosity being strongly excited, he
said, “Dear Owlglass, I should have to go a long way for another
confessor, and if in the meantime you should die unabsolved we
should both have much to answer for, therefore speak, my Son, and
your sin shall be forgiven you.” “Be it so then,” Owlglass said, “but
my sin is not so great, as that I fear offending you, for it concerns
you.” This excited the Priest’s curiosity still more, and he said,
“Speak without hesitation, for I forgive you beforehand; besides, my
anger need not matter, for I dare not divulge your confession.” “Oh,
my dear, good Friend,” Owlglass answered, “I know I shall much
anger and offend you; but since I feel that my end is near I will no
longer delay. I grieve to say that I have kissed your maid more than
once.” The Priest inquired how often that had happened; and being
told five times, he hastily absolved his penitent, and going out called
his servant to him. He accused her of having allowed herself to be
kissed by Owlglass; and though she denied it, he took a stick and
beat her till she was black and blue. Owlglass laughed when he
heard the maid cry, and thought to himself, now the business is
settled; so after remaining in bed one more day and night he got up,
declaring himself to be quite well. After settling with his host for his
board and lodging, he said, “I am now going to Halberstadt to the
Bishop, to denounce you for having divulged the secrets of the
confessional.” The poor Priest, who a moment before had felt quite
happy at the prospect of getting rid of so dangerous a visiter, was
now taken quite aback, when he saw ruin staring him in the face,
and he begged most earnestly that he would not betray him, for it
was in anger. He added that he would give him twenty pounds to
purchase his secrecy, but Owlglass declared that he would not take
fifty. Thereupon the Priest begged his maid to intercede, and
ascertain what Owlglass would accept; and he, after making much
difficulty, said he would not take anything but the Priest’s horse.
Now the Priest would rather have parted with anything than his
horse; but there was no help for it, so he gave him the animal.
Owlglass mounted the horse and rode off to Wolfenbuttel, where he
found the Duke standing on the bridge. As he came near, the Duke
took off his coat, saying, “You see, Owlglass, that as you have
performed your part of the agreement I am ready to perform mine.
There, take the coat I promised you.” Owlglass then had to relate by
what means he obtained the horse from the Priest; at which the
Duke laughed heartily, and besides the coat gave him another horse.
Owlglass’s Confession.

This was not the only priest whom Owlglass tricked, as you shall
hear.

HILST staying in the house where the adventure just told you
occurred, he had become acquainted with a priest who came
there several times, and there were two things he did not fail
to note. Firstly, this Priest was very heavy with sleep every day after
dinner, so that it seemed impossible to him to keep his eyes open;
and secondly, he had a handsome silver snuff-box, which it was his
habit to lay down by his side after taking a pinch from it. He lived in
a town at no great distance from Riesenburgh; and thither Owlglass
went to stay a day or two, the very first opportunity he had.
Choosing the time when he knew the Priest had dined, he went to
the confessional, and by means of a rambling story soon sent his
friend asleep, his snuff-box lying by his side as usual. Owlglass then
put the box in his own pocket, and having waked the Priest, said,
“There is one thing weighs very heavily on my mind, for I have
committed the mean crime of theft, and I must beg of you to accept
the stolen article.”
This the Priest refused to do, advising him to restore it to its real
owner; but Owlglass said, “He refuses to accept it.”
“Under those circumstances keep it, my Son, and I give you full
absolution for having committed the great sin of stealing.”
Owlglass then took the box out of his pocket, saying, “This is the
box, and it was from you I stole it; when urged by remorse I wished
to make restoration, but you refused to accept it, giving me full
absolution.”
After this he left the confessional, and shortly after the town.
Owlglass takes the Priest’s Snuff-box.
XIII.

How a Bootmaker of Brunswick larded Owlglass’s Boots; and how he


was paid for doing so.

HE weather having turned wet, Owlglass thought it well to


have his boots greased, that his feet might be kept dry
during his frequent wanderings; so, going to a bootmaker
of the name of Christopher, in the marketplace of
Brunswick, he gave him the boots, and said, “Let these be well
larded, and have them ready by to-morrow morning.” When he had
left the shop, the bootmaker’s foreman said, “Master, that is
Owlglass, who plays every one some ugly trick or another, so be
very careful what you do, or your turn will have come.” The Master
asked, “What did he tell us to do?” “He told you to lard his boots,
meaning to grease them,” the Foreman answered; “and if I were you
I would act up to the letter of what he said; I should not grease
them, but lard them as one lards meat.” “Well, we will do as he bids
us,” the Master said; and cutting up a piece of bacon into small
strips, he larded the boots as if they were a joint of meat. Owlglass
called the following morning to ask whether the boots were ready;
and the bootmaker, pointing to them as they hung against the wall,
answered, “Yes, there they are.” Owlglass, seeing his boots thus
larded, burst out laughing, and said, “Now you are the sort of
tradesman I like, for you have conscientiously done as I ordered;
how much do I owe you?” “A shilling,” was the answer. As he paid
the money, Owlglass said, “You are much too moderate in your
charges, but I shall not consider that with one miserable shilling I
have paid you. Rest assured, my good Friend, that I will not forget
you.” Then taking his boots he departed, the Master and his
Foreman, looking after him, said, “He is the last man to whom such
a thing should have happened.” And as they talked it over they
chuckled that the trickster, in his turn, had been tricked. Their
merriment, however, was of but short duration, for suddenly
Owlglass’s head and shoulders appeared through the shop window,
the glass flying in all directions about the place. “Pray, my Friend,”
he said, “have the goodness to tell me whether my boots are larded
with sow’s or boar’s bacon.” When the bootmaker had recovered a
little from his surprise, he exclaimed, “Get out of that, you
scoundrel, or you will have my last at your head.” “Do not be angry,
my good Sir,” Owlglass said, “for I only wish to know what bacon
that is with which you have larded my boots; whether it is from a
boar or a sow?”
The bootmaker’s rage increased, and he abused him in the vilest
terms for breaking his window; but Owlglass said coolly, “If you will
not tell me what bacon it is, I must go and ask some one else;” and
drawing back his head and shoulders, contriving at the same time to
break the windows still further, he disappeared. Then the bootmaker
was in a rage with his man, and said, “You gave me advice before;
now advise me what I am to do to make my window whole again.
Pack yourself off at once, and the wages due to you I shall apply to
repairing the mischief your wisdom has caused.”
Owlglass returns with the Boots.
XIV.

How Owlglass hires himself to a Tailor; and how well he executes his
Master’s Orders.

HEN Owlglass found his pockets empty, he hired himself to a


Tailor, who said to him, “Sew neatly, so that no one can see
it, as a good workman should do.” So Owlglass took a
needle and some pieces of cloth, and having crept under
the cutting board, with his face turned to the wall, he laid the work
across his knees and began to sew in the dark. When the Master
beheld this proceeding, he said, “What are you doing there, my
man? That is a most extraordinary way of working.” Owlglass
answered, “Master, you told me to work so that no one could see it,
and as you yourself cannot see what I am doing, so can no one else
see my work, and therefore I am strictly executing your orders.” The
Tailor, who was a quiet, easy man, then said, “That was not what I
meant; come out there, and sew in such a manner that every one
may see how fine your work is.” Thus they went on for a matter of
three days, when, one evening, the Tailor, feeling sleepy, threw a
half-finished rough peasant’s coat over to Owlglass, and said,
“There, make up that wolf for me, and then you can go to bed, as I
am now going to do.” You must know, that that particular sort of
coat was called a wolf. As soon as the Tailor had left the workshop,
Owlglass cut up the coat, and with the pieces first made the head,
and then the body and legs of a wolf. He stood it up by means of
sticks, and then went to bed. When, on the following morning, the
Master went into the shop, he started back in a fright, but Owlglass
just then coming in, he saw how it was, and said, “What have you
been doing here?” Owlglass answered, “I have made a wolf, as you
bid me.” And the Tailor saying that he did not mean a wolf of that
sort, but the peasant’s rough coat, he continued, “My dear Master, I
wish I had understood your meaning, for I would rather have made
a coat than a wolf.” With this the Master was satisfied, and they
went on comfortably together for three or four days more, when one
evening he again felt sleepy; but thinking it too early for his man to
go to bed, he gave him a coat which was finished all but putting in
the sleeves, and said, “Whip the sleeves to this coat, and then you
can go to rest.” Owlglass hung the coat up on a hook, and having
laid the sleeves near it, he lighted two candles, and, with a whip he
then made, whipped the sleeves all through the night. When the
Tailor came in, in the morning, he exclaimed, “What tomfoolery is
this?” “It is no tomfoolery,” Owlglass answered, “I have done as you
told me; but though I have stood here all night whipping the
sleeves, I could not get them to stick to the coat. It would have
been better you had let me go to bed than make me waste my time
in this way.” “It is not my fault,” the Tailor said, “how could I know
you understood it this way, when I meant you to sew the sleeves
into the coat?” Owlglass answered, “I wish you would not say one
thing when you mean another; but now you may do the work, for I
must go to bed.” This the Tailor would no way agree to, so they
quarrelled; and Owlglass leaving him, went his way.
XV.

How Owlglass caused Three Tailors to fall from their Work-board,


and persuaded the People that the Wind had blown them down.

WLGLASS took a lodging at Bamberg, near to the market-


place, where he remained about a fortnight, and next door
to him there lived a tailor who had three workmen. These
men sat on a board, supported by four posts, outside the
window, and they laughed at Owlglass, and threw pieces of rag or
cloth at him whenever he passed. Owlglass bore all in silence, biding
his time to pay them back with interest; and this he determined
should be on a fair day, when the market-place would be full of
people. The night before the day of the fair he had sawed the posts
nearly through which supported the board on which the three tailors
sat, and in the morning they placed the board on them as usual,
seated themselves on it and began their sewing. Now, when the
swineherd blew his horn all the people let out their pigs, and the
tailor’s pigs also came out of his house, and went, as Owlglass well
knew they would, under the board, rubbing themselves against the
posts, which, giving way, the three journeymen tailors were thrown
into the gutter. Owlglass, who had been on the watch, now cried
out, “See how light three tailors are, for a gust of wind has blown
them all at once into the street, as if they were but three feathers!
How easily a tailor can fly!” And this he cried so loud that he could
be heard all over the marketplace. All the people came running to
the spot to see the fun, and mocked and laughed at the poor tailors,
who knew not what to do for very shame. They could not tell how it
was their board fell; but they found out at last, and guessed that it
was Owlglass who had played them that trick. They put up fresh
posts, but did not again venture to make game of Owlglass.
Downfall of the Tailors.
XVI.

How Owlglass tells a Truth to a Smith, to his Wife, his Assistant, and
his Maidservant, for which he gets his Horse shod.

WLGLASS now being in funds, he rode about the country


like a gentleman, and one day came to a small town, where
he saw a very neat woman, with her servant maid,
standing at the door of a smithy, and judged her to be the
smith’s wife. He put up at an inn just opposite, and during the night
pulled the four shoes off his horse. On the following morning he led
his horse to the smithy; and as soon as it was known that it was
Owlglass, the wife and maidservant came out to see what had
brought him there. Owlglass asked the Smith whether he would
shoe his horse; to which he at once agreed, for he was glad of an
opportunity to have some talk with a man of whom he had heard so
much. After much talk on both sides, the Smith said, “If you will tell
me a truth that is really true, I will put one shoe on your horse
without any charge.” To this Owlglass answered, “If you have iron
and coals, and there is plenty of wind in the bellows, the fault will be
yours if the forge does not go on well.” “That is undoubtedly true,”
said the Smith; and he gave him the promised horseshoe. The
assistant, as he was putting on the shoe, said that if he would tell
him a truth that applied to him, he would put another shoe on his
horse. In answer, Owlglass said, “A smith’s assistant must work hard
and not spare himself if he expects to please his master.” “That is
true enough,” was the answer, and the horse had a second shoe.
Then the wife and the servant wanted a truth told them, for which
each promised his horse a shoe. Owlglass whispered his answer in
the ear of each of these. To the mistress he said, “When a servant
apes her mistress’s dress, she would be mistress not only in dress
alone.” The Mistress marked his glances as well as his words, and
said, “That is true enough;” so there was a third shoe for the horse.
And to the maid he said, “When a servant is better looking than her
mistress, she will find it difficult to please her in anything.” The Maid
said, “That I know to be true.” So the horse got its fourth shoe, and
Owlglass rode further on his way.

Owlglass in the Smithy.


XVII.

How Owlglass hired himself to a Merchant as Cook and Coachman.

N the town of Windsheim there lived a rich merchant, who


was walking one day outside the town, when he saw
Owlglass lying on the grass, and stopping, he asked him
what his calling was. Owlglass answered that he was a
cook; whereupon the Merchant said, “You are just the man I want,
that is, if you understand your business; for my wife is not at all
satisfied with her present cook, and we have some of the first
people of the town to dine with us to-morrow, to whom we would
like to give a good dinner.” Owlglass said that he would serve him
faithfully, and that he felt confident of giving satisfaction; so the
merchant engaged him, stipulating that he should also serve as
coachman, and took him home with him at once. As soon as the
merchant’s wife saw Owlglass, she said, “Who is this fellow whom
you have brought home with you, for I do not like the look of him at
all?” Her husband answered, “Never mind his look, my Dear, for he is
a first-rate cook, and we will serve up a dinner to-morrow that shall
be the envy of the whole town.” Early the next morning the
Merchant gave Owlglass full instructions as to the dinner, telling him
what soup, meat, and vegetables to get, and how he liked
everything done. “As for game,” he added, “Professor Guzzle is
particularly fond of roast hare, so we cannot do better than let him
have his favourite puss; but, mind, let it be the finest that can be got
in the whole town.” Owlglass promised that all his instructions
should be strictly attended to; and the Merchant, having business of
importance to attend to, went out in easy confidence in his new
servant. The Merchant got home only just in time to receive his
guests, so that he could not visit the kitchen before dinner, and his
wife was too fine a lady to attend to such matters. However, the
dinner went off very well, and the hare, in particular, was declared to
be the finest that had been seen that year; so that all the company
were in high spirits. At dessert the conversation turned upon cats;
and one of the ladies, addressing the mistress of the house, said she
had heard that she had the finest one in the whole town. The
Merchant’s wife was very proud of her cat, and gave orders that it
should be brought into the room; but it could not be found
anywhere; and now the servants remembered that they had not
seen it since the morning, when one of them saw Owlglass carry it
from the kitchen to an outhouse. Owlglass was now sent for into the
dining-room, before all the guests, and questioned as to what had
become of the cat. Without being in the slightest degree
disconcerted, he said his master had told him that Professor Guzzle
was very fond of roast hare, and that they could not do better than
let him have his favourite puss, and therefore he, Owlglass, was to
be sure and get the very finest in the town; that he had searched
the whole town through, but there were none to compare to the one
in the house, and he was sure his master would not begrudge it his
guests; therefore he had killed and roasted it, and the company had
just eaten it. Horror was depicted upon most of the countenances,
whilst one or two of the guests tried to joke about it; but these the
very first showed symptoms of distress, and one after another of the
company had to leave the room pale as death, and not one
returned. The mistress insisted upon Owlglass being at once sent
away; but the Merchant said, “I want him to drive me and the priest
to Goslar to-morrow, and when we get back I will immediately send
him about his business.” That evening he told Owlglass to get the
carriage ready for the morrow, and to grease it well. As soon as all
had gone to bed, Owlglass took some cart grease and greased the
carriage outside and in, but particularly the seats. Early the next
morning the Merchant ordered the horses to be put to the carriage,
and he and the priest getting in, they drove off in high spirits. They
had not gone far, however, when they found they were gradually
slipping off the seats; and the Priest exclaimed, “What is all this
grease? I held on with my hands to check the jolting, and I am all
grease.” They ordered Owlglass to stop, and they found they were
covered with grease; so that they had to buy a bundle of straw from
a farmer and rub themselves and the carriage well. The Merchant
had now lost all patience, and he cried out to Owlglass, “I find out
now that you are a professed wag, and of the most mischievous
class; but you are in the right road, go on, my good Friend, straight
to the gallows, and there your journey will be at an end.” Owlglass
did as he was bid, for, turning off the road, he drove straight to a
gallows which stood at no great distance, and stopping there began
to take the horses out of the carriage. “What are you doing now, you
rascal?” the Merchant exclaimed. Owlglass answered, “You told me
to go straight to the gallows, and that there my journey would be at
an end, so I naturally thought that we were to stop here.” The
Merchant looked out of the carriage, and seeing that they were
indeed under the gallows, could not help laughing. He said, “You
have delayed us so long on the road with your foolery that I am
afraid we shall not reach Goslar in time for our business, so now, my
good Fellow, I pray you get on as fast as you can. Do not look
behind you, but mind only the road before you.” Owlglass now again
mounted his horse, having first loosened the pin connecting the
front wheels, and set off as fast as the horses could gallop. He had
not gone far when the pin fell out; but, without looking behind him,
he galloped on, carrying off the pole and front wheels, and leaving
the body of the carriage far behind. In vain the Priest and Merchant
shouted to him to stop. On he went; so they had to jump out of the
carriage, and by scrambling through hedges and running across
fields they were, fortunately, able to overtake him. Complaint was
useless; and as they found they could not now reach Goslar in time,
even if their coachman could be trusted to take them there, they
determined upon returning home. The homeward journey was
accomplished without any further accident; and when the Merchant
found himself safe in his own house, he called Owlglass to him and
said, “It is but too evident that all the mischief you have done since
you have been with me has been done purposely. What have you to
say to this?” Owlglass answered, “I do everything strictly to the
letter, as I am told, and if I do wrong, the fault is therefore not mine,
but the fault of those who give the orders. You do not seem
satisfied, so, if you pay me my wages, I would rather look for justice
elsewhere.” The Merchant thinking it better to avoid further, and
perhaps worse, mischief by getting rid of him at once, paid him, and
they parted.

Owlglass’s “skilful” Coachmanship.


XVIII.

How Owlglass cheated a Horse-dealer at Wismar, and afterwards


cheated the Public.

WLGLASS next went to Wismar, a town much frequented by


horse-dealers, and one of these had a habit of pulling the
tail of any horse he thought of buying. This he did from a
notion that, if the hair were firm in the tail, the horse was
strong, and would live long; but if, on the contrary, the hair came
out freely, that the animal would not last long, and he would
therefore have nothing to do with it. Owlglass knew of this habit,
and determined to make some profit of it, so he bought a horse
without a tail, which he got very cheap on that account, and most
artfully he fastened a beautifully flowing tail to the bare stump, by
means of blood and gum. With this horse he went to Wismar, and
asked so high a price that no one would bid for it, until the dealer
came whose habit it was to pull the horses’ tails, and him he asked a
very low price. Before striking a bargain, the Horse-dealer, as usual,
caught hold of the tail, and having formed a favourable opinion of
the animal, gave it, perhaps, a harder tug than customary, when, lo
and behold, the tail remained in his hands, and he measured his
length upon the ground. A shout of laughter arose on all sides; but
that was not enough for Owlglass, who cried out, at the highest
pitch of his voice, “See here! the villain has ruined my horse, for,
beautiful creature that it is, who would have it without a tail?” The
people drew nearer and took part with Owlglass, so that the Horse-
dealer had to pay him ten pounds for the damage done to his horse,
and Owlglass laughed more heartily than any one, though only to
himself.
He rode out of Wismar in high spirits, his trick having succeeded
so well; and as soon as he was outside the town he fastened the tail
on again, intending to sell the horse in the next town. As he rode
along, however, he thought of some other way how to make money
by his horse, before finally parting with it. In pursuance of the plan
he had formed, he stopped at an inn two or three miles distant from
the town, where he intended to put his plan into execution. Here he
remained till it had grown dark, so that he might enter the town
unseen; which having done, he hired a stable, and having put up his
horse, and attended to it himself, he locked the stable-door, putting
the key in his pocket.
The next morning he had it cried through the town that there was
a horse to be shown with its tail where its head should be, stating a
certain hour at which only it could be seen. Before the appointed
time he made all necessary preparations in the stable, when he
again locked the door and then stood before it, waiting the arrival of
the curious. Now, as curiosity was pretty general in the town, there
was a numerous attendance; and when Owlglass judged that all the
company to be expected had arrived, he collected the admission
price from each, and then threw the door open.
There was a general rush, followed by laughter from some, and
indignant complaints from others, as they saw the horse, no
different in itself to other horses, but fastened with its tail to the
manger instead of its head.
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!

textbookfull.com

You might also like