This file contains 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
vecvector<int> removeDuplicates(vector<int> A) | |
{ | |
int j = 0; | |
for(int i = 1; i < A.size()-1; i++) | |
{ | |
if (A[i] != A[i-1]) | |
{ | |
swap(A[j],A[i]); | |
j++; | |
} |
This file contains 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 multiply two arbitary precision arrays */ | |
vector<int> Multiply (vector<int> num1, vector<int> num2) | |
{ | |
// The result will be sum of size of 2 numbers + 1. setting it to 0 initially | |
vector result(num1.size()+num2.size()+1,0); | |
//Return early if either is empty | |
if(num1.empty() || num2.empty()) | |
return result; |
This file contains 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 which takes an input array and an index and rearranges the array such that values less than the element come first, | |
elements equal follow and finally followed by elements greater than the index element*/ | |
//Notes: This is just the quicksort algorithm where they have given the random value and there is just one step | |
This solution is the same as the precvious code: only just add a condition to increment the current index when the values match | |
This file contains 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
struct morphParameters{ | |
int shape; | |
int size; | |
int oper; | |
Mat* src; | |
Mat* res; | |
}; | |
void morphology(Mat* src, Mat *result, int size) | |
{ | |
int choice; |
This file contains 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
#include <opencv2/imgproc/imgproc.hpp> | |
#include "opencv2/highgui/highgui.hpp" | |
#include <iostream> | |
using namespace cv; | |
using namespace std; | |
int main( int argc, char** argv ) | |
{ | |
This file contains 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
void countSort(int* arr,int size, int exp) | |
{ | |
int output[size]; | |
int count[10]; | |
for(int i=0; i<size; i++) | |
count[(arr[i]/exp)%10]++; | |
for(int i=1; i<10; i++) | |
count[i] += count[i-1]; |
This file contains 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
//Heapify function is used to convert a tree rooted at node root into a max heap | |
void heapify (int* arr, int root, int size) | |
{ | |
int pos = root; | |
// location of children | |
int left = 2*root + 1; | |
int right = 2*root + 2; | |
if (arr[root] < arr[left]) |
This file contains 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
void swap(int& a, int& b) | |
{ | |
int temp = a; | |
a = b; | |
b = temp; | |
} | |
void partition(int * arr, int left, int right) | |
{ | |
int pivotValue = arr[right]; |
This file contains 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
void mergeArrays(int * arr, int l, int m, int r) | |
{ | |
// Compare element by element from arr[l:m] with arr[m:r] and accordingly move index within idividual arr | |
int lsize = m-l+1; // this will include the middle element | |
int rsize = r-m; | |
int L[lsize];R[rsize]; | |
for(int i=0; i < lsize; i++) | |
L[i] = arr[l+i]; | |
for(int i=0; i < rsize; i++) | |
R[i] = arr[m+j]; |
This file contains 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
#include "chapter2.h" | |
void display_video(char **argv) | |
{ | |
// CvCapture structure is used to store the information of the various properties of the | |
// avi and the create file capture returns a pointer of this type initialized to the beginning | |
// of the avi | |
CvCapture *pCapture = cvCreateFileCapture(argv[1]); | |
// Create a window to display the video frames |
NewerOlder