KAUST AMCS 260 algorithm