From bd6c8a3531fe54ed938a26c6f65d6c29d32d9ace Mon Sep 17 00:00:00 2001 From: ashwek Date: Tue, 12 Feb 2019 18:58:22 +0530 Subject: [PATCH] Removed duplicate files --- Array Left Rotation.cpp | 31 ---- Array Right Rotation.cpp | 31 ---- Binary Search.cpp | 34 ----- Buzz_number.cpp | 17 --- Circular Linked List.cpp | 109 ------------- Circular Queue Using Array.cpp | 77 ---------- Doubly Linked List.cpp | 125 --------------- GCD_of_n_numbers.cpp | 23 --- Intersection_of_2_arrays.cpp | 30 ---- Linear Search.cpp | 48 ------ List Array.cpp | 185 ----------------------- Queue Using Array.cpp | 78 ---------- Queue Using Linked List.cpp | 90 ----------- Reverse a Linked List using Recusion.cpp | 80 ---------- Stack Using Linked List.cpp | 75 --------- Strassen Matrix Multiplication.cpp | 60 -------- Tower of Hanoi.cpp | 88 ----------- Union_of_2_arrays.cpp | 33 ---- fibonacci.cpp | 46 ------ searching.cpp | 39 ----- 20 files changed, 1299 deletions(-) delete mode 100644 Array Left Rotation.cpp delete mode 100644 Array Right Rotation.cpp delete mode 100644 Binary Search.cpp delete mode 100644 Buzz_number.cpp delete mode 100644 Circular Linked List.cpp delete mode 100644 Circular Queue Using Array.cpp delete mode 100644 Doubly Linked List.cpp delete mode 100644 GCD_of_n_numbers.cpp delete mode 100644 Intersection_of_2_arrays.cpp delete mode 100644 Linear Search.cpp delete mode 100644 List Array.cpp delete mode 100644 Queue Using Array.cpp delete mode 100644 Queue Using Linked List.cpp delete mode 100644 Reverse a Linked List using Recusion.cpp delete mode 100644 Stack Using Linked List.cpp delete mode 100644 Strassen Matrix Multiplication.cpp delete mode 100644 Tower of Hanoi.cpp delete mode 100644 Union_of_2_arrays.cpp delete mode 100644 fibonacci.cpp delete mode 100644 searching.cpp diff --git a/Array Left Rotation.cpp b/Array Left Rotation.cpp deleted file mode 100644 index 177dada01..000000000 --- a/Array Left Rotation.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -using namespace std; -int main(){ - int n,k; - cout<<"Enter size of array=\t"; - cin>>n; - cout<<"Enter Number of indeces u want to rotate the array to left=\t"; - cin>>k; - int a[n]; - cout<<"Enter elements of array=\t"; - for(int i=0;i>a[i]; - } - int temp=0; - for(int i=0;i -using namespace std; -int main(){ - int n,k; - cout<<"Enter size of array=\t"; - cin>>n; - cout<<"Enter Number of indices u want to rotate the array to right=\t"; -cin>>k; -int a[n]; -cout<<"Enter elements of array=\t"; - for(int i=0;i>a[i]; - int temp=0; - for(int i=0;i=0;j--){ - if(j==0){ - a[j]=temp; - } - else{ - a[j]=a[j-1];} - - } - - } - cout<<"Your rotated array is=\t"; - for(int i=0;i -using namespace std; -int binary_search(int a[],int l,int r,int key){ - while(l<=r){ - int m = l+(r-l)/2; - if(key==a[m]) - return m; - else if(key>n; - cout<<"Enter array elements: "; - int a[n]; - for (int i = 0; i < n; ++i) - { - cin>>a[i]; - } - cout<<"Enter search key: "; - cin>>key; - int res = binary_search(a,0,n-1,key); - if(res != -1) - cout< -using namespace std; -int main() -{ - int n,t; - cin >> t; - while(t--) - { - cin >> n; - if((n%7==0)||(n%10==7)) - cout << n << " is a buzz number" << endl; - else - cout << n << " is not a buzz number" << endl; - } - return 0; -} diff --git a/Circular Linked List.cpp b/Circular Linked List.cpp deleted file mode 100644 index bd68043dc..000000000 --- a/Circular Linked List.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -using namespace std; - -struct node -{ - int val; - node *next; -}; - -node *start; - -void insert(int x) -{ - node *t=start; - - if (start!=NULL) - { - while(t->next!=start) - { - t=t->next; - } - node *n= new node; - t->next=n; - n->val=x; - n->next=start; - } - else - { - node *n= new node; - n->val=x; - start=n; - n->next=start; - } -} - -void remove(int x) -{ - node *t=start; - node *p; - while(t->val!=x) - { - p=t; - t=t->next; - } - p->next=t->next; - delete t; -} - -void search(int x) -{ - node *t= start; - int found =0; - while(t->next!=start) - { - if(t->val==x) - { - cout<<"\nFound"; - found=1; - break; - } - t=t->next; - } - if(found==0) - { - cout<<"\nNot Found"; - } -} - -void show() -{ - node *t=start; - do - { - cout<val<<"\t"; - t=t->next; - } - while(t!=start); - -} - -int main() -{ - int choice, x; - do - { - cout<<"\n1. Insert"; - cout<<"\n2. Delete"; - cout<<"\n3. Search"; - cout<<"\n4. Print"; - cout<<"\n\nEnter you choice : "; - cin>>choice; - switch (choice) - { - case 1 : cout<<"\nEnter the element to be inserted : "; - cin>>x; - insert(x); break; - case 2 : cout<<"\nEnter the element to be removed : "; - cin>>x; - remove(x); break; - case 3 : cout<<"\nEnter the element to be searched : "; - cin>>x; - search(x); break; - case 4 : show(); break; - } - } - while(choice!=0); - - return 0; -} diff --git a/Circular Queue Using Array.cpp b/Circular Queue Using Array.cpp deleted file mode 100644 index d91f31af3..000000000 --- a/Circular Queue Using Array.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -using namespace std; - -int queue[10]; -int front=0; -int rear=0; -int count=0; - -void Enque(int x) -{ - if(count==10) - { - cout<<"\nOverflow"; - } - else - { - queue[rear]=x; - rear=(rear+1)%10; - count++; - } -} - -void Deque() -{ - if (front==rear) - { - cout<<"\nUnderflow"; - } - - else - { - cout<<"\n"<>ch; - if (ch==1) - { - cout<<"\nInsert : "; - cin>>x; - Enque(x); - } - else if (ch==2) - { - Deque(); - } - else if (ch==3) - { - show(); - } - } - while(ch!=0); - - return 0; -} - diff --git a/Doubly Linked List.cpp b/Doubly Linked List.cpp deleted file mode 100644 index db550d422..000000000 --- a/Doubly Linked List.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include -using namespace std; - -struct node -{ - int val; - node *prev; - node *next; -}; - -node *start; - -void insert(int x) -{ - node *t=start; - if (start!=NULL) - { - while(t->next!=NULL) - { - t=t->next; - } - node *n= new node; - t->next=n; - n->prev=t; - n->val=x; - n->next=NULL; - } - else - { - node *n= new node; - n->val=x; - n->prev=NULL; - n->next=NULL; - start=n; - } -} - -void remove(int x) -{ - node *t=start; - while(t->val!=x) - { - t=t->next; - } - t->prev->next=t->next; - t->next->prev=t->prev; - delete t; -} - -void search(int x) -{ - node *t= start; - int found =0; - while(t!=NULL) - { - if(t->val==x) - { - cout<<"\nFound"; - found=1; - break; - } - t=t->next; - } - if(found==0) - { - cout<<"\nNot Found"; - } -} - -void show() -{ - node *t=start; - while(t!=NULL) - { - cout<val<<"\t"; - t=t->next; - } - -} - -void reverseShow() -{ - node *t=start; - while(t->next!=NULL) - { - t=t->next; - } - while(t!=NULL) - { - cout<val<<"\t"; - t=t->prev; - } -} - -int main() -{ - int choice, x; - do - { - cout<<"\n1. Insert"; - cout<<"\n2. Delete"; - cout<<"\n3. Search"; - cout<<"\n4. Forward print"; - cout<<"\n5. Reverse print"; - cout<<"\n\nEnter you choice : "; - cin>>choice; - switch (choice) - { - case 1 : cout<<"\nEnter the element to be inserted : "; - cin>>x;; - insert(x); break; - case 2 : cout<<"\nEnter the element to be removed : "; - cin>>x; - remove(x); break; - case 3 : cout<<"\nEnter the element to be searched : "; - cin>>x; - search(x); break; - case 4 : show(); break; - case 5 : reverseShow(); break; - } - } - while(choice!=0); - - return 0; -} diff --git a/GCD_of_n_numbers.cpp b/GCD_of_n_numbers.cpp deleted file mode 100644 index 3e9e9ce17..000000000 --- a/GCD_of_n_numbers.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//This program aims at calculating the GCD of n numbers by division method -#include -using namepsace std; -int main() -{ - cout <<"Enter value of n:"<> n; - int a[n]; - int i,j,gcd; - cout << "Enter the n numbers:" << endl; - for(i=0;i> a[i]; - j=1; //to access all elements of the array starting from 1 - gcd=a[0]; - while(j -int main() -{ - int i,j,m,n; - cout <<"Enter size of array 1:"; - cin >> m; - cout <<"Enter size of array 2:"; - cin >> n; - int a[m]; - int b[n]; - cout <<"Enter elements of array 1:"; - for(i=0;i> a[i]; - for(i=0;i> b[i]; - i=0;j=0; - while((ib[j]) - j++; - else - { - cout << a[i++]<<" "; - j++; - } - } - return 0; -} diff --git a/Linear Search.cpp b/Linear Search.cpp deleted file mode 100644 index fd381756d..000000000 --- a/Linear Search.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -using namespace std; - -int LinearSearch(int *array, int size, int key) -{ - for (int i = 0; i < size; ++i) - { - if (array[i]==key) - { - return i; - } - } - - return -1; -} - - -int main() -{ - int size; - cout<<"\nEnter the size of the Array : "; - cin >> size; - - int array[size]; - int key; - - //Input array - cout<<"\nEnter the Array of " << size << " numbers : "; - for (int i = 0; i < size; i++) - { - cin>>array[i]; - } - - cout<<"\nEnter the number to be searched : "; - cin>>key; - - int index=LinearSearch(array, size, key); - if (index!=-1) - { - cout<<"\nNumber found at index : "< -using namespace std; - -struct list -{ - int data[50]; - int top=0; - bool isSorted=false; - - int BinarySearch(int *array, int first, int last, int x) - { - if(lastarray[mid]) - return (BinarySearch(array, mid+1, last, x)); - } - - int LinarSearch(int *array, int x) - { - for (int i = 0; i < top; i++) - { - if (array[i]==x) - { - return i; - } - } - - return -1; - } - - int Search(int x) - { - int pos=-1; - - if (isSorted) - { - pos=BinarySearch(data, 0, top-1, x); - } - - else - { - pos=LinarSearch(data, x); - } - - if (pos!=-1) - { - cout<<"\nElement found at position : "< pos; i--) - { - data[i]=data[i-1]; - } - top++; - data[pos]=x; - } - } - - void Remove(int x) - { - int pos=Search(x); - cout<<"\n"<>choice; - switch (choice) - { - case 1: cout<<"\nEnter the element to be inserted : "; - cin>>x; - L.insert(x); - break; - case 2: cout<<"\nEnter the element to be removed : "; - cin>>x; - L.Remove(x); - break; - case 3: cout<<"\nEnter the element to be searched : "; - cin>>x; - L.Search(x); - break; - case 4: L.Sort(); - break; - case 5: L.Show(); - break; - } - } - while(choice!=0); - return 0; -} diff --git a/Queue Using Array.cpp b/Queue Using Array.cpp deleted file mode 100644 index 7b5816f84..000000000 --- a/Queue Using Array.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include -using namespace std; - -int queue[10]; -int front=0; -int rear=0; - -void Enque(int x) -{ - if(rear==10) - { - cout<<"\nOverflow"; - } - else - { - queue[rear++]=x; - } -} - -void Deque() -{ - if (front==rear) - { - cout<<"\nUnderflow"; - } - - else - { - cout<<"\n"<>ch; - if (ch==1) - { - cout<<"\nInsert : "; - cin>>x; - Enque(x); - } - else if (ch==2) - { - Deque(); - } - else if (ch==3) - { - show(); - } - } - while(ch!=0); - - return 0; -} - diff --git a/Queue Using Linked List.cpp b/Queue Using Linked List.cpp deleted file mode 100644 index acf32ebd5..000000000 --- a/Queue Using Linked List.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include -using namespace std; - -struct node -{ - int val; - node *next; -}; - - -node *front, *rear; - - -void Enque(int x) -{ - if (rear==NULL) - { - node *n= new node; - n->val=x; - n->next=NULL; - rear=n; - front=n; - } - - else - { - - node *n = new node; - n->val=x; - n->next=NULL; - rear->next=n; - rear=n; - } -} - -void Deque() -{ - if (rear==front) - { - cout<<"\nUnderflow"; - } - else - { - node *t = front; - cout<<"\n"<val<<" deleted"; - front=front->next; - delete t; - } -} - -void show() -{ - node *t=front; - while(t!=NULL) - { - cout<val<<"\t"; - t=t->next; - } -} - -int main() -{ - int ch, x; - do - { - cout<<"\n1. Enque"; - cout<<"\n2. Deque"; - cout<<"\n3. Print"; - cout<<"\nEnter Your Choice : "; - cin>>ch; - if (ch==1) - { - cout<<"\nInsert : "; - cin>>x; - Enque(x); - } - else if (ch==2) - { - Deque(); - } - else if (ch==3) - { - show(); - } - } - while(ch!=0); - - return 0; -} - diff --git a/Reverse a Linked List using Recusion.cpp b/Reverse a Linked List using Recusion.cpp deleted file mode 100644 index daefa18e8..000000000 --- a/Reverse a Linked List using Recusion.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -using namespace std; - -struct node -{ - int val; - node *next; -}; - -node *start; - -void insert(int x) -{ - node *t=start; - if (start!=NULL) - { - while(t->next!=NULL) - { - t=t->next; - } - node *n= new node; - t->next=n; - n->val=x; - n->next=NULL; - } - else - { - node *n= new node; - n->val=x; - n->next=NULL; - start=n; - } -} - -void reverse(node *p, node *q) -{ - if (q->next == NULL) - { - q->next=p; - p->next=NULL; - start=q; - return; - } - else - { - reverse(q, q->next); - q->next=p; - p->next=NULL; - } - -} - - -void show() -{ - node *t=start; - while(t!=NULL) - { - cout<val<<"\t"; - t=t->next; - } - -} - -int main() -{ - insert(1); - insert(2); - insert(3); - insert(4); - insert(5); - insert(6); - - reverse(start, start->next); - - show(); - - - return 0; -} diff --git a/Stack Using Linked List.cpp b/Stack Using Linked List.cpp deleted file mode 100644 index 753fda8ed..000000000 --- a/Stack Using Linked List.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include -using namespace std; - -struct node -{ - int val; - node *next; -}; - - -node *top; - -void push(int x) -{ - node *n = new node; - n->val=x; - n->next=top; - top=n; -} - -void pop() -{ - if (top==NULL) - { - cout<<"\nUnderflow"; - } - else - { - node *t = top; - cout<<"\n"<val<<" deleted"; - top=top->next; - delete t; - } -} - -void show() -{ - node *t=top; - while(t!=NULL) - { - cout<val<<"\n"; - t=t->next; - } -} - -int main() -{ - int ch, x; - do - { - cout<<"\n1. Push"; - cout<<"\n2. Pop"; - cout<<"\n3. Print"; - cout<<"\nEnter Your Choice : "; - cin>>ch; - if (ch==1) - { - cout<<"\nInsert : "; - cin>>x; - push(x); - } - else if (ch==2) - { - pop(); - } - else if (ch==3) - { - show(); - } - } - while(ch!=0); - - return 0; -} - diff --git a/Strassen Matrix Multiplication.cpp b/Strassen Matrix Multiplication.cpp deleted file mode 100644 index 1cb398a62..000000000 --- a/Strassen Matrix Multiplication.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -using namespace std; - -Multiply(int A[][], int B[][], int n) -{ - if (n==2) - { - int p1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]); - int p2= (a[1][0]+a[1][1])*b[0][0]; - int p3= a[0][0]*(b[0][1]-b[1][1]); - int p4= a[1][1]*(b[1][0]-b[0][0]); - int p5= (a[0][0]+a[0][1])*b[1][1]; - int p6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]); - int p7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]); - - - int c[n][n]; - c[0][0]=p1+p4-p5+p7; - c[0][1]=p3+p5; - c[1][0]=p2+p4; - c[1][1]=p1-p2+p3+p6; - - return c[][]; - } - else - { - - } - -} - -int main() -{ - int p,q,r,s; - cout<<"Enter the dimensions of Matrices"; - cin>>n; - int A[n][n],; - int B[n][n],; - cout<<"Enter the elements of Matrix A"; - for (int i = 0; i < n; i++) - { - for (int j = 0; j >A[i][j]; - } - } - - - cout<<"Enter the elements of Matrix B"; - for (int i = 0; i < n; i++) - { - for (int j = 0; j >B[i][j]; - } - } - - Multiply(A, B, n); - return 0; -} \ No newline at end of file diff --git a/Tower of Hanoi.cpp b/Tower of Hanoi.cpp deleted file mode 100644 index f9b363784..000000000 --- a/Tower of Hanoi.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -using namespace std; - -struct tower -{ - int values[10]; - int top; -}F, U, T; - - - -void show() -{ - cout<<"\n\n\tF : "; - for(int i=0; i> no; - - for (int i = no; i >0; i--) - { - F.values[F.top++]=i; - }; - - - - - - show(); - TH(no, F, U, T); - - - - - - return 0; -} diff --git a/Union_of_2_arrays.cpp b/Union_of_2_arrays.cpp deleted file mode 100644 index 4046e1ae8..000000000 --- a/Union_of_2_arrays.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -int main() -{ - int m,n,i=0,j=0; - cout << "Enter size of both arrays:"; - cin >> m >> n; - int a[m]; - int b[n]; - cout << "Enter elements of array 1:"; - for(i=0;i>a[i]; - cout << "Enter elements of array 2:"; - for(i=0;i> b[i]; - i=0;j=0; - while((ib[j]) - cout << b[j++] <<" "; - else - { - cout << a[i++]; - j++; - } - } - while(i -#include -using namespace std; - -const long long MAX = 93; - - -long long f[MAX] = {0}; - - -long long fib(long long n) -{ - - if (n == 0) - return 0; - if (n == 1 || n == 2) - return (f[n] = 1); - - - if (f[n]) - return f[n]; - - long long k = (n%2!=0)? (n+1)/2 : n/2; - - f[n] = (n%2!=0)? (fib(k)*fib(k) + fib(k-1)*fib(k-1)) - : (2*fib(k-1) + fib(k))*fib(k); - return f[n]; -} - - -int main() -{ - //Main Function - for(long long i=1;i<93;i++) - { - cout << i << " th fibonacci number is " << fib(i) << "\n"; - } - return 0; -} diff --git a/searching.cpp b/searching.cpp deleted file mode 100644 index eab40e4e8..000000000 --- a/searching.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -using namespace std; -char paragraph; - -int main() -{ - string paragraph; - cout << "Please enter your paragraph: \n"; - getline (cin,paragraph); - cout << "\nHello, your paragraph is:\n " << paragraph << "!\n"; - cout << "\nThe size of your paragraph = " << paragraph.size() << " characters. \n\n"; - - if (paragraph.empty()) - { - cout << "\nThe paragraph is empty" << endl; - } - else - { - while (true) { - string word; - cout << "Please enter the word you are searching for: "; - getline (cin,word); - cout << "Hello, your word is " << word << "!\n"; - if (paragraph.find(word) == string::npos) - { - cout << word << " does not exist in the sentence" << endl; - } - else - { - cout << "The word " << word << " is now found at location " << paragraph.find(word) << endl << endl; - } - system("pause"); - } - - } -}