Computer programming is a highly cognitive skill. It requires mastery of many domains. But in reality many learners are not able to cope with the mental demands required in learning programming. Thus it leads to rote learning and memorization. There are many reasons for this situation. However one of the main reasons is the nature of the novice learners who experience high cognitive load while learning programming. Given the fact that the novice learners lack well defined schema and the limitation of the working memory, the students could not assimilate the knowledge required for learning. Many types of learning supports like visualization is provide to reduce the cognitive load. It is expected that the visualization will help in reducing the cognitive load by expanding the working memory. However the effect of visualization in learning is not clearly tangible. There are two common methods used to measure the cognitive load namely physiological and non physiological measures. It is found based on our prior studies that non physiological measure are more appropriate for measuring cognitive load in a class room situation. The non physiological measures include NASA TLX rating scale. It is also observed from our prior studies that there is a variation in learning performance using same visualization support among the students in a homogenous group. This variation is attributed to the level of Long Term Memory which includes prior mathematical, prior language skills, demographics and gender. This paper will propose a framework to optimize the instruction to learners based on their background profile and the extent of the long term memory and will employ neural network to optimize the instruction by suggesting the best visualization tool for each learner. The paper also validates the performance of the proposed tool by a study with the learners to evaluate the accuracy of the tool.