From ad29e53586e90fe628fbd40034c1314ce35d824b Mon Sep 17 00:00:00 2001 From: kshitijalwadhi <52427677+kshitijalwadhi@users.noreply.github.com> Date: Thu, 31 Oct 2019 11:28:40 +0530 Subject: [PATCH 1/2] Create LinearSearch.cpp --- Searching/LinearSearch.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Searching/LinearSearch.cpp diff --git a/Searching/LinearSearch.cpp b/Searching/LinearSearch.cpp new file mode 100644 index 0000000..309a115 --- /dev/null +++ b/Searching/LinearSearch.cpp @@ -0,0 +1,33 @@ +#include + +void main() +{ + int arr[10], i, num, n, c=0, pos; + cout<<"Enter the array size : "; + cin>>n; + cout<<"Enter Array Elements : "; + for(i=0; i>arr[i]; + } + cout<<"Enter the number to be searched: "; + cin>>num; + for(i=0; i Date: Thu, 31 Oct 2019 11:32:26 +0530 Subject: [PATCH 2/2] Create RecursiveBubbleSort.cpp --- Sorting/RecursiveBubbleSort.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Sorting/RecursiveBubbleSort.cpp diff --git a/Sorting/RecursiveBubbleSort.cpp b/Sorting/RecursiveBubbleSort.cpp new file mode 100644 index 0000000..1e1f743 --- /dev/null +++ b/Sorting/RecursiveBubbleSort.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +void bubbleSort(int arr[], int n) { + for (int i = 0; i < n - 1; i++) { + if (arr[i] > arr[i + 1]) { + int temp = arr[i]; + arr[i] = arr[i+1]; + arr[i+1] = temp; + } + } + if (n - 1 > 1) { + bubbleSort(arr, n - 1); + } +} +int main() { + int arr[] = { 5,4,2,1,3 }; + int n = 5; + bubbleSort(arr, n); + for (int i = 0; i < n; i++) { + cout<< arr[i]<<"\t"; + } + return 0; +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy