Can't understand how c++ set works : I am using c++ stl set class for a leetcode question. from googlein I heard set keeps the elements in ordered manner and I heard that set.begin() returns the smallest element. But I also heard set uses red black trees and has log(n) time complexity. I don't understand how these two can go together, as in how does set.begin() return smallest element when a redblack tree doesn't guarantee the smallest element will be the head. Also set.begin() function makes it seem like this container uses an array instead of a linked list to build the redblack tree, which again I don't understand how an array can be used instead of a tree.Can someone explain me the implementation of c++ set?

Thank you.