Divide and Conquer is a programming technique which makes the program more efficient to write. And this technique work on the concept of recursion to solve a problem step by step. Generally this technique work in three parts:- Divide:- Divide the problem into some subproblem. Conquer:- Conquer the subproblem by calling recursively until subproblem solved. Combine:- (Optional Step) Combine the subproblem solution. So, that we will get the final problem Solution. When the subproblems are large enough to solve recursively, we call the recursive case. Once the subproblem becomes small enough that we no longer recursive, we say that the recursion "bottom out" and that we have gotten down to the base case. Application of Divide and Conquer Quick Sort Strassen's algorithm for matrix multiplication Merge Sort Counting inversions Binary Search Finding Min and max Divide and Conquer Abstract Algorithm DAC(a,i,j) {
#include<stdio.h> #include<conio.h> //creating a structure for linked list typedef struct node { int data; struct node* next; }node; //rename whole structure // function for creating nodes of linked list node * createlinkedlist(int n); //return address void display(node * head); void sort1(node * head,int n); int main(){ int n=0; node* HEAD=NULL; node* HEAD1=NULL; printf("how many nodes want to add in a linklist "); scanf("%d",&n); HEAD=createlinkedlist(n); sort1(HEAD,n); display(HEAD); return 0; } node * createlinkedlist(int n) { int i=0; node * head=NULL; node * temp=NULL; node * p=NULL; for(i=0;i<n;i++) { //creating unattached node temp=(node*)malloc(sizeof(node)); printf("Enter the data for node %d \t",i+1); scanf("%d",&(temp->data)); temp->next =NU