## Selection Sorting using Recursion – Algorithms & Data Structures in C++

-// Recursive C++ program to sort an array // using selection sort #include <iostream> using namespace std;   // Return minimum index int minIndex(int a[], int i, int j) { if (i == j) return i;   // Find minimum of remaining elements int k = minIndex(a, i + 1, j);   // Return minimum […]

## Bubble Sorting using Recursion – Algorithms & Data Structures in C++

/C++ program for recursive implementation // of Bubble sort #include <bits/stdc++.h> using namespace std;   // A function to implement bubble sort void bubbleSort(int arr[], int n) { // Base case if (n == 1) return;   // One pass of bubble sort. After // this pass, the largest element // is moved (or bubbled) […]

## Insertion Sorting using Recursion – Algorithms & Data Structures in C++

#include <iostream> using namespace std; // Recursive function to sort an array using // insertion sort void insertionSortRecursive(int arr[], int n) { // Base case if (n <= 1) return;   // Sort first n-1 elements insertionSortRecursive( arr, n-1 );   // Insert last element at its correct position // in sorted array. int last […]

## Binary Searching using Iteration Method – Algorithms & Data Structures in C++

//BINARY SEARCH USING ITERATION #include<iostream> using namespace std; int binarysearch(int a[],int n,int x){ int start=0; int end=n-1; while(start<=end){ int mid=(start+end)/2; if(x==a[mid]) return mid; else if(x<a[mid]) end=mid-1; else start=mid+1; } return -1; } int main(){ int a[]={4,6,8,10,12,14,18,20}; cout<<“enter a number:\n”; int x; cin>>x; int index=binarysearch(a,8,x); if(index!=-1) cout<<“\n number is at index “<<index; else cout<<“\n number not […]

## Linked List Double – Algorithms & Data Structures in C++

#include<iostream> using namespace std; /* Linked list structure */ struct list { struct list *prev; int data; struct list *next; } *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL; class linkedlist { public: /* Function for create/insert node at the beginning of Linked list */ void insert_beginning() { […]

## Double Linked List Complete Program+Menu+Choices+Classes+Structure List+Switch Statements+Functions+Pointers – Algorithms & Data Structures in C++

#include<iostream> using namespace std; /* Linked list structure */ struct list { struct list *prev; int data; struct list *next; } *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL; class linkedlist { public: /* Function for create/insert node at the beginning of Linked list */ void insert_beginning() { […]

## Linked List Program – Algorithms & Data Structures in C++

#include <iostream> #include <conio.h> using namespace std; struct node { int data; node *next; }; class list { private: node *head, *tail; public: list() { head=NULL; tail=NULL; } void createnode(int value) { node *temp=new node; temp->data=value; temp->next=NULL; if(head==NULL) { head=temp; tail=temp; temp=NULL; } else { tail->next=temp; tail=temp; } } void display() { node *temp=new node; […]

## Bubble Sorting Maximum – Algorithms & Data Structures in C++

#include<iostream> #include<conio.h> #include<iomanip> #include<stdio.h> #include<dos.h> using namespace std; void BubbleSort (int arr[], int n) { int i, j; for (i = 0; i < n; ++i) { for (j = 0; j < n-i-1; ++j) { if (arr[j] < arr[j+1]) { arr[j] = arr[j]+arr[j+1]; arr[j+1] = arr[j]-arr[j + 1]; arr[j] = arr[j]-arr[j + 1]; } […]