Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-vpsfw Total loading time: 0 Render date: 2024-07-25T00:19:16.957Z Has data issue: false hasContentIssue false

4 - Trees

Published online by Cambridge University Press:  10 November 2016

Shmuel Tomi Klein
Affiliation:
Bar-Ilan University, Israel
Get access

Summary

Allowing Multiple Successors

The graphs of the previous chapter were a generalization of the linear lists to structures without order. We now turn to another generalization, still keeping some order, but a more relaxed one. The main motivation may be the fact that a linear list is ultimately not able to support both efficient searches and updates. To get the possibility to perform a binary search, the elements have to be stored sequentially, but then inserts and deletes may require steps. Using a linked list, on the other hand, may reduce the update time to O(1), but at the price of losing the ability to locate the middle elements needed for the binary search, so the time complexity can be.

The problem is that the constraint of every record having only a single successor, as depicted on the left-hand side of Figure 4.1, might be too restrictive. This chapter explores the structures one obtains by allowing each element to be directly followed by possibly more than one other element, as on the righthand side of Figure 4.1. Because of the repeated branching, such structures are known as trees. Formally, the definition of a tree is general enough to encompass a broad family of recursive structures, and we shall deal with several such families in this and the following chapters.

Definition 4.1. A tree is a set of elements called nodes for which:

  1. (i) there is a special element in the set, called the root;

  2. (ii) the other elements can be partitioned into m subsets, each of which is a tree.

Actually, almost any set can then be considered to be a tree. Refer for example to the nodes in the left part of Figure 4.2, 5 might be chosen as the root, and the others can be partitioned into m = 3 subsets, as shown. The convention is to draw such a tree in levels top down, the root being placed on the top in level 0, and the m subtrees following in some order below the root, starting with the next level. This yields the equivalent tree on the right side of Figure 4.2. Accordingly, the vocabulary of genealogic trees has been adopted, for example, 3 is the parent of 4, and 3, 9, and 10 are siblings and the children of 5.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Trees
  • Shmuel Tomi Klein, Bar-Ilan University, Israel
  • Book: Basic Concepts in Data Structures
  • Online publication: 10 November 2016
  • Chapter DOI: https://doi.org/10.1017/CBO9781316676226.005
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Trees
  • Shmuel Tomi Klein, Bar-Ilan University, Israel
  • Book: Basic Concepts in Data Structures
  • Online publication: 10 November 2016
  • Chapter DOI: https://doi.org/10.1017/CBO9781316676226.005
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Trees
  • Shmuel Tomi Klein, Bar-Ilan University, Israel
  • Book: Basic Concepts in Data Structures
  • Online publication: 10 November 2016
  • Chapter DOI: https://doi.org/10.1017/CBO9781316676226.005
Available formats
×