I'm currently implementing a Merkle Tree in Rust. One of the problems I'm facing is the complexity of generating the proof. Meaning the vector I give to the verifier in order to check if an element is present. Many people say that I should transverse the tree to find the path for the element (if the element is part of the data set), but I don't understand how that would work if the Merkle Tree is not sorted. Am I missing something? From my understanding the best way to do this is find the leaf (if it exists) and find your way up the tree. In that case the complexity will be O(N) to generated.
Thanks in advance!