Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning JavaScript Data  Structures and Algorithms

You're reading from   Learning JavaScript Data Structures and Algorithms Write complex and powerful JavaScript code using the latest ECMAScript

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788623872
Length 426 pages
Edition 3rd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Loiane Avancini Loiane Avancini
Author Profile Icon Loiane Avancini
Loiane Avancini
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. JavaScript – A Quick Overview FREE CHAPTER 2. ECMAScript and TypeScript Overview 3. Arrays 4. Stacks 5. Queues and Deques 6. Linked Lists 7. Sets 8. Dictionaries and Hashes 9. Recursion 10. Trees 11. Binary Heap and Heap Sort 12. Graphs 13. Sorting and Searching Algorithms 14. Algorithm Designs and Techniques 15. Algorithm Complexity 1. Other Books You May Enjoy Index

Divide and conquer


In Chapter 13, Sorting and Searching Algorithms, we learned how to develop the merge and quick sort algorithms. What both sorting solutions have in common is that they are divide and conquer algorithms. Divide and conquer is one of the approaches to algorithm design. It breaks the problem into small subproblems that are similar to the original problem, it solves the subproblems recursively, and combines the solutions of the subproblems to solve the original problem.

The divide and conquer algorithm can be split into three parts:

  1. Divide the original problem into smaller subproblems (smaller instances of the original problem).
  2. Conquer the smaller subproblems by solving them with recursive algorithms that return the solution for the subproblems. The base case of the recursive algorithm solves and returns the solution for the smallest subproblem.
  3. Combine the solutions of the subproblems into the solution for the original problem.

As we have already covered the two most famous divide...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Banner background image