362 369
363 370
364 371
365 372
366 373
367 374
368 375
369 376
370 377
371 378
372 379
373 380
374 381
375 382
376 383
377 384
378 385
379 386
380 387
381 388
382 389
383 390
384 391
385 392
386 393
387 394
388 395
389 396
390 397
391 398
392 399
393 401
394 402
395 403
396 404
397 405
398 406
399 407
400 408
401 409
402 410
403 411
404 412
405 413
406 414
407 415
408 416
409 417
410 418
411 419
412 420
413 421
414 422
415 423
416 424
417 425
418 426
419 427
420 428
421 429
422 431
423 432
424 433
Introduction
You need to learn about algorithms for school or work. Yet, all the books you’ve tried on the subject end up being more along the lines of really good sleep-inducing aids rather than texts to teach you something. Assuming that you can get past the arcane symbols obviously written by a demented two-year-old with a penchant for squiggles, you end up having no idea of why you’d even want to know anything about them. Most math texts are boring! However, Algorithms For Dummies, 2nd Edition is different. The first thing you’ll note is that this book has a definite lack of odd symbols (especially of the squiggly sort) floating about. Yes, you see a few (it is a math book, after all), but what you find instead are clear instructions for using algorithms that actually have names and a history behind them and that perform useful tasks. You’ll encounter simple coding techniques to perform amazing tasks that will intrigue your friends. You can certainly make them jealous as you perform feats of math that they can’t begin to understand. You get all this without having to strain your brain, even a little, and you won’t even fall asleep (well, unless you really want to do so). New in this edition of the book are more details about how algorithms work, and you even get to create your own basic math package so that you know how to do it for that next job interview.
About This Book
Algorithms For Dummies, 2nd Edition is the math book that you wanted in college but didn’t get. You discover, for example, that algorithms aren’t new. After all, the Babylonians used algorithms to perform simple tasks as early as 1,600 BC. If the Babylonians could figure this stuff out, certainly you can, too! This book actually has three things that you won’t find in most math books:
Algorithms that have actual names and a historical basis so that you can remember the algorithm and know why someone took time to create it
Simple explanations of how the algorithm performs awesome feats of data manipulation, data analysis, or probability prediction
Code that shows how to use the algorithm without actually dealing with arcane symbols that no one without a math degree can understand
Part of the emphasis of this book is on using the right tools. This book uses Python to perform various tasks. Python has special features that make working with algorithms significantly easier. For example, Python provides access to a huge array of packages that let you do just about anything you can imagine, and more than a few that you can’t. However, unlike many texts that use Python, this one doesn’t bury you in packages. We use a select group of packages that provide great flexibility with a lot of functionality but don’t require you to pay anything. You can go through this entire book without forking over a cent of your hard-earned money.
You also discover some interesting techniques in this book. The most important is that you don’t just see the algorithms used to perform tasks; you also get an explanation of how the algorithms work. Unlike many other books, Algorithms For Dummies, 2nd Edition enables you to fully understand what you’re doing, but without requiring you to have a PhD in math. Every one of the examples shows the expected output and tells you why that output is important. You aren’t left with the feeling that something is missing.
Of course, you might still be worried about the whole programming environment issue, and this book doesn’t leave you in the dark there, either. This book relies on Google Colab to provide a programming environment (although you can use Jupyter Notebook quite easily, too). Because you access Colab through a browser, you can program anywhere and at any time that you have access to a browser, even on your smartphone while at the dentist’s office or possibly while standing on your head watching reruns of your favorite show.
To help you absorb the concepts, this book uses the following conventions:
Text that you’re meant to type just as it appears in the book is in bold. The exception is when you’re working through a step list: Because each step is bold, the text to type is not bold.
Words that we want you to type in that are also in italics are used as placeholders, which means that you need to replace them with something that works for you. For example, if you see “Type Your Name and press Enter,” you need to replace Your Name with your actual name.
We also use italics