README.rst
1.. zephyr:code-sample:: red-black-tree
2 :name: Red-Black Tree Data Structure
3
4 Use a red-black tree data structure in a Zephyr application.
5
6Overview
7********
8
9This sample demonstrates how to use the Red-Black Tree (rbtree) data structure
10in a Zephyr application.
11The example shows basic rbtree operations such as insert, remove and foreach.
12
13Building and Running
14********************
15
16To build and run this sample on a supported board:
17
18.. code-block:: console
19
20 west build -b <your_board> samples/data_structures/rbtree
21 west flash
22
23Replace ``<your_board>`` with your actual board name (e.g., ``native_sim``).
24
25Sample Output
26*************
27
28On startup, the sample application will perform a sequence of rbtree operations
29and print the results. Expected output resembles:
30
31.. code-block:: console
32
33 *** Booting Zephyr OS build gd2a5c1ca82f0 ***
34 insert n=1 rb=0x105004
35 insert n=3 rb=0x105010
36 insert n=2 rb=0x10501c
37 insert n=5 rb=0x105028
38 insert n=4 rb=0x105034
39 max=1 min=5
40 rbtree elements:
41 n=5
42 n=4
43 n=3
44 n=2
45 n=1
46 removed max=1
47 removed min=5
48 rbtree after removal:
49 n=4
50 n=3
51 n=2
52 Done
53
54
55Requirements
56************
57
58No external hardware is required to run this sample.
59It runs on any Zephyr-supported board with standard console output, or
60native_sim.
61