Algorithms For Fault Tolerance In Distributed Systems And Routing In Ad Hoc Networks