diff --git a/Algorithmic Strategies/Divide and Conquer .README.md b/Algorithmic Strategies/Divide and Conquer .README.md new file mode 100644 index 00000000..0c16b840 --- /dev/null +++ b/Algorithmic Strategies/Divide and Conquer .README.md @@ -0,0 +1,104 @@ +#
Divide and Conquer
+## Divide and Conquer is a problem-solving technique that breaks down a large problem into smaller, more manageable subproblems. These subproblems are solved independently and then combined to find the solution to the original problem. This approach helps in reducing complexity and improving efficiency in many algorithms. It is often used in algorithms related to sorting, searching, and multiplication. + +### Example: Merge Sort +### 1. Divide the array into two halves. +### 2. Recursively sort each half. +### 3. Merge the two sorted halves to form a sorted array. +### In this case, the problem of sorting an array is divided into smaller subproblems, each of which is easier to solve. +
+ +### For Example : +``` +#include + +// Function to merge two halves into a sorted array +void merge(int arr[], int left, int mid, int right) { + int n1 = mid - left + 1; + int n2 = right - mid; + + // Create temporary arrays + int leftArr[n1], rightArr[n2]; + + // Copy data to temporary arrays + for (int i = 0; i < n1; i++) + leftArr[i] = arr[left + i]; + for (int j = 0; j < n2; j++) + rightArr[j] = arr[mid + 1 + j]; + + // Merge the temp arrays back into the original array + int i = 0, j = 0, k = left; + while (i < n1 && j < n2) { + if (leftArr[i] <= rightArr[j]) { + arr[k] = leftArr[i]; + i++; + } else { + arr[k] = rightArr[j]; + j++; + } + k++; + } + + // Copy remaining elements of leftArr[], if any + while (i < n1) { + arr[k] = leftArr[i]; + i++; + k++; + } + + // Copy remaining elements of rightArr[], if any + while (j < n2) { + arr[k] = rightArr[j]; + j++; + k++; + } +} + +// Function to implement Merge Sort +void mergeSort(int arr[], int left, int right) { + if (left < right) { + int mid = left + (right - left) / 2; // Find the middle point + + // Recursively sort the first and second halves + mergeSort(arr, left, mid); + mergeSort(arr, mid + 1, right); + + // Merge the sorted halves + merge(arr, left, mid, right); + } +} + +// Function to print the array +void printArray(int arr[], int size) { + for (int i = 0; i < size; i++) + printf("%d ", arr[i]); + printf("\n"); +} + +// Main function +int main() { + int arr[] = {38, 27, 43, 3, 9, 82, 10}; + int size = sizeof(arr) / sizeof(arr[0]); + + printf("Original Array: \n"); + printArray(arr, size); + + // Call mergeSort to sort the array + mergeSort(arr, 0, size - 1); + + printf("Sorted Array: \n"); + printArray(arr, size); + + return 0; +} + +``` + +### Output: +``` +Original Array: +38 27 43 3 9 82 10 +Sorted Array: +3 9 10 27 38 43 82 + +``` diff --git a/index.html b/index.html index c824b8ba..efae409d 100644 --- a/index.html +++ b/index.html @@ -190,23 +190,10 @@

Codeforces

  • Who We Are
  • - - onmouseover="this.style.color='black'; this.style.paddingLeft='10px'" - onmouseout="this.style.color='white'; this.style.paddingLeft='0'">Who We Are - - -
  • Blog
  • - - -
  • Blog
  • -
  • Work With Us
  • Codeforces - \ No newline at end of file + diff --git a/styles.css b/styles.css index 0264d1a5..505acfe7 100644 --- a/styles.css +++ b/styles.css @@ -704,85 +704,6 @@ footer { color: #1da1f2; text-shadow: 0 6px 10px rgba(0, 0, 0, 0.2); } -footer form input { - flex: 1; - padding: 10px; - font-size: 14px; - border: 1px solid #dee2e6; - border-radius: 4px; - background-color: #ffffff; - transition: all 0.4s ease; - outline: none; - position: relative; -} - -footer form input:hover { - border-color: #6c757d; - background-color: #f1f1f1; - box-shadow: 0 4px 12px rgba(108, 117, 125, 0.2); - transform: translateY(-2px) scale(1.02); -} - -footer form input:focus { - border-color: #495057; - background-color: #ffffff; - box-shadow: 0 6px 15px rgba(73, 80, 87, 0.3); - transform: translateY(-3px) scale(1.03); -} - -footer form input:active { - border-color: #343a40; - background-color: #e9ecef; - box-shadow: 0 2px 8px rgba(52, 58, 64, 0.2); - transform: translateY(0) scale(1); -} - -footer form button { - padding: 10px 20px; - font-size: 14px; - font-weight: bold; - background-color: #6c757d; - color: #ffffff; - border: none; - border-radius: 4px; - cursor: pointer; - transition: all 0.4s ease, box-shadow 0.4s ease; - position: relative; - overflow: hidden; -} - -footer form button:hover { - background-color: #495057; - transform: translateY(-2px) scale(1.05); - box-shadow: 0 6px 15px rgba(73, 80, 87, 0.3); -} - -footer form button:active { - background-color: #343a40; - transform: translateY(0) scale(0.98); - box-shadow: 0 2px 8px rgba(52, 58, 64, 0.2); -} - -footer form button::before { - content: ""; - position: absolute; - top: 0; - left: -100%; - width: 100%; - height: 100%; - background: rgba(255, 255, 255, 0.2); - transition: all 0.4s ease; - z-index: 1; -} - -footer form button:hover::before { - left: 100%; -} - -footer form button span { - position: relative; - z-index: 2; -} .social-links a[aria-label="Instagram"]:hover { color: #e4405f;