Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Expert C++ - Second Edition

You're reading from  Expert C++ - Second Edition

Product type Book
Published in Aug 2023
Publisher Packt
ISBN-13 9781804617830
Pages 604 pages
Edition 2nd Edition
Languages
Authors (5):
Marcelo Guerra Hahn Marcelo Guerra Hahn
Profile icon Marcelo Guerra Hahn
Araks Tigranyan Araks Tigranyan
Profile icon Araks Tigranyan
John Asatryan John Asatryan
Profile icon John Asatryan
Vardan Grigoryan Vardan Grigoryan
Profile icon Vardan Grigoryan
Shunguang Wu Shunguang Wu
Profile icon Shunguang Wu
View More author details

Table of Contents (24) Chapters

Preface Part 1:Under the Hood of C++ Programming
Chapter 1: Building C++ Applications Chapter 2: Beyond Object-Oriented Programming Chapter 3: Understanding and Designing Templates Chapter 4: Template Meta Programming Chapter 5: Memory Management and Smart Pointers Part 2: Designing Robust and Efficient Applications
Chapter 6: Digging into Data Structures and Algorithms in STL Chapter 7: Advanced Data Structures Chapter 8: Functional Programming Chapter 9: Concurrency and Multithreading Chapter 10: Designing Concurrent Data Structures Chapter 11: Designing World-Ready Applications Chapter 12: Incorporating Design Patterns in C++ Applications Chapter 13: Networking and Security Chapter 14: Debugging and Testing Chapter 15: Large-Scale Application Design Part 3:C++ in the AI World
Chapter 16: Understanding and Using C++ in Machine Learning Tasks Chapter 17: Using C++ in Data Science Chapter 18: Designing and Implementing a Data Analysis Framework Index Other Books You May Enjoy

Searching

Let us start with the find function. The idea behind the strategy of finding an element lies in looking at a root node and then, based on the results, going to the left subtree or the right subtree. As you can see in the preceding code, we also have Boolean functions, which will help us implement the find function based on the type of node we are dealing with. A node of a 2-3 tree can be a leaf, a 2-node, or a 3-node and as those nodes have a different number of keys, the implementations of a search function should slightly differ for each type of node.

Before the implementation of the find function, let us first look at a simple illustrative example of looking for an element with a value of 554 in a 2-3 tree:

Figure 7.5 – A 2-3 tree example

Figure 7.5 – A 2-3 tree example

First, we look at the root node. We see that its value is 17 and it is not equal to 554. So, we continue looking for the number:

Figure 7.6 – First step to find a value inside a 2-3 tree

Figure 7.6 – First step to find...

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