README.rst
1.. zephyr:code-sample:: min-heap
2 :name: Min-Heap Data Structure
3
4 Demonstrate usage of a min-heap implementation in a Zephyr application.
5
6Overview
7********
8
9This sample demonstrates Min-Heap Data Structure implementation used as a
10priority queue in a Zephyr application.
11The example shows basic heap operations such as insert, remove, pop and
12empty check.
13
14Building and Running
15********************
16
17To build and run this sample on a supported board:
18
19.. code-block:: console
20
21 west build -b <your_board> samples/lib/min_heap
22 west flash
23
24Replace ``<your_board>`` with your actual board name (e.g., ``native_sim``).
25
26Sample Output
27*************
28
29On startup, the sample application will perform a sequence of heap operations
30and print the results. Expected output resembles:
31
32.. code-block:: console
33
34 *** Booting Zephyr OS build 9c0c063db09d ***
35 Min-heap sample using static storage
36 Heap elements by order of priority:
37 key=2 value=400
38 key=5 value=200
39 key=30 value=300
40 key=10 value=100
41 Top of heap: key=2 value=400
42 Found element with key 5 at index 1,removing it...
43 Heap after removal:
44 key=2 value=400
45 key=10 value=100
46 key=30 value=300
47
48
49
50Requirements
51************
52
53No external hardware is required to run this sample.
54It runs on any Zephyr-supported board with standard console output or
55native_sim.
56