From ae302a34a255c3cdc30171882c0c071b2ee21ea9 Mon Sep 17 00:00:00 2001 From: "NAGARAJ.K" <67584685+NAGARAJ08@users.noreply.github.com> Date: Wed, 12 Oct 2022 19:11:20 +0530 Subject: [PATCH 1/2] Merge_Sort --- merge_sort.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 merge_sort.cpp diff --git a/merge_sort.cpp b/merge_sort.cpp new file mode 100644 index 0000000..0ca2588 --- /dev/null +++ b/merge_sort.cpp @@ -0,0 +1,93 @@ +#include +using namespace std; + + +void merge(int arr[],int left,int mid,int right) +{ + //number of elements in the divided arrays + int nL=mid-left+1; //nL number of elements in left array + int nR = right-mid; //nR number of elements in right array + + int L[nL],R[nR]; //temporary arrays + + for(int i=0;i>n; + int arr[n]; + cout<<"Enter the elements: "; + for(int i=0;i>arr[i]; + } + + mergeSort(arr,0,n-1); + + cout<<"The sorted Array is: "< Date: Wed, 12 Oct 2022 21:12:37 +0530 Subject: [PATCH 2/2] priority_queue --- priority_queue.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 priority_queue.cpp diff --git a/priority_queue.cpp b/priority_queue.cpp new file mode 100644 index 0000000..057696c --- /dev/null +++ b/priority_queue.cpp @@ -0,0 +1,47 @@ + +//by default priority queue creates max-heap. + +#include +using namespace std; + + + +void showpq(priority_queuepq) +{ + priority_queuep = pq; //just copied it + while(!p.empty()) + { + cout<<"\t"<pq; + + // we can create a min heap priority queue using the below line + //priority_queue,greater>pq; + pq.push(20); + pq.push(40); + pq.push(30); + pq.push(3); + pq.push(1); + + cout<<"The priority Queue is: "; + showpq(pq); + + + +return 0; +} + + + + + + + +