itinerary 3 http://postimg.org/image/p8vmh1223/
Budapest-Zagreb: daytime trains twice a day (morning/evening), roughly 7 hours travel time and 29 euro (doesn't matter when to buy you ticket as far as you do it in Hungary)
Zagreb-Sarajevo: daytime train, roughly 9 hours, about 30 euro (only when you buy in Croatia/BiH)
Sarajevo-Montenegro: no decent train option, so just bus here
Montenegro-Albania: same here, no passenger trains between two countries
Montenegro-Belgrade: daytime & overnight trains (quite busy during summer), marvelous scenery (thus recommend to travel during the day), roughly 11 hours, tickets from roughly 20 euro (only when you buy in MNT/Serbia)
Belgrade-Budapest: daytime & overnight trains, roughly 8 hours, tickets from 15 euro (only when you buy in Hungary/Serbia)
itinerary 4 http://postimg.org/image/4d9c5s5uz/
Szeged-Belgrade: no direct service, but with two relatively easy changes it is possible to get to Belgrade by rail only
Belgrade-Sarajevo: no direct rail service
--//--
Albania-Kosovo: no direct rail service
Pristina-Skopje: once a day direct train, roughly 2:30 hours, tickets (separate for Kosovo & Macedonia legs) in total would be around 5 euro or so
Skopje-Sofia: no direct rail service, but plenty of buses
Sofia-Timisoara: no direct train, but you can try going via Bucharest (or, alternatively with many changes & buses via Vidin/Craiova)
Timisoara-Szeged: no direct train, but with one change (in Bekescsaba) it's about 5 hours journey by rail (NB direct Timisoara-Budapest trains available)