diff --git a/ArrayLeftRotation.cpp b/Array Left Rotation.cpp similarity index 90% rename from ArrayLeftRotation.cpp rename to Array Left Rotation.cpp index 36278e1bb..177dada01 100644 --- a/ArrayLeftRotation.cpp +++ b/Array Left Rotation.cpp @@ -6,7 +6,8 @@ int main(){ 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"; + int a[n]; + cout<<"Enter elements of array=\t"; for(int i=0;i>a[i]; } diff --git a/ArrayRightRotation.cpp b/Array Right Rotation.cpp similarity index 100% rename from ArrayRightRotation.cpp rename to Array Right Rotation.cpp diff --git a/BubbleSort.cpp b/Bubble Sort.cpp similarity index 100% rename from BubbleSort.cpp rename to Bubble Sort.cpp diff --git a/CircularLinkedList - .cpp b/Circular Linked List.cpp similarity index 98% rename from CircularLinkedList - .cpp rename to Circular Linked List.cpp index c8b3841a2..bd68043dc 100644 --- a/CircularLinkedList - .cpp +++ b/Circular Linked List.cpp @@ -92,7 +92,7 @@ int main() switch (choice) { case 1 : cout<<"\nEnter the element to be inserted : "; - cin>>x;; + cin>>x; insert(x); break; case 2 : cout<<"\nEnter the element to be removed : "; cin>>x; diff --git a/Circular Queue Using Array.cpp b/Circular Queue Using Array.cpp new file mode 100644 index 000000000..503531e7a --- /dev/null +++ b/Circular Queue Using Array.cpp @@ -0,0 +1,77 @@ +#include +using namespace std; + +int queue[10]; +int front=0; +int rear=0; +int count=0; + +void push(int x) +{ + if(count==10) + { + cout<<"\nOverflow"; + } + else + { + queue[rear]=x; + rear=(rear+1)%10; + count++; + } +} + +void pop() +{ + if (front==rear) + { + cout<<"\nUnderflow"; + } + + else + { + cout<<"\n"<>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/decimal_to_binary.cpp b/Decimal To Binary.cpp similarity index 92% rename from decimal_to_binary.cpp rename to Decimal To Binary.cpp index 340a885cf..3794d2a96 100644 --- a/decimal_to_binary.cpp +++ b/Decimal To Binary.cpp @@ -1,20 +1,20 @@ -#include -using namespace std; -int main() -{ - int number; - cin>>number; - int remainder,binary=0,var=1; - -do{ - - remainder=number%2; - number=number/2; - binary=binary+(remainder*var); - var=var*10; - - -} -while(number>0); - cout< +using namespace std; +int main() +{ + int number; + cin>>number; + int remainder,binary=0,var=1; + +do{ + + remainder=number%2; + number=number/2; + binary=binary+(remainder*var); + var=var*10; + + +} +while(number>0); + cout<next!=NULL) + while(t->next!=NULL) { t=t->next; } diff --git a/InsertionSort.cpp b/Insertion Sort.cpp similarity index 100% rename from InsertionSort.cpp rename to Insertion Sort.cpp diff --git a/LinearSearch.cpp b/Linear Search.cpp similarity index 100% rename from LinearSearch.cpp rename to Linear Search.cpp diff --git a/LinkedList.cpp b/Linked List.cpp similarity index 100% rename from LinkedList.cpp rename to Linked List.cpp diff --git a/ListArray.cpp b/List Array.cpp similarity index 100% rename from ListArray.cpp rename to List Array.cpp diff --git a/Queue Using Array.cpp b/Queue Using Array.cpp new file mode 100644 index 000000000..e7e2e295d --- /dev/null +++ b/Queue Using Array.cpp @@ -0,0 +1,78 @@ +#include +using namespace std; + +int queue[10]; +int front=0; +int rear=0; + +void push(int x) +{ + if(rear==10) + { + cout<<"\nOverflow"; + } + else + { + queue[rear++]=x; + } +} + +void pop() +{ + if (front==rear) + { + cout<<"\nUnderflow"; + } + + else + { + cout<<"\n"<>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/Queue Using Linked List.cpp b/Queue Using Linked List.cpp new file mode 100644 index 000000000..067a9c35d --- /dev/null +++ b/Queue Using Linked List.cpp @@ -0,0 +1,90 @@ +#include +using namespace std; + +struct node +{ + int val; + node *next; +}; + + +node *front, *rear; + + +void push(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 pop() +{ + 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. 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/SelectionSort.cpp b/Selection Sort.cpp similarity index 100% rename from SelectionSort.cpp rename to Selection Sort.cpp diff --git a/ShellSort.cpp b/Shell Sort.cpp similarity index 100% rename from ShellSort.cpp rename to Shell Sort.cpp diff --git a/Stack Using Array.cpp b/Stack Using Array.cpp new file mode 100644 index 000000000..4095c5aed --- /dev/null +++ b/Stack Using Array.cpp @@ -0,0 +1,68 @@ +#include +using namespace std; + +int stack[10]; +int top=0; + +void push(int x) +{ + if(top==10) + { + cout<<"\nOverflow"; + } + else + { + stack[top++]=x; + } +} + +void pop() +{ + if (top==0) + { + cout<<"\nUnderflow"; + } + else + { + cout<<"\n"<>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/Stack Using Linked List.cpp b/Stack Using Linked List.cpp new file mode 100644 index 000000000..753fda8ed --- /dev/null +++ b/Stack Using Linked List.cpp @@ -0,0 +1,75 @@ +#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; +} +