分割アルゴリズム_分而治のアルゴリズムの意味:例を挙げて説明する


分割して治めるアルゴリズム
分けて治めるアルゴリズムとは何ですか.(いや、これは「分けて治める」(What are Divide and Conquer Algorithms?)
Divide and Conquer is an algorithmic paradigm (sometimes mistakenly called "Divide and Concur"- a funny and apt name), similar to Greedy and Dynamic Programming. A typical Divide and Conquer algorithm solves a problem using the following three steps.
「分割して治す」は、「貪欲で動的なプログラミング」に似たアルゴリズムのパターンである(時には「Divide and Concur」(面白くて適切な名前)と誤って呼ばれることがある).典型的な分割アルゴリズムは、次の3つのステップを使用して問題を解決する.
  • Divide: Break the given problem into subproblems of same type. This step involves breaking the problem into smaller sub-problems. Sub-problems should represent a part of the original problem. This step generally takes a recursive approach to divide the problem until no sub-problem is further divisible. At this stage, sub-problems become atomic in nature but still represent some part of the actual problem. 分割:指定した問題を同じタイプのサブ問題に分解します.このステップは、問題をより小さなサブ問題に分解することに関連します.サブ問題は元の問題の一部を表すべきである.このステップは、通常、サブ問題がさらに分割されないまで、再帰的な方法で問題を分割します.この段階では,サブ問題は本質的に原子問題となっているが,実際の問題の一部を代表している.
  • Conquer: Recursively solve these sub-problems. This step receives a lot of smaller sub-problems to be solved. Generally, at this level, the problems are considered 'solved' on their own. 征服:これらのサブ問題を再帰的に解決する.このステップでは、解決すべき小さな問題がたくさん発生します.通常、このレベルでは、問題は「解決済み」とみなされます.
  • Combine: Appropriately combine the answers. When the smaller sub-problems are solved, this stage recursively combines them until they formulate a solution of the original problem. This algorithmic approach works recursively and conquer & merge steps works so close that they appear as one. マージ:答えを適切にマージします.小さなサブ問題が解決されると、このフェーズでは、元の問題の解決策が作成されるまで、それらを再帰的に組み合わせます.このアルゴリズム法は再帰的に機能し,征服と合併ステップがこのように接近してそれらが1つのように見えるようになった.

  • This method usually allows us to reduce the time complexity by a large extent.
    この方法は通常,時間的複雑さを大幅に低減することができる.
    For example, Bubble Sort uses a complexity of O(n^2) , whereas quicksort (an application Of Divide And Conquer) reduces the time complexity to O(nlog(n)) . Linear Search has time complexity O(n) , whereas Binary Search (an application Of Divide And Conquer) reduces time complexity to O(log(n)) .
    例えば、バブルソートはO(n^2)の複雑さを使用し、高速ソート(分割アプリケーション)は時間複雑さをO(nlog(n))に低減する.線形探索の時間的複雑度はO(n)であり、バイナリ探索(分割アプリケーション)は時間的複雑度をO(log(n))に低減する.
    Following are some standard algorithms that are of the Divide and Conquer algorithms variety.
    以下は、分割されたアルゴリズムのいくつかの標準アルゴリズムです.
    Binary Search  is a searching algorithm. In each step, the algorithm compares the input element (x) with the value of the middle element in array. If the values match, return the index of middle. Otherwise, if x is less than the middle element, then the algorithm recurs to the left side of the middle element, else it recurs to the right side of the middle element.
    バイナリ検索は検索アルゴリズムです.各ステップでは、アルゴリズムは入力要素(x)と配列内の中間要素の値を比較します.値が一致すると、中間インデックスが返されます.そうでなければ、xが中間要素より小さい場合、アルゴリズムは中間要素の左側に再帰され、そうでなければアルゴリズムは中間要素の右側に再帰される.
    Quicksort  is a sorting algorithm. The algorithm picks a pivot element, rearranges the array elements in such a way that all elements smaller than the picked pivot element move to the left side of the pivot, and all greater elements move to the right side. Finally, the algorithm recursively sorts the subarrays on left and right of pivot element.
    Quicksortはソートアルゴリズムです.このアルゴリズムでは、選択したピボット要素より小さいすべての要素がピボットの左側に移動し、より大きいすべての要素が右側に移動するピボット要素を選択します.最後に,このアルゴリズムはピボット要素の左右両側のサブ配列を再帰的にソートする.
    Merge Sort  is also a sorting algorithm. The algorithm divides the array into two halves, recursively sorts them, and finally merges the two sorted halves. The time complexity of this algorithm is O(nLogn) , be it best case, average case or worst case. It's time complexity can be easily understood from the recurrence equates to: T(n) = 2T(n/2) + n .
    マージソートもソートアルゴリズムです.このアルゴリズムは配列を2つの半分に分け,それらを再帰的に並べ替え,最後に2つの並べ替えの半分を結合する.このアルゴリズムの時間的複雑さはO(nLogn)であり,最適であっても平均であっても最悪であってもよい.時間がT(n) = 2T(n/2) + nに等しいことから、その時間的複雑さを容易に理解することができる.
    Closest Pair of Points  The problem is to find the closest pair of points in a set of points in x-y plane. The problem can be solved in O(n^2) time by calculating distances of every pair of points and comparing the distances to find the minimum. The Divide and Conquer algorithm solves the problem in O(nLogn) time.
    最も近い点対問題はxy平面の中の1組の点の中で最も近い点対を見つけることである.この問題は、各対の点の距離を計算し、距離を比較して最小値を見つけることによって、O(n^2)時間以内に解決することができる.分割アルゴリズムはO(nLogn)時間の問題を解決した.
    Strassen’s Algorithm  is an efficient algorithm to multiply two matrices. A simple method to multiply two matrices need 3 nested loops and is O(n^3) . Strassen’s algorithm multiplies two matrices in O(n^2.8974) time.
    Strassenアルゴリズムは2つの行列を乗算する効率的なアルゴリズムである.2つの行列を単純に乗算する方法は、O(n^3)の3つのネストされたサイクルを必要とする.Strassenアルゴリズムは2つの行列をO(n^2.8974)時間で乗算する.
    Cooley–Tukey Fast Fourier Transform (FFT) algorithm  is the most common algorithm for FFT. It is a divide and conquer algorithm which works in O(nlogn) time.
    Cooley-Tukey高速フーリエ変換(FFT)アルゴリズムはFFTで最もよく使われるアルゴリズムである.これはO(nlogn)時間以内に使用できる分治法です.
    The Karatsuba algorithm  was the first multiplication algorithm asymptotically faster than the quadratic "grade school"algorithm. It reduces the multiplication of two n-digit numbers to at most to n^1.585 (which is approximation of log of 3 in base 2) single digit products. It is therefore faster than the classical algorithm, which requires n^2 single-digit products.
    Karatsubaアルゴリズムは,二次「等級学校」アルゴリズムよりも漸進的に速い最初の乗算アルゴリズムである.2つのnビット数の積を最大n^1.585(2をベースとした対数3の対数)に減少させる.従って,古典アルゴリズムよりも速く,後者はn^2単位の積を必要とする.
    分而治之(D&C)と動的プログラミング(DP)(Divide and Conquer(D&C)vs Dynamic Programming(DP))
    Both paradigms (D & C and DP) divide the given problem into subproblems and solve subproblems. How to choose one of them for a given problem? Divide and Conquer should be used when same subproblems are not evaluated many times. Otherwise Dynamic Programming or Memoization should be used.
    両方の例(D&CおよびDP)は、与えられた問題をサブ問題に分割し、サブ問題を解決する.指定した問題のいずれかを選択するにはどうすればいいですか?同じサブ問題が複数回評価されていない場合は、分割を使用して解決する必要があります.そうでない場合は、ダイナミックプログラミングまたはメモリを使用します.
    For example, Binary Search is a Divide and Conquer algorithm, we never evaluate the same subproblems again. On the other hand, for calculating the nth Fibonacci number, Dynamic Programming should be preferred.
    たとえば,バイナリ検索は分割されたアルゴリズムであり,同じサブ問題を二度と評価しない.一方,n番目のフィボナッチ数を計算するためには,動的プログラミングが優先されるべきである.
    翻訳:https://www.freecodecamp.org/news/divide-and-conquer-algorithms/
    分割して治めるアルゴリズム