Tree (data structure)

From WikiMD's Wellness Encyclopedia

Error creating thumbnail:
Tree_(computer_science)
Error creating thumbnail:
Linux_Distribution_Timeline_Dec._2020

Tree (data structure)

A tree is a widely used abstract data type (ADT) that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes. A tree data structure is a collection of nodes connected by edges, where each node contains a value or data and may have a reference to other nodes, known as its children.

Structure[edit | edit source]

A tree consists of nodes and edges. The topmost node is called the root, and each node (except the root) is connected by a single edge to exactly one other node, which is its parent. A node that has no children is called a leaf node. Nodes that have the same parent are called siblings.

Types of Trees[edit | edit source]

There are several types of trees, each with its own properties and applications:

  • Binary tree: A tree in which each node has at most two children, referred to as the left child and the right child.
  • Binary search tree (BST): A binary tree in which the left subtree of a node contains only nodes with values less than the node's value, and the right subtree only nodes with values greater than the node's value.
  • AVL tree: A self-balancing binary search tree where the difference in heights between the left and right subtrees cannot be more than one for all nodes.
  • Red-black tree: A self-balancing binary search tree where each node contains an extra bit for denoting the color of the node, either red or black.
  • B-tree: A self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time.
  • Trie: A tree-like data structure that stores a dynamic set of strings, where the keys are usually strings.

Operations[edit | edit source]

Common operations on a tree data structure include:

  • Insertion: Adding a node to the tree.
  • Deletion: Removing a node from the tree.
  • Traversal: Visiting all the nodes in a specific order. Common traversal methods include pre-order traversal, in-order traversal, and post-order traversal.
  • Searching: Finding a node in the tree that contains a specific value.

Applications[edit | edit source]

Trees are used in various applications, including:

Related Pages[edit | edit source]

See Also[edit | edit source]

Template:Data-structures-stub

WikiMD
Navigation: Wellness - Encyclopedia - Health topics - Disease Index‏‎ - Drugs - World Directory - Gray's Anatomy - Keto diet - Recipes

Search WikiMD

Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD

WikiMD's Wellness Encyclopedia

Let Food Be Thy Medicine
Medicine Thy Food - Hippocrates

Medical Disclaimer: WikiMD is not a substitute for professional medical advice. The information on WikiMD is provided as an information resource only, may be incorrect, outdated or misleading, and is not to be used or relied on for any diagnostic or treatment purposes. Please consult your health care provider before making any healthcare decisions or for guidance about a specific medical condition. WikiMD expressly disclaims responsibility, and shall have no liability, for any damages, loss, injury, or liability whatsoever suffered as a result of your reliance on the information contained in this site. By visiting this site you agree to the foregoing terms and conditions, which may from time to time be changed or supplemented by WikiMD. If you do not agree to the foregoing terms and conditions, you should not enter or use this site. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.

Contributors: Prab R. Tumpati, MD