How can i sort binary search tree by count

Hi everyone,
i have a binary search tree. it has string name and int count
also it has left and right

Aahan 25
Aalam 87
Abharan 21
Abhinandana 998
Kumari 24
.
.
.
i want to sort like this
Abhinandana 998
Aalam 87
Aahan 25
Kumari 24
Abharan 21

Best regards
Last edited on
Make sure that your binary tree's node struct has data members name and count as well as left and right pointers.

Define a bool comesBefore( node a, node b ) function that returns whether a.count > b.count. Use this in your comparison that determines left or right for both insertion and writing out.

Beyond that use a standard binary tree structure.

Show your attempt.
Topic archived. No new replies allowed.