Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PHP 7 Data Structures and Algorithms

You're reading from   PHP 7 Data Structures and Algorithms Implement linked lists, stacks, and queues using PHP

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781786463890
Length 340 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Mizanur Rahman Mizanur Rahman
Author Profile Icon Mizanur Rahman
Mizanur Rahman
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Introduction to Data Structures and Algorithms FREE CHAPTER 2. Understanding PHP Arrays 3. Using Linked Lists 4. Constructing Stacks and Queues 5. Applying Recursive Algorithms - Recursion 6. Understanding and Implementing Trees 7. Using Sorting Algorithms 8. Exploring Search Options 9. Putting Graphs into Action 10. Understanding and Using Heaps 11. Solving Problems with Advanced Techniques 12. PHP Built-In Support for Data Structures and Algorithms 13. Functional Data Structures with PHP

Understanding recursion

Recursion is a way to solve larger problems by dividing them into smaller problems. In other words, recursion is breaking the big problem into smaller similar problems to solve them and get the actual results. Often, recursion is termed as a function calling itself. It might sound strange, but the fact is the function must call itself when it is in recursion. What does this look like? Let's look at an example,

In mathematics, the term "factorial" is very popular. A factorial of a number N is defined as multiplication of all positive integers less than and equal to N. It is always denoted with ! (an exclamation mark). So, a factorial of 5 can be written as follows:

5! = 5 X 4 X 3 X 2 X 1

Similarly, we can write the following factorials of the given number::

4! = 4 X 3 X 2 X 1

3! = 3 X 2 X 1

2! = 2 X 1

1! = 1

If we look closely at our...

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 $19.99/month. Cancel anytime