Skip to content
All library documents

When to Use Trees Instead of Queues or Linked Lists

Article MQL5 articles

Summary

This programming tutorial compares queues, linked lists, and trees, emphasizing how their structures affect insertion, removal, and search. Queues suit ordered processing but make arbitrary middle changes awkward. Linked lists allow efficient insertion and removal at different positions, at the cost of extra memory and potentially slow searches through many elements. Trees are introduced as a way to represent branching relationships and improve search when their organization supports it.

The article explains nodes, branches, and roots, and uses diagrams and a dictionary-search example to motivate branching structures. It then begins implementing a general tree in MQL5 based on earlier linked-list code and discusses traversal behavior. The excerpt is introductory: it does not compare specific balanced-tree variants or provide performance benchmarks, and it cautions that different tree types suit different tasks. The material is general programming guidance rather than a trading method, but may help readers building data-processing or analysis software.

Key ideas

  • Queues are convenient for sequential processing but are inefficient for arbitrary changes in the middle.
  • Linked lists support insertion and removal at different positions but require additional memory and can be slow to search.
  • Trees represent branching relationships and can support more efficient searching when organized appropriately.
  • A tree’s root, nodes, and branches describe its structure and influence traversal and search.
  • The article presents a general introductory implementation and does not benchmark or cover specialized tree variants.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.