This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Divide : Divide the n-element array into two n/2-element | |
* sub-arrays | |
* Conquer : Sort the two sub-arrays recursively using | |
* merge sort | |
* Combine : Merge the two sorted subsequences to form the | |
* sorted array | |
**/ | |
#include<stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Divide : Partition the array A[low....high] into two sub-arrays | |
* A[low....j-1] and A[j+1...high] such that each element | |
* of A[low....j-1] is less than or equal to A[j], which | |
* in turn is is less than or equal to A[j+1...high]. Compute | |
* the index j as part of this partitioning procedure. | |
* Conquer : Sort the two sub-arrays A[low....j-1] and A[j+1....high] | |
* by recursive calls to quicksort | |
**/ | |
#include<stdio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swapping without using a temporary variable in C | |
* (Addition & Subtraction) | |
**/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int a = 5, b = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Binary Search locates the position of an item in a sorted list. | |
* | |
* Divide : It works by dividing the list into two halves and | |
* comparing the input value to be searched with the | |
* middle element of the list. | |
* | |
* Conquer : If the input value is equal to the mid value, search | |
* is successful. If greater, call binary search only | |
* on the greater sub-array of the sorted list and if | |
* lesser, call binary search on the lesser sub-array. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swapping without using a temporary variable in C | |
* (Multiplication & Division) | |
**/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int a = 5, b = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Swapping without using a temporary variable in C | |
* (XOR) | |
**/ | |
#include<stdio.h> | |
int main(void) | |
{ | |
int a = 5; /* a = 0101 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To check whether a number is prime or not | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int n, i, p = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* To find the factorial of a number | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(void) | |
{ | |
int n, i, f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A palindrome is a word, phrase, number or other sequence | |
* of units that can be read the same way in either direction | |
**/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
int main(void) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Program to check the occurrences of a pattern in a text/string | |
* This program checks whether the pattern occur in the string | |
* or not, if yes at what positions and also print the text/string | |
* highlighting the occurrences | |
**/ | |
#include <stdio.h> | |
#include<string.h> |
OlderNewer