Why does memoization not improve the runtime of Merge Sort?

允我心安 提交于 2019-12-05 17:30:36

You have already given the answer in the question. Memoization implies writing a memo after solving a problem, so that when we encounter the problem again, we use the memo instead of solving the same problem again.

Since in mergesort, the problems don't overlap, writing a memo is of no use.

Memoization is a technique where the result of an expensive functioned is stored to be used later. Merge sort is a divide and conquer algorithm which divides the problem into smaller non overlapping sub problems. Because of the functions being non overlapping they are called just once and hence memoization cannot really be used to optimise it since their is no need to store the output of a expensive function call for it to be used later, since it is called only once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!