implemented print_all_paths algorithm