I need to construct a Binary Search Tree from a file that has more than 2 million lines (each line will give me a pair key/val). Since the data is ordered, if I just read one line, get the key and val and add to my tree, the height will be huge so that the tree will be inefficient to search. So, I was thinking if there is a good way to construct this search tree so that it doesnt have a huge height. My attempt was to get the first 100.000 keys, shuffle, put on tree and so on, but it doesnt seems much efficient. Any suggestion?
P.S: I have to use a not balanced search tree.
Thanks !