Added greedy search and created ordering for nodes