简体   繁体   中英

Why does memoization not improve the runtime of Merge Sort?

Why does memoization not improve the runtime of Merge Sort?

I have this question from Assignment task. But as far as I know, Merge Sort uses divide and conquer approach (no overlapping subproblems) but Memoization is based on dynamic programing (with overlapping subproblem). I know the runtime of Merge Sort is O(nlogn) .

I even searched on web search engines and there is no result for this question. Is this question wrong? If it sounds wrong but why would a professor give a wrong question in assignment? If the question is not wrong or my understanding about the question, Merge Sort and Memoization is wrong, How should I answer this question?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM