The Nanda dynasty ruled in northern part of the Indian subcontinent during the 4th century BCE, and possibly during the 5th century BCE. In 326 BC, Alexander invaded India, after crossing the river Indus he advanced towards Taxila.
Viharas were for the purpose of living, Chaityas were assemblies for the purpose of discussions. Further, Chaityas were with Stupas, Viharas did not have stupas.