A tree sort algorithm in Julia


I warmly welcome everyone,

I am a new, fresh user of Julia, my programming skills are rather weak. I would like to use Julia’s language to make a tree sort algorithm. Is it possible to do this in this language?

Can I ask for help on how to do it? Can anyone already do this algorithm in this language?

Thank you for all the help.



Welcome too! Everything is possible in Julia (it’s turning complete :wink: ), but more importantly, most things are pleasant to program in Julia!

The SortedDict in https://github.com/JuliaCollections/DataStructures.jl is based on a tree datastructure, which is sorted. Maybe this can help?

Edit: see this old post also https://groups.google.com/forum/?fromgroups=#!searchin/julia-dev/tree/julia-dev/dDaUEqHKVCk/zBBIQBAn7jMJ


So, so true!


@rafg I’ll just add that, if you’re looking to implement the algorithm as part of learning the language and learning programming in general, looking at an expert’s version (like you might find in SortedDict) might be confusing.

That’s ok! If you go to kick a soccer ball (football) for the first or even hundredth time, and compare yourself to a pro, of course you might feel lacking. My advice: make something short that you want to sort (x = rand(10) will give you an array of length 10 that would be a good start), and start trying to build a function that sorts it isn’t the tree sort algorithm.

Good luck!


Very good point! I know that my own implementations of things like that are heavily optimized for performance,
and that can be harder to follow. :nerd_face:


You are definitely right, maybe I have expressed myself badly but I need help writing such a function, because even this causes me a problem and I do not know how to do it :frowning: .


Yup! Welcome to programming - bang your head against things that you can’t do until you can do them. Then work on doing them better. As lost as you may feel, the fact that you have something specific to work on puts you in a good place!

Generally speaking, when you’re asking questions of people in forums like this, if your question is broad (as yours is), people will point you to documentation, or to other examples. The usual advice is to be as specific as possible with your question. If you’re asking how to write a tree sort algorithm, but you’re actually not quite sure how to even write any algorithm, the solutions for writing a tree sort aren’t going to be very helpful (I’m not saying this is where you are, but it’s just an example).

When you’re starting out, it can be hard to be specific, because you don’t necessarily know what it is you’re really asking. It’s as if you’re asking how to get to Paris, and someone tells you “Oh, you just drive to the airport and get on a plane,” but you don’t know what an airport is, don’t know how to drive, and that “get on a plane” actually means “purchase a ticket for a plane that is flying to Paris.” Once you’ve actually figured out how to drive and how to get to the airport, you start asking questions in forums about what to do with the controls of a jumbo jet.

Being specific helps here too. Read this. Then read it again. It’s really useful advice. But the gist is, whenever you’re asking a question, tell us not just what you’re trying to do, but what you’ve tried and what errors or problems that you’re experiencing. If you say “I’m trying to get to Paris - I managed to figure out how to get in the car and get to an airport, but when I tried pulling the throttle of the plane, but the plane didn’t lift off the ground,” people will be able to say “Whoa - you don’t actually need to fly the plane yourself! Here’s a website where you can buy a ticket.”