Package topics.divideconquer


package topics.divideconquer
Divide-and-Conquer algorithms — break, solve, and combine.

Divide and Conquer solves problems by recursively splitting them into smaller sub-problems of the same type, solving each sub-problem independently, and then merging the partial results into a final answer.

Recurrence and the Master Theorem

The running time of a divide-and-conquer algorithm typically satisfies:

T(n) = a · T(n/b) + f(n)

where a is the number of sub-problems, b is the size reduction factor, and f(n) is the cost of dividing / combining.

Distinction from Dynamic Programming

  • Divide & Conquer — sub-problems are independent; solved once.
  • Dynamic Programming — sub-problems overlap; results are cached.

Classes in This Package

  • Classes
    Class
    Description
    Binary Search implementation for finding an element in a sorted array.
    DIVIDE AND CONQUER PROBLEM: CALCULATE THE FACTORIAL OF A NUMBER
    Fibonacci Number Calculation using Divide and Conquer and Iterative Approaches.
    GREATEST COMMON DIVISORS: Calculate the GCG of two positive integers
    //DIVIDE AND CONQUER PROBLEM: IS THERE A MAJORITARIAN ELEMENT IN n ELEMENTS?
    DIVIDE AND CONQUER PROBLEM: MAXIMUM SUMMATION OF ALL THE SUBSEQUENCES OF n ELEMENTS
    //DIVIDE AND CONQUER PROBLEM: THE MEDIAN OF n ELEMENTS
    Mergesort algorithm using divide-and-conquer.
    //DIVIDE AND CONQUER PROBLEM: MODE OF n ELEMENTS
    DIVIDE AND CONQUER PROBLEM: CALCULATE THE POSITION OF AN ELEMENT x IN A VECTOR (SORTED OR UNSORTED) OF n DIFFERENT ELEMENTS
    DIVIDE AND CONQUER PROBLEM: CALCULATE THE SUM OF n ELEMENTS IN A VECTOR