From 5c0cb3f11820c4f1d44be5ea71aa8617c027e19b Mon Sep 17 00:00:00 2001 From: TheCodeyWizard <92143765+TheCodeyWizard@users.noreply.github.com> Date: Tue, 4 Oct 2022 12:46:27 +0530 Subject: [PATCH 01/48] Add Kevin in Contributing.md --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a375309..0417e12 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,2 +1,5 @@ A repo for beginner contributors in hacktober 2022 , you can create a file and upload a new program and pull. MAke sure the program is error free. Multiple languages allowed . Happy coding. + + +[Abhishek Kevin Gomes.txt](https://github.com/Anurag2622002/Codefornewccoder/files/9703528/Abhishek.Kevin.Gomes.txt) From 0e038b7d4f631612898d06f563b012959ba7b5fe Mon Sep 17 00:00:00 2001 From: utksin13 <114904343+utksin13@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:01:33 +0530 Subject: [PATCH 02/48] Create c --- c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 c diff --git a/c b/c new file mode 100644 index 0000000..d0af7d7 --- /dev/null +++ b/c @@ -0,0 +1,65 @@ +#include +int removerepeated(int size,int a[]); +void sort(int size,int a[]); +main(){ + int i,size1,size2,size,j=0,k; + printf("Enter size of an array1\n"); + scanf("%d",&size1); + printf("Enter size of an array2\n"); + scanf("%d",&size2); + int a[size1],b[size2],uni[size1+size2]; + printf("Enter numbers for array 1\n"); + for(i=0;ia[j]){ + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } + } + } +} From 93e010d427ea08037d98362fe882698d035833ef Mon Sep 17 00:00:00 2001 From: Ayushi Sagar Date: Tue, 4 Oct 2022 13:04:09 +0530 Subject: [PATCH 03/48] BellmanFord --- BellmanFord.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 BellmanFord.cpp diff --git a/BellmanFord.cpp b/BellmanFord.cpp new file mode 100644 index 0000000..047de33 --- /dev/null +++ b/BellmanFord.cpp @@ -0,0 +1,56 @@ +#include "bits/stdc++.h" +using namespace std; + +const int INF = 1e9; + +int main(){ + int n,m;cin>>n>>m; + vector> edges; + cout<<"u v w"<>u>>v>>w; + edges.push_back({u,v,w}); + } + cout<>src; + vector dist(n,INF); + dist[src] = 0; + for (int iter = 0; iter < n-1; iter++) + { + bool change = false; + + for(auto e : edges){ + int u = e[0]; + int v = e[1]; + int w = e[2]; + + //for detection of cycle + if(dist[v] > w + dist[u]){ + change = true; + } + dist[v] = min(dist[v], w + dist[u]); + } + } + cout<<"VERTEX DISTANCE FROM SOURCE"< Date: Tue, 4 Oct 2022 13:04:49 +0530 Subject: [PATCH 04/48] Create create cc --- create cc | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 create cc diff --git a/create cc b/create cc new file mode 100644 index 0000000..d0af7d7 --- /dev/null +++ b/create cc @@ -0,0 +1,65 @@ +#include +int removerepeated(int size,int a[]); +void sort(int size,int a[]); +main(){ + int i,size1,size2,size,j=0,k; + printf("Enter size of an array1\n"); + scanf("%d",&size1); + printf("Enter size of an array2\n"); + scanf("%d",&size2); + int a[size1],b[size2],uni[size1+size2]; + printf("Enter numbers for array 1\n"); + for(i=0;ia[j]){ + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } + } + } +} From 4e102de5a318a3b06e14c2aef7314357e6f9b5e3 Mon Sep 17 00:00:00 2001 From: Shivam Date: Tue, 4 Oct 2022 13:08:52 +0530 Subject: [PATCH 05/48] FloydWarshall Algo --- FloydWarshallAlgo.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 FloydWarshallAlgo.cpp diff --git a/FloydWarshallAlgo.cpp b/FloydWarshallAlgo.cpp new file mode 100644 index 0000000..f05856f --- /dev/null +++ b/FloydWarshallAlgo.cpp @@ -0,0 +1,47 @@ +#include "bits/stdc++.h" +using namespace std; + +const int INF = 1e9; + +int main(){ + vector> graph = + { {0,5,INF,10}, + {INF,0,3,INF}, + {INF,INF,0,1}, + {INF,INF,INF,0} + }; + + int n = graph.size(); + vector> dist = graph; + for(int k=0; k dist[i][k] + dist[k][j]){ + dist[i][j] = dist[i][k] + dist[k][j]; + } + } + } + } + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if(dist[i][j] == INF){ + cout<<"INF "; + } + else{ + cout< Date: Tue, 4 Oct 2022 13:28:36 +0530 Subject: [PATCH 06/48] Creating fIle of heap sort program creating heap sort --- heap_Sort.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 heap_Sort.c diff --git a/heap_Sort.c b/heap_Sort.c new file mode 100644 index 0000000..d17647d --- /dev/null +++ b/heap_Sort.c @@ -0,0 +1,106 @@ + +// HEAP SORT USING ARRAY IMPLEMENTATION + + +#include +int a[20],n; + +void display() +{ +int i; +for(i=0;i0) +{ +parent=(loc-1)/2; +if (num<=a[parent]) +{ +a[loc]=num; +return; +} +a[loc]=a[parent]; +loc=parent; +} +a[0]=num; +} + +void create_heap() +{ +int i; +for(i=0;i=a[left] && a[i]>=a[right] ) +return; +if ( a[right]<=a[left] ) +{ +temp=a[i]; +a[i]=a[left]; +a[left]=temp; +i=left; +} +else +{ +temp=a[i]; +a[i]=a[right]; +a[right]=temp; +i=right; +} +left=2*i+1; +right=2*i+2; +} +if ( left==last-1 && a[i]0; last--) +del_root(last); +} + +void main() +{ +int i; +printf ("\nEnter number of elements :"); +scanf ("%d",&n); +for(i=0;i Date: Tue, 4 Oct 2022 13:29:32 +0530 Subject: [PATCH 07/48] MergeSort & MergeSortInPlace in JAVA --- mergeSort.java | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 mergeSort.java diff --git a/mergeSort.java b/mergeSort.java new file mode 100644 index 0000000..ea621df --- /dev/null +++ b/mergeSort.java @@ -0,0 +1,88 @@ +import java.util.Arrays; + +public class mergeSort { + public static void main(String[] args) { + int[] arr = {5,32,12,31,2}; + mergeSortInp(arr,0,arr.length); + System.out.println(Arrays.toString(arr)); + } + + static int[] mergesort(int[] arr) { + if (arr.length == 1) { + return arr; + } + int mid = arr.length / 2; + int[] left = mergesort(Arrays.copyOfRange(arr, 0, mid)); + int[] right = mergesort(Arrays.copyOfRange(arr, mid, arr.length)); + return merge(left, right); + } + + private static int[] merge(int[] first, int[] second) { + int[] mix = new int[first.length + second.length]; + int i = 0; + + int j = 0; + int k = 0; + while (i < first.length && j < second.length) { + if (first[i] < second[j]) { + mix[k] = first[i]; + i++; + } else { + mix[k] = second[j]; + j++; + } + k++; + } + while (i < first.length) { + mix[k] = first[i]; + i++; + k++; + } + while (j < second.length) { + mix[k] = second[j]; + j++; + k++; + } + return mix; + } + + static void mergeSortInp(int[] arr, int s, int e) { + if (e-s == 1) { + return; + } + int mid = (s+e)/2; + mergeSortInp(arr,s,mid); + mergeSortInp(arr,mid,e); + mergeInp(arr,s,mid,e); + + } + private static void mergeInp(int[] arr,int s,int m,int e){ + int[] mix = new int[e-s]; + int i =s; + int j=m; + int k=0; + while(i Date: Tue, 4 Oct 2022 13:34:46 +0530 Subject: [PATCH 08/48] Updated QuickSort by adding Recusion. *Added Recursion. --- Quicksort.java | 80 ++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/Quicksort.java b/Quicksort.java index d2da1fa..4e11a35 100644 --- a/Quicksort.java +++ b/Quicksort.java @@ -1,47 +1,45 @@ import java.io.*; -class GFG { - static void swap(int[] arr, int i, int j) - { - int temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - }static int partition(int[] arr, int low, int high) - { - int pivot = arr[high]; - int i = (low - 1); +import java.util.Arrays; - for (int j = low; j <= high - 1; j++) { - if (arr[j] < pivot) { - i++; - swap(arr, i, j); - } - } - swap(arr, i + 1, high); - return (i + 1); - } - static void quickSort(int[] arr, int low, int high) - { - if (low < high) { - int pi = partition(arr, low, high); - quickSort(arr, low, pi - 1); - quickSort(arr, pi + 1, high); - } - } -static void printArray(int[] arr, int size) - { - for (int i = 0; i < size; i++) - System.out.print(arr[i] + " "); +public class QuickSort { + public static void main(String[] args) { + int[] arr = {5, 4, 3, 2, 1}; +// sort(arr, 0, arr.length - 1); +// System.out.println(Arrays.toString(arr)); + Arrays.sort(arr); + } - System.out.println(); - } + static void sort(int[] nums, int low, int hi) { + if (low >= hi) { + return; + } - public static void main(String[] args) - { - int[] arr = { 10, 7, 8, 9, 1, 5 }; - int n = arr.length; + int s = low; + int e = hi; + int m = s + (e - s) / 2; + int pivot = nums[m]; - quickSort(arr, 0, n - 1); - System.out.println("Sorted array: "); - printArray(arr, n); - } + while (s <= e) { + + // also a reason why if its already sorted it will not swap + while (nums[s] < pivot) { + s++; + } + while (nums[e] > pivot) { + e--; + } + + if (s <= e) { + int temp = nums[s]; + nums[s] = nums[e]; + nums[e] = temp; + s++; + e--; + } + } + + // now my pivot is at correct index, please sort two halves now + sort(nums, low, e); + sort(nums, s, hi); + } } From 1215b87baedd9ef04b4e6bb4acd7126a2ed6b747 Mon Sep 17 00:00:00 2001 From: sahanmndl Date: Tue, 4 Oct 2022 13:35:22 +0530 Subject: [PATCH 09/48] Topological Sort CPP --- TopologicalSort.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 TopologicalSort.cpp diff --git a/TopologicalSort.cpp b/TopologicalSort.cpp new file mode 100644 index 0000000..1ab6248 --- /dev/null +++ b/TopologicalSort.cpp @@ -0,0 +1,75 @@ +#include +using namespace std; + +class Solution +{ + public: + void dfs(int node, int vis[], stack &st, vector adj[]) { + vis[node] = 1; + + for(auto x : adj[node]) { + if(!vis[x]) { + dfs(x, vis, st, adj); + } + } + + st.push(node); + } + + vector topoSort(int V, vector adj[]) + { + int vis[V] = {0}; + stack st; + + for(int i = 0; i < V; i++) { + if(!vis[i]) { + dfs(i, vis, st, adj); + } + } + + vector ans; + while(!st.empty()) { + ans.push_back(st.top()); + st.pop(); + } + + return ans; + } +}; + +int check(int V, vector &res, vector adj[]) { + vector map(V, -1); + for (int i = 0; i < V; i++) { + map[res[i]] = i; + } + for (int i = 0; i < V; i++) { + for (int v : adj[i]) { + if (map[i] > map[v]) return 0; + } + } + return 1; +} + +int main() { + int T; + cin >> T; + while (T--) { + int N, E; + cin >> E >> N; + int u, v; + + vector adj[N]; + + for (int i = 0; i < E; i++) { + cin >> u >> v; + adj[u].push_back(v); + } + + Solution obj; + vector res = obj.topoSort(N, adj); + + cout << check(N, res, adj) << endl; + } + + return 0; +} \ No newline at end of file From 96528d79adca8f985a13f9f22bee6951bf53ebb9 Mon Sep 17 00:00:00 2001 From: TheCodeyWizard <92143765+TheCodeyWizard@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:37:55 +0530 Subject: [PATCH 10/48] Create Diamond Pattern in Python --- Diamond Pattern in Python | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Diamond Pattern in Python diff --git a/Diamond Pattern in Python b/Diamond Pattern in Python new file mode 100644 index 0000000..6be8698 --- /dev/null +++ b/Diamond Pattern in Python @@ -0,0 +1,12 @@ +#Diamond Pattern in Python by Kevin + +n = 5 +print("Pattern 1") +for a1 in range (0,n): + for a2 in range (a1): + print("*", end="") + print() +for a1 in range (n,0,-1): + for a2 in range (a1): + print("*", end="") + print() From 95fb189ee96b53e2c93d062b1eb78811446bf370 Mon Sep 17 00:00:00 2001 From: aarushiksk Date: Tue, 4 Oct 2022 16:39:56 +0530 Subject: [PATCH 11/48] Display Affirmation --- AffirmationsInPython.py | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 AffirmationsInPython.py diff --git a/AffirmationsInPython.py b/AffirmationsInPython.py new file mode 100644 index 0000000..02d4e9f --- /dev/null +++ b/AffirmationsInPython.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +""" +Created on Tue Oct 4 15:32:00 2022 + +@author: aarus +""" + +# Import turtle package +import turtle + +# Creating a turtle object(pen) +pen = turtle.Turtle() + +# Defining a method to draw curve +def curve(): + for i in range(200): + + # Defining step by step curve motion + pen.right(1) + pen.forward(1) + +# Defining method to draw a full heart +def heart(): + + # Set the fill color to red + pen.fillcolor('red') + + # Start filling the color + pen.begin_fill() + + # Draw the left line + pen.left(140) + pen.forward(113) + + # Draw the left curve + curve() + pen.left(120) + + # Draw the right curve + curve() + + # Draw the right line + pen.forward(112) + + # Ending the filling of the color + pen.end_fill() + +# Defining method to write text +def txt(): + + # Move turtle to air + pen.up() + + # Move turtle to a given position + pen.setpos(-68, 95) + + # Move the turtle to the ground + pen.down() + + # Set the text color to lightgreen + pen.color('black') + + # Write the specified text in + # specified font style and size + pen.write("YOU MATTER!!", font=( + "Andada Pro", 15, "bold")) + + + +# Draw a heart +heart() + +# Write text +txt() + +# To hide turtle +pen.ht() \ No newline at end of file From 7da735eecfdc0dccf0adf33b764a058c457d6fc5 Mon Sep 17 00:00:00 2001 From: Rishabh Jha Date: Tue, 4 Oct 2022 17:22:18 +0530 Subject: [PATCH 12/48] Tower of Hanoi using c --- TowerOfHanoi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 TowerOfHanoi.c diff --git a/TowerOfHanoi.c b/TowerOfHanoi.c new file mode 100644 index 0000000..35359a0 --- /dev/null +++ b/TowerOfHanoi.c @@ -0,0 +1,22 @@ +#include +#include + +void move(int n, char source, char dest, char spare) +{ + if (n == 1) + printf("\n Move from %c to %c", source, dest); + else + { + move(n - 1, source, spare, dest); + move(1, source, dest, spare); + move(n - 1, spare, dest, source); + } +} +int main() +{ + int n; + printf("\n Enter the number of rings: "); + scanf("%d", &n); + move(n, 'a', 'c', 'b'); + return 0; +} From ce00ad586e8a439bacabc80b8160dc33e9fe1837 Mon Sep 17 00:00:00 2001 From: yashgoel2211 <114853033+yashgoel2211@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:30:28 +0530 Subject: [PATCH 13/48] Add files via upload --- hoursToWeek.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 hoursToWeek.java diff --git a/hoursToWeek.java b/hoursToWeek.java new file mode 100644 index 0000000..0c332d8 --- /dev/null +++ b/hoursToWeek.java @@ -0,0 +1,13 @@ +import java.util.*; +public class Main +{ + public static void main(String args[]) + { + Scanner sc=new Scanner(System.in); + + double hour = 450; + double week = 3.5; + double wk = hour / 168; + System.out.println("Value of "+hour+" hour in week: "+ wk); + } +} \ No newline at end of file From dbc5ea26a8f977391556130c2c8c323ee53f110c Mon Sep 17 00:00:00 2001 From: bhavy007 <44473716+bhavy007@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:45:35 +0530 Subject: [PATCH 14/48] added insertionSort --- insertionSort.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 insertionSort.py diff --git a/insertionSort.py b/insertionSort.py new file mode 100644 index 0000000..864bad9 --- /dev/null +++ b/insertionSort.py @@ -0,0 +1,23 @@ +# creating a function for insertion +def insertion_sort(list1): + + # Outer loop to traverse through 1 to len(list1) + for i in range(1, len(list1)): + + value = list1[i] + + # Move elements of list1[0..i-1], that are + # greater than value, to one position ahead + # of their current position + j = i - 1 + while j >= 0 and value < list1[j]: + list1[j + 1] = list1[j] + j -= 1 + list1[j + 1] = value + return list1 + # Driver code to test above + +list1 = [10, 5, 13, 8, 2] +print("The unsorted list is:", list1) + +print("The sorted list1 is:", insertion_sort(list1)) \ No newline at end of file From eb9eb84a80a0d9afca7d0823d0378fb57f60a068 Mon Sep 17 00:00:00 2001 From: chir263 <31371125+chir263@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:47:42 +0530 Subject: [PATCH 15/48] Longest increasing subsequence --- longest_increasing_subsequence.cpp | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 longest_increasing_subsequence.cpp diff --git a/longest_increasing_subsequence.cpp b/longest_increasing_subsequence.cpp new file mode 100644 index 0000000..0cbd974 --- /dev/null +++ b/longest_increasing_subsequence.cpp @@ -0,0 +1,56 @@ +/* C++ implementation of LIS problem */ +#include +using namespace std; + +/* lis prints the length and the longest + increasing subsequence in arr[] of size n */ +void lis_and_print(int arr[], int n) +{ + int lis[n]; + + lis[0] = 1; + + /* Compute optimized LIS values in + bottom up manner */ + for (int i = 1; i < n; i++) + { + lis[i] = 1; + for (int j = 0; j < i; j++) + if (arr[i] > arr[j] && lis[i] < lis[j] + 1) + lis[i] = lis[j] + 1; + } + + // maximum value in lis + int length = *max_element(lis, lis + n); + + cout << "Length of LIS is " << length << "\n"; + + // Prints Longest increasing subsequence in arr[] + + cout << "LIS is "; + + vector longest_inc_sub; + for (int i = n - 1; i >= 0; i--) + { + if (lis[i] == length) + { + longest_inc_sub.push_back(arr[i]); + length--; + } + } + + reverse(longest_inc_sub.begin(), longest_inc_sub.end()); + + for (auto elem : longest_inc_sub) + cout << elem << " "; + cout << "\n"; +} + +/* Driver program to test above function */ +int main() +{ + int arr[] = {20, 32, 19, 43, 31, 60, 51, 70}; + int n = sizeof(arr) / sizeof(arr[0]); + lis_and_print(arr, n); + return 0; +} \ No newline at end of file From 1549514fae0c14de8bb46104303a7097ae3c6b0b Mon Sep 17 00:00:00 2001 From: bhavy007 <44473716+bhavy007@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:57:35 +0530 Subject: [PATCH 16/48] added heapSort --- heapSort.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 heapSort.cpp diff --git a/heapSort.cpp b/heapSort.cpp new file mode 100644 index 0000000..36e3d94 --- /dev/null +++ b/heapSort.cpp @@ -0,0 +1,71 @@ +#include + +using namespace std; + +// A function to heapify the array. +void MaxHeapify(int a[], int i, int n) +{ + int j, temp; + temp = a[i]; + j = 2*i; + + while (j <= n) + { + if (j < n && a[j+1] > a[j]) + j = j+1; + // Break if parent value is already greater than child value. + if (temp > a[j]) + break; + // Switching value with the parent node if temp < a[j]. + else if (temp <= a[j]) + { + a[j/2] = a[j]; + j = 2*j; + } + } + a[j/2] = temp; + return; +} +void HeapSort(int a[], int n) +{ + int i, temp; + for (i = n; i >= 2; i--) + { + // Storing maximum value at the end. + temp = a[i]; + a[i] = a[1]; + a[1] = temp; + // Building max heap of remaining element. + MaxHeapify(a, 1, i - 1); + } +} +void Build_MaxHeap(int a[], int n) +{ + int i; + for(i = n/2; i >= 1; i--) + MaxHeapify(a, i, n); +} +int main() +{ + int n, i; + cout<<"\nEnter the number of data element to be sorted: "; + cin>>n; + n++; + int arr[n]; + for(i = 1; i < n; i++) + { + cout<<"Enter element "<>arr[i]; + } + // Building max heap. + Build_MaxHeap(arr, n-1); + HeapSort(arr, n-1); + + // Printing the sorted data. + cout<<"\nSorted Data "; + + for (i = 1; i < n; i++) + cout<<"->"< Date: Tue, 4 Oct 2022 18:10:32 +0530 Subject: [PATCH 17/48] Alternate element swap of an array --- AlternateSwap.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 AlternateSwap.cpp diff --git a/AlternateSwap.cpp b/AlternateSwap.cpp new file mode 100644 index 0000000..52a3211 --- /dev/null +++ b/AlternateSwap.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; + +void swapAlternate(int arr[], int size) +{ + for (int i = 0; i < size; i += 2) + { + if (i + 1 < size) + { + swap(arr[i], arr[i + 1]); + } + } +} + +void printArray(int arr[], int n) +{ + for (int i = 0; i < n; i++) + { + cout << arr[i] << " "; + } + cout << endl; +} + +int main() +{ + int arr[8] = {1, 3, 5, 7, 9, 2, 6, 0}; + int brr[5] = {1, 3, 5, 7, 9}; + + swapAlternate(arr, 8); + printArray(arr, 8); + + swapAlternate(brr, 5); + printArray(brr, 5); + return 0; +} \ No newline at end of file From 2b77079e9843e9be4d9b93520b9e77bd5186d945 Mon Sep 17 00:00:00 2001 From: Vishal35679 <104795331+Vishal35679@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:11:29 +0530 Subject: [PATCH 18/48] Simple atm program using switch --- atm.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 atm.c diff --git a/atm.c b/atm.c new file mode 100644 index 0000000..9fbf149 --- /dev/null +++ b/atm.c @@ -0,0 +1,84 @@ +#include +#include + +int currentbal,initialbal,withdraw,deposit,choice,i,pin; +float principal, t, rate, SI; +char transaction ='y'; + +int main() +{ + while (pin != 3579) +{ + printf("ENTER YOUR PIN NUMBER: "); + scanf("%d", &pin); + if (pin != 3579) + printf("PLEASE ENTER VALID PASSWORD\n"); +} + +printf("Enter initial balance:\n"); +scanf("%d",&initialbal); +do{ + printf("Select your choice:"); + printf("*********Welcome to ATM Service*********\n"); + printf("1. Check Balance\n"); + printf("2. Deposit Cash\n"); + printf("3. Withdraw Cash\n"); + printf("4. View previous transaction\n"); + printf("5. Calculate interest accrued in the account\n"); + printf("6. Exit the application\n"); + printf("Enter your choice: \n"); + scanf("%d", &choice); + +switch(choice) +{ + case 1: + printf("The current balance is Rs.%d", currentbal ); + break; + + case 2: + printf("Enter the amount to deposit in the account: \n"); + scanf("%d", &deposit); + currentbal = initialbal + deposit; + break; + + case 3: + printf("Enter the amount to withdraw from the account: \n"); + scanf("%d", &withdraw); + currentbal = currentbal - withdraw; + break; + + case 4: + if(currentbal>initialbal) + printf("The overall deposit is made of Rs. %d\n", currentbal - initialbal); + else + printf("The overall withdrawal is made of Rs. %d\n", initialbal - currentbal); + break; + + case 5: + printf("Enter the principal amount: "); + scanf("%f", &principal); + printf("Enter the time period: "); + scanf("%f", &t); + printf("Enter the rate of interest: "); + scanf("%f", &rate); + SI = (principal * t * rate) / 100; + printf("Simple Interest for Principal Amount %.2f is %.2f", principal, SI); + break; + + case 6: + printf("Exiting Program\n"); + break; + + default: + printf("\n INVALID CHOICE"); +} + +printf("\n\n\n DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): "); +fflush(stdin); +scanf("%c", &transaction); +if (transaction == 'n'|| transaction == 'N') +i = 0; +} while (!i); + +printf("\n\n THANKS FOR USING OUR ATM SERVICE"); +} \ No newline at end of file From c6e1d42c0bc52281ee9204c0e193644b068e9a0d Mon Sep 17 00:00:00 2001 From: Vishal35679 <104795331+Vishal35679@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:12:27 +0530 Subject: [PATCH 19/48] nCr problem --- nCrProblem.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nCrProblem.cpp diff --git a/nCrProblem.cpp b/nCrProblem.cpp new file mode 100644 index 0000000..0e83ad9 --- /dev/null +++ b/nCrProblem.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +int factorial(int n) +{ + int fact=1; + for(int i=1; i<=n; i++) + { + fact = fact * i; + } + return fact; +} + +int nCr(int n, int r) +{ + int num=factorial(n); + int den= factorial(r) * factorial(n-r); + int ans = num/den; + return ans; + +} + +int main() +{ + int n,r; + cin >> n >> r; + cout<< nCr(n,r) << endl; + + return 0; +} \ No newline at end of file From eeeff2e8b913323af90f57e6822d4afe228d6c8b Mon Sep 17 00:00:00 2001 From: Vishal35679 <104795331+Vishal35679@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:13:54 +0530 Subject: [PATCH 20/48] Decimal to Binary conversion code --- DecToBin.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 DecToBin.cpp diff --git a/DecToBin.cpp b/DecToBin.cpp new file mode 100644 index 0000000..81f6798 --- /dev/null +++ b/DecToBin.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + int ans=1; //0 to run in online compiler + int i=0; + while(n!=0) + { + int bit = n & 1; + ans = (bit * pow(10,i)) + ans; + n = n >> 1; + i++; + } + cout<< "Answer is " << ans < Date: Tue, 4 Oct 2022 18:14:27 +0530 Subject: [PATCH 21/48] Binary to Decimal Conversion code --- BinToDec.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 BinToDec.cpp diff --git a/BinToDec.cpp b/BinToDec.cpp new file mode 100644 index 0000000..e1d6475 --- /dev/null +++ b/BinToDec.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + int ans=0; + int i=0; + while(n!=0) + { + int bit = n%10; + n/=10; + ans = (bit * pow(2,i)) + ans; + i++; + } + cout<< "Answer is " << ans < Date: Tue, 4 Oct 2022 18:39:35 +0530 Subject: [PATCH 22/48] added selection sort --- selection_sort.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 selection_sort.cpp diff --git a/selection_sort.cpp b/selection_sort.cpp new file mode 100644 index 0000000..4e5eba9 --- /dev/null +++ b/selection_sort.cpp @@ -0,0 +1,76 @@ +/* +Algorithm +Step 1 − Set MIN to location 0 +Step 2 − Search the minimum element in the list +Step 3 − Swap with value at location MIN +Step 4 − Increment MIN to point to next element +Step 5 − Repeat until list is sorted + +Pseudocode +procedure selection sort + list : array of items + n : size of list + + for i = 1 to n - 1 + set current element as minimum + min = i + + check the element to be minimum + + for j = i+1 to n + if list[j] < list[min] then + min = j; + end if + end for + + swap the minimum element with the current element + if indexMin != i then + swap list[min] and list[i] + end if + end for + +end procedure + +Time Complexity = O(n^2); +Space Complexity = O(1); +*/ + +#include +using namespace std; + +void readArray(int array[], int size){ + for(int i = 0 ; i < size; i++){ + cin >> array[i]; + } +} + +void printArray(int array[], int size){ + for(int i = 0 ; i < size; i++){ + cout << array[i] << " "; + } +} + +void selectionSort(int array[], int size){ + for(int i = 0; i < size - 1; i++){ + int minIndex = i; + + for(int j = i + 1; j < size; j++){ + if(array[j] < array[minIndex]){ + minIndex = j; + } + } + swap(array[minIndex], array[i]); + } +} + +int main(){ + int size; + cin >> size; + int array[size]; + cout << "Enter the Elements of the Array. " << endl; + readArray(array, size); + selectionSort(array, size); + printArray(array, size); + + +} \ No newline at end of file From 78ed0704461f02e333d34cebb5ceeb80363b6f81 Mon Sep 17 00:00:00 2001 From: Kamana54855 <114852248+Kamana54855@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:44:44 +0530 Subject: [PATCH 23/48] Add files via upload --- fibonacci.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 fibonacci.java diff --git a/fibonacci.java b/fibonacci.java new file mode 100644 index 0000000..c05978e --- /dev/null +++ b/fibonacci.java @@ -0,0 +1,44 @@ +// Program to print fibonacci series followed by giver number by user... + +import java.util.Scanner; + +public class fibonacci { + + static int fib(int no) + { + if(no <= 1) { + return no; + } + else { + return fib(no - 1) + fib(no - 2); + } + + } + + //-------------------MAIN------------------------ + + public static void main(String[] args) { + + Scanner inp = new Scanner(System.in); + + while(true){ + + System.out.print("Enter Number : "); + int no = inp.nextInt(); + int stop = 000; + if(no == stop) { // If user enter 000 process will stop.. + break; + } + else { + for (int i = 0; i < no; i++) { + System.out.print(fib(i) + " "); + } + System.out.println(" "); + } + } + + } +} + + +//exit is a string , but we are taking input as integer ( int no = inp.nextInt(); ) , how to break while loop ? From ba68ec69b785a501d6f6f1636d1d670481e22908 Mon Sep 17 00:00:00 2001 From: kiranmayek Date: Tue, 4 Oct 2022 18:57:30 +0530 Subject: [PATCH 24/48] added binary search and counting frequency of each element in array using c++ --- binary_search.cpp | 41 ++++++++++++++++++++ count_frequency_of_each_element_in_array.cpp | 32 +++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 binary_search.cpp create mode 100644 count_frequency_of_each_element_in_array.cpp diff --git a/binary_search.cpp b/binary_search.cpp new file mode 100644 index 0000000..4ccae5d --- /dev/null +++ b/binary_search.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; + +int BinarySearch(int n, int search, int arr[]) +{ + int s = 0; + int e = n; + int mid = (s + e) / 2; + while (s <= e) + { + if (arr[mid] == search) + { + return mid; + } + else if (arr[mid] < search) + { + s = mid + 1; + } + else{ + e=mid-1; + } + } + return -1; +} + +int main() +{ + int n; + cin >> n; + int arr[n]; + for (int i = 0; i < n; i++) + { + cin >> arr[i]; + } + + int number; + cin >> number; + cout << BinarySearch(n, number, arr); + + return 0; +} \ No newline at end of file diff --git a/count_frequency_of_each_element_in_array.cpp b/count_frequency_of_each_element_in_array.cpp new file mode 100644 index 0000000..7b2f640 --- /dev/null +++ b/count_frequency_of_each_element_in_array.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; + +void countFreq(int arr[], int n) +{ + vector visited(n, false); + + for (int i = 0; i < n; i++) { + + // Skip this element if already processed + if (visited[i] == true) + continue; + + // Count frequency + int count = 1; + for (int j = i + 1; j < n; j++) { + if (arr[i] == arr[j]) { + visited[j] = true; + count++; + } + } + cout << arr[i] << " " << count << endl; + } +} + +int main() +{ + int arr[] = {10,5,10,15,10,5}; + int n = sizeof(arr) / sizeof(arr[0]); + countFreq(arr, n); + return 0; +} \ No newline at end of file From d08c184a1966612439213edb06212555cae78a94 Mon Sep 17 00:00:00 2001 From: palak Date: Tue, 4 Oct 2022 19:15:57 +0530 Subject: [PATCH 25/48] added bfs and dfs in C --- BreadthFirstSearch.c | 37 +++++++++++++++++++++++++++++++++++++ DepthFirstSearch.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 BreadthFirstSearch.c create mode 100644 DepthFirstSearch.c diff --git a/BreadthFirstSearch.c b/BreadthFirstSearch.c new file mode 100644 index 0000000..cdd3f72 --- /dev/null +++ b/BreadthFirstSearch.c @@ -0,0 +1,37 @@ +#include +void BFS(int a[10][10], int n, int src, int s[10]) +{ + int f = 0, r = -1, q[20], i, v; + printf("Source Node: %d\n", src); + s[src] = 1; + q[++r] = src; + printf("Visited Nodes using BFS:\n"); + while (f <= r) + { + v = q[f++]; + for (i = 1; i <= n; i++) + if (s[i] == 0 && a[v][i]) + { + q[++r] = i; + printf("%d\t", i); + s[i] = 1; + } + } +} +int main() +{ + int a[10][10], n, i, j, s[20], src; + printf("Enter no. of Nodes in Graph\n"); + scanf("%d", &n); + printf("Enter the connections of Graph in Adjacency Matrix\n"); + for (i = 1; i <= n; i++) + for (j = 1; j <= n; j++) + scanf("%d", &a[i][j]); + printf("Enter the Source Node\n"); + scanf("%d", &src); + for (i = 1; i <= n; i++) + s[i] = 0; + BFS(a, n, src, s); + printf("\n"); + return 0; +} diff --git a/DepthFirstSearch.c b/DepthFirstSearch.c new file mode 100644 index 0000000..0bde005 --- /dev/null +++ b/DepthFirstSearch.c @@ -0,0 +1,29 @@ +#include +void DFS(int a[10][10], int n, int src, int s[10]) +{ + int i; + s[src] = 1; + printf("%d\t", src); + for (i = 1; i <= n; i++) + if (s[i] == 0 && a[src][i]) + DFS(a, n, i, s); +} +int main() +{ + int a[10][10], n, i, j, s[20], src; + printf("Enter no. of Nodes in Graph\n"); + scanf("%d", &n); + printf("Enter the connections of Graph in Adjacency Matrix\n"); + for (i = 1; i <= n; i++) + for (j = 1; j <= n; j++) + scanf("%d", &a[i][j]); + printf("Enter the Source Node\n"); + scanf("%d", &src); + printf("Source Node = %d\n", src); + for (i = 1; i <= n; i++) + s[i] = 0; + printf("Visited Nodes using DFS:\n"); + DFS(a, n, src, s); + printf("\n"); + return 0; +} \ No newline at end of file From 307a46ae2842a761995cd3d1787c06dbef80fc68 Mon Sep 17 00:00:00 2001 From: Sumit Date: Tue, 4 Oct 2022 19:42:25 +0530 Subject: [PATCH 26/48] My Commit --- decimaltobinary.c | 29 +++++++++++++++++++++++++++++ decimaltobinary.exe | Bin 0 -> 41446 bytes 2 files changed, 29 insertions(+) create mode 100644 decimaltobinary.c create mode 100644 decimaltobinary.exe diff --git a/decimaltobinary.c b/decimaltobinary.c new file mode 100644 index 0000000..e1c082f --- /dev/null +++ b/decimaltobinary.c @@ -0,0 +1,29 @@ +#include +#include + +int main(){ + + int decimal_num,remainder,binary_num=0; + int i = 0; + + + + printf("\n Enter The Decimal No: "); + scanf("%d", &decimal_num); + + + while (decimal_num != 0) + { + remainder= decimal_num%2; + binary_num += remainder*pow(10,i); + decimal_num = decimal_num/2; + i++; +} + + +printf("\n The Binary Equivalent = %d",binary_num); + +return 0; + +} + diff --git a/decimaltobinary.exe b/decimaltobinary.exe new file mode 100644 index 0000000000000000000000000000000000000000..5b794e6e9b086035f2c7679d911e48424c2f2bd4 GIT binary patch literal 41446 zcmeIb3w%`7wLiYkJd%NgoCJcRMjdESPzVG8(S|yc$>bqqhOcQne_K7@3+`0p40^dLL! z`sdQvo(V5c-zSv5JiVs5rQ6xr)v>OtuFcs{*WTVCJL`SUE`PhTrQKOjQSEH&X!PYw znlv$6V_oTGtW=o9{`{4^2G+&cNrAD`ELlhqELkiENX57OFVz3zX>IKs80qxs!1Jxk6KX5SXfQ@a}(n}u$8@XiZee?r|AJI+zq}WvQATulUliBKuD-oU#mmCUvQ;ww%fye`L?a8QAcIpz)`MI* z-}n5DM8EV}UaeZd;v}Hzh2NOXt0mu!Dg_r3f{oW(lOXaXfVOKo&|#v+C%)uwf)CKB zwD4w8m*U;e)e<#KUgA0`@lZ5!*qq0eyiCjc7v%NHH!w~9TIJp9z}d_lyDMF!r7To} z^uYB(CZ-h}9S)pLrFgoFh5L!sSzGut`sNOY%f%F1cKDq%h?fIzvBTNPS>=bWeP*kR z?Mx*EC^O_qC%l_M%u!U>e1ctRhE)>G3Rw6C{Dh`*4(Z{osVMf$x$uQ#T93wQ+%<_&CzeS?OS9-aCGsu%v5S)Xb?X->=k@8ucmopfCZ_779RXKiFcKL%3`jM{nBjGe8j__is)rrN4-hcZZ2oUH+KII?3W z95(AcFK1Amg9vTe`_{Tx^tBz+D5qb(9S}E&!Zy9!=TIt>rxHa4af5zO!}0@X9m;{; zWAX$L5N-4rBJ(prc{NP9&o{d2-ZcZL=8&Drr0WIx8QD5ADOOjCpuT~#({^yd`Z+f) z(C`kb7X(V70{@m5XgfTh;-5JeI6FW5AsmX{ZU`YSS5GrZ{|I~s+RjO40lBsk>>j{I z+CqT--TwEl7lzTqvxk9@eG>O?R%fRpoQ2Tw8~ZNc{|36e10<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d6ANMIq*v5?4Sn6~!BC{Q+GkWf8ao9{px5>P?wAzb| zntZX7N+o;`hjTvSdKT{kbvO}*4#HB^tDT%mV;w&vS3Q}d4S%|Z@=N1Rl%}m?iaV~C+oNtIT7Tg_Qy0T@J}vjS z{AgcJ7ytDIx)+WWp%Y%w5Rk+;l~y$~ogXcuO}B|pvh?hlC~OzwBz(O)sKy5Vfs>7lBk7a zwTSakR9mP>mwQ~dG0tEWJK8tq8ph7exN{lbIgEFjGp}mwjNmcdJl<)mJybR-gSxe$ zZ{*V%aiEKNbMo-IfzcX5mo)LOM2#;c-*~~-s5D{Xe6(E+Ek)}_%uf>koj$?X*$*p($J9Mx9g#)R1f~!laP2;%Ke`!i^nLn+ikB<0bS@1jYBO@I`M1P(O zr|_vGFE2(v1sR`4p`&RtOLRxR?W3zqT|7~jYhK?iug5o+kXZLO>wR7AzE&K?Q3qgr zzlt+Y?O~4YRE@@t7m&*nI}4l}7IX_AoLCo*8auW*)^cVyVrrO1EDE&Ywr0#!h%>wF z%;t;x_jtn!=Qq}qYbG7%aWC(h^}!P(iJ{!sEKQ=SsLl>ErMN{1!SHD|`2@YQX-;&k OrY_r&x#-#+_WuH<$*o%e literal 0 HcmV?d00001 From 207015246418ad0be91dcd19885a3e05b6ea7ed6 Mon Sep 17 00:00:00 2001 From: bilwa496 <66560100+bilwa496@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:01:11 +0530 Subject: [PATCH 27/48] Created longest_palindromic_subsequence.cpp Dynamic Programming based C++ program for LPS problem --- longest_palindromic_subsequence.cpp | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 longest_palindromic_subsequence.cpp diff --git a/longest_palindromic_subsequence.cpp b/longest_palindromic_subsequence.cpp new file mode 100644 index 0000000..2ecc7b4 --- /dev/null +++ b/longest_palindromic_subsequence.cpp @@ -0,0 +1,44 @@ +// A Dynamic Programming based C++ program for LPS problem +// Returns the length of the longest palindromic subsequence in seq +#include +#include + +int max (int x, int y) { return (x > y)? x : y; } + +int lps(char *str) +{ +int n = strlen(str); +int i, j, cl; +int L[n][n]; + + +// Strings of length 1 are palindrome of length 1 +for (i = 0; i < n; i++) + L[i][i] = 1; + + for (cl=2; cl<=n; cl++) + { + for (i=0; i Date: Tue, 4 Oct 2022 20:02:01 +0530 Subject: [PATCH 28/48] Create Hollow_Rectangle_Pattern.cpp --- Hollow_Rectangle_Pattern.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Hollow_Rectangle_Pattern.cpp diff --git a/Hollow_Rectangle_Pattern.cpp b/Hollow_Rectangle_Pattern.cpp new file mode 100644 index 0000000..c91c02f --- /dev/null +++ b/Hollow_Rectangle_Pattern.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; + +int main(){ + + int rows, cols; + // Getting dimensions of rectangle + cout << "Enter the number of rows in rectangle - "; + cin >> rows; + + cout << "Enter the number of columns in rectangle - "; + cin >> cols; + + + cout << "Rectangle of dimensions " << rows << "*" << cols << endl; + + // Main logic to print hollow rectangle. + for( int i = 0; i < rows; i++ ) { + for( int j = 0; j < cols; j++ ){ + + // If the index is at the border, then + // print *. + if( i == 0 || i == rows - 1 || j == 0 || j == cols -1 ) + cout<<"* "; + else + cout<<" "; + } + cout< Date: Tue, 4 Oct 2022 20:08:44 +0530 Subject: [PATCH 29/48] Create Fibonnaci.py --- Fibonnaci.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Fibonnaci.py diff --git a/Fibonnaci.py b/Fibonnaci.py new file mode 100644 index 0000000..fe666f3 --- /dev/null +++ b/Fibonnaci.py @@ -0,0 +1,17 @@ +#Fibonacci series in Python + +def recur_fibo(n): + if n <= 1: + return n + else: + return(recur_fibo(n-1) + recur_fibo(n-2)) + +nterms = 10 + +# checking number is negative or positive if negative then enter positive number and if positive then print series +if nterms <= 0: + print("Plese enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(nterms): + print(recur_fibo(i)) From 226e746c1302b145fe97827da93203ff77bdb041 Mon Sep 17 00:00:00 2001 From: Ayush1347 <75846927+Ayush1347@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:24:14 +0530 Subject: [PATCH 30/48] Create Tower of Hanoi.py --- Tower of Hanoi.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Tower of Hanoi.py diff --git a/Tower of Hanoi.py b/Tower of Hanoi.py new file mode 100644 index 0000000..cbf4246 --- /dev/null +++ b/Tower of Hanoi.py @@ -0,0 +1,14 @@ +#Tower of Hanoi +def tower_of_hanoi(disks, source, auxiliary, target): + if(disks == 1): + print('Move disk 1 from rod {} to rod {}.'.format(source, target)) + return + # function call itself + tower_of_hanoi(disks - 1, source, target, auxiliary) + print('Move disk {} from rod {} to rod {}.'.format(disks, source, target)) + tower_of_hanoi(disks - 1, auxiliary, source, target) + + +disks = int(input('Enter the number of disks: ')) +# We are referring source as A, auxiliary as B, and target as C +tower_of_hanoi(disks, 'A', 'B', 'C') From 68370170942d7fc161d66ab18d8a1cff82296f59 Mon Sep 17 00:00:00 2001 From: borkarSahil Date: Tue, 4 Oct 2022 20:34:15 +0530 Subject: [PATCH 31/48] Reverse the K group in Linked List --- reverseKgrpLinkedList.cpp | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 reverseKgrpLinkedList.cpp diff --git a/reverseKgrpLinkedList.cpp b/reverseKgrpLinkedList.cpp new file mode 100644 index 0000000..d7a5d38 --- /dev/null +++ b/reverseKgrpLinkedList.cpp @@ -0,0 +1,86 @@ +#include +using namespace std ; + +class Node{ + public: + int data; + Node* next; + +// CONSTRUCTOR +Node(int data){ + this -> data = data ; + this -> next = NULL; +} +}; + +void insertAtHead( Node* &head,int data){ + Node* New = new Node(data); + New -> next = head ; + head = New ; +}; + +void print(Node* head){ + Node* New = head ; + while (New != NULL) + { + cout << New -> data << " "; + New = New -> next ; + } + cout << endl ; +}; + +Node* reversekGroup(Node* head,int k){ + + if (head == NULL ) + { + return NULL ; + } + + + Node* forward = NULL ; + Node* prev = NULL ; + Node* current = head ; + int count = 0; + + while (current != NULL && count < k) + { + forward = current -> next ; + current -> next = prev ; + prev = current ; + current = forward ; + count++; + } + + if (forward != NULL ) + { + head -> next = reversekGroup(forward,k); + } + + return prev ; + +}; + +int main(){ + + Node* head = NULL ; + + insertAtHead(head,10); + print(head); + + insertAtHead(head,20); + print(head); + + insertAtHead(head,30); + print(head); + + insertAtHead(head,40); + print(head); + + insertAtHead(head,50); + print(head); +cout << " REVERSE "<> k ; +head = reversekGroup(head,k); +print(head); + return 0; +} \ No newline at end of file From 63158d826c473ba2d3c0f0ce82ad8afb62e07a72 Mon Sep 17 00:00:00 2001 From: Rashmi Kumari <76115061+thakurRashmi@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:13:48 +0530 Subject: [PATCH 32/48] Create BubbleSort_OptimisedCode.cpp This is an optimized code for implementing Bubble Sort in C++ language. The time complexities in the best and worst cases will be O(n) and O(n^2) respectively. --- BubbleSort_OptimisedCode.cpp | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 BubbleSort_OptimisedCode.cpp diff --git a/BubbleSort_OptimisedCode.cpp b/BubbleSort_OptimisedCode.cpp new file mode 100644 index 0000000..ce4b3e5 --- /dev/null +++ b/BubbleSort_OptimisedCode.cpp @@ -0,0 +1,63 @@ +// Optimized implementation of Bubble sort to avoid extra spaces. + +#include +#include +using namespace std; + + +void bubbleSort(int arr[], int n) +{ + int i, j, flag, temp; + + for (i = 0; i < n-1; i++) + { + flag=0; + for (j = 0; j < n-1-i; j++) + { + if (arr[j] > arr[j+1]) + { + temp=arr[j]; + arr[j]=arr[j+1]; + arr[j+1]=temp; + flag=1; + } + } + + // IF no two elements were swapped + // by inner loop, then break + if (flag==0) + break; + } +} + +// Function to print an array +void printArray(int arr[], int size) +{ + for (int i = 0; i < size; i++) + { + cout <<" "<< arr[i]; + } +} + +// Driver program to test above functions +int main() +{ + int n;// size of the array + cout<<"Enter the size of Array"<>n; + + int arr[n]; + cout<<"Enter the elements of the Array"<>arr[i]; + } + + bubbleSort(arr, n); + cout <<"Sorted array: \n"; + printArray(arr, n); + return 0; +} +// Time Complexity: +// Best Case: O(n) +// Worst case: O(n^2) From c6c703d8d99ccb1328d6f1780005202c40c9a07f Mon Sep 17 00:00:00 2001 From: Nishant Rathore <74294802+RinzlerN26@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:23:49 +0530 Subject: [PATCH 33/48] Added Shell Sort Code --- ShellSort.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ShellSort.cpp diff --git a/ShellSort.cpp b/ShellSort.cpp new file mode 100644 index 0000000..7f7df39 --- /dev/null +++ b/ShellSort.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; + +// shell sort implementation +int shellSort(int arr[], int N) +{ + for (int gap = N/2; gap > 0; gap /= 2) + { + for (int i = gap; i < N; i += 1) + { + //sort sub lists created by applying gap +int temp = arr[i]; + +int j; +for (j = i; j >= gap && arr[j - gap] > temp; j -= gap) +arr[j] = arr[j - gap]; + +arr[j] = temp; + } + } + return 0; +} + +int main() +{ + int arr[] = {45,23,53,43,18,24,8,95,101}, i; + //Calculate size of array + int N = sizeof(arr)/sizeof(arr[0]); + + cout << "Array to be sorted: \n"; + for (int i=0; i Date: Tue, 4 Oct 2022 22:44:06 +0530 Subject: [PATCH 34/48] Create generateparantheses.cpp --- generateparantheses.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 generateparantheses.cpp diff --git a/generateparantheses.cpp b/generateparantheses.cpp new file mode 100644 index 0000000..b0af342 --- /dev/null +++ b/generateparantheses.cpp @@ -0,0 +1,42 @@ +/* + +22. Generate Parentheses +Medium +15.4K +588 +Companies +Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. +*/ + +class Solution { +public: + vectorresult; + + void helper(int open,int close,int n,string current) + { + if(current.length()==n*2) + { + result.push_back(current); + return; + } + if(open generateParenthesis(int n) { + helper(0,0,n,""); + return result; + } +}; +// Intuition: Since we are asked to calculate all the possible permutations of brackets , hence we have to use backtracking + +// Concept: In every backtracking problem , there are two things to keep in mind , which we will explore here as well : + +// Base Case: Every problem of backtracking has some base case which tells us at which point we have to stop with the recursion process. In our case, when the length of our string has reached the maximum length(n*2), we stop with the recursion for that case and that is our base case. + +// Conditions: On observing carefully we find that there are two conditions present: + +// For adding (: If number of opening brackets(open) is less than the the given length(n) i.e. +// if max Date: Tue, 4 Oct 2022 22:56:50 +0530 Subject: [PATCH 35/48] Binary search algorithim in C Binary search requires an sorted array, traversing though it, the algorithim finds the matching given element in the array, and returns the index of the element. --- Binary Search | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Binary Search diff --git a/Binary Search b/Binary Search new file mode 100644 index 0000000..97bc87d --- /dev/null +++ b/Binary Search @@ -0,0 +1,31 @@ +//code for binnary search algorithim in C + +#include + +int binarySearch(int arr[], int l, int r, int x) +{ + if (r >= l) { + int mid = l + (r - l) / 2; + + if (arr[mid] == x) + return mid; + + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + return binarySearch(arr, mid + 1, r, x); + } + return -1; +} + +int main(void) +{ + int arr[] = { 2, 3, 4, 10, 40 }; + int n = sizeof(arr) / sizeof(arr[0]); + int x = 10; + int result = binarySearch(arr, 0, n - 1, x); + (result == -1) + ? printf("Element is not present in array") + : printf("Element is present at index %d", result); + return 0; +} From 3f3cc6e08be01baaafbb7163849b8e370fee444b Mon Sep 17 00:00:00 2001 From: Shubham Gaur <94301988+404shubham@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:20:37 +0530 Subject: [PATCH 36/48] Insertion sort algorithims Insertion sort algorithim works by comparing every key to it's predecessor, elements are compared multiple times though the algorithim. --- Insertion Sort | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Insertion Sort diff --git a/Insertion Sort b/Insertion Sort new file mode 100644 index 0000000..1103315 --- /dev/null +++ b/Insertion Sort @@ -0,0 +1,36 @@ +#include +#include + +void insertionSort(int arr[], int n) +{ + int i, key, j; + for (i = 1; i < n; i++) { + key = arr[i]; + j = i - 1; + + while (j >= 0 && arr[j] > key) { + arr[j + 1] = arr[j]; + j = j - 1; + } + arr[j + 1] = key; + } +} + +void printArray(int arr[], int n) +{ + int i; + for (i = 0; i < n; i++) + printf("%d ", arr[i]); + printf("\n"); +} + +int main() +{ + int arr[] = { 12, 11, 13, 5, 6 }; + int n = sizeof(arr) / sizeof(arr[0]); + + insertionSort(arr, n); + printArray(arr, n); + + return 0; +} From 40627b95f04adf24919131768a581dc8ecfb4063 Mon Sep 17 00:00:00 2001 From: Shivam Chopra <60386222+imshivam18@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:34:56 +0530 Subject: [PATCH 37/48] Tower of Hanoi Problem using Recursion in C++ --- TowerogHanoi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 TowerogHanoi diff --git a/TowerogHanoi b/TowerogHanoi new file mode 100644 index 0000000..d123643 --- /dev/null +++ b/TowerogHanoi @@ -0,0 +1,24 @@ +#include +using namespace std; + +// Tower of Hanoi + + void TowerOfHanoi(int n, char source, char destiny, char helper) +{ + if(n==0) + { + return ; + } + + TowerOfHanoi(n-1,source,helper,destiny); + cout << "Moving from " << source << " to " << destiny << endl ; + TowerOfHanoi(n-1,helper,destiny,source); +} + +int main() +{ + int n; + cin >> n; + TowerOfHanoi(n,'A','C','B'); + return 0; +} From 5431089d4998238dce95bd46367429efd9477191 Mon Sep 17 00:00:00 2001 From: shrutij1247 <114980144+shrutij1247@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:36:33 +0530 Subject: [PATCH 38/48] Create Cocktail Sort.cpp --- Cocktail Sort.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Cocktail Sort.cpp diff --git a/Cocktail Sort.cpp b/Cocktail Sort.cpp new file mode 100644 index 0000000..5e39ace --- /dev/null +++ b/Cocktail Sort.cpp @@ -0,0 +1,72 @@ +// C++ implementation of Cocktail Sort +#include +using namespace std; + +// Sorts array a[0..n-1] using Cocktail sort +void CocktailSort(int a[], int n) +{ +bool swapped = true; +int start = 0; +int end = n - 1; + +while (swapped) { +// reset the swapped flag on entering +// the loop, because it might be true from +// a previous iteration. +swapped = false; + +// loop from left to right same as +// the bubble sort +for (int i = start; i < end; ++i) { +if (a[i] > a[i + 1]) { + swap(a[i], a[i + 1]); + swapped = true; +} +} + +// if nothing moved, then array is sorted. +if (!swapped) +break; + +// otherwise, reset the swapped flag so that it +// can be used in the next stage +swapped = false; + +// move the end point back by one, because +// item at the end is in its rightful spot +--end; + +// from right to left, doing the +// same comparison as in the previous stage +for (int i = end - 1; i >= start; --i) { +if (a[i] > a[i + 1]) { + swap(a[i], a[i + 1]); + swapped = true; +} +} + +// increase the starting point, because +// the last stage would have moved the next +// smallest number to its rightful spot. +++start; +} +} + +/* Prints the array */ +void printArray(int a[], int n) +{ +for (int i = 0; i < n; i++) +printf("%d ", a[i]); +printf("\n"); +} + +// Driver code +int main() +{ +int arr[] = { 5, 1, 4, 2, 8, 0, 2 }; +int n = sizeof(arr) / sizeof(arr[0]); +CocktailSort(arr, n); +printf("Sorted array :\n"); +printArray(arr, n); +return 0; +} From 3faeab70510bff78e130b09d954df9812b9b2bd7 Mon Sep 17 00:00:00 2001 From: Shivam Chopra <60386222+imshivam18@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:38:51 +0530 Subject: [PATCH 39/48] Backtracking Problem Rat in Maze using C++ --- Rat in Maze | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Rat in Maze diff --git a/Rat in Maze b/Rat in Maze new file mode 100644 index 0000000..963c73d --- /dev/null +++ b/Rat in Maze @@ -0,0 +1,81 @@ +#include + +using namespace std; + +bool isSafe(int** arr,int x,int y,int n) + { + if(x> n; + + int** arr = new int*[n]; + for(int i=0;i>arr[i][j]; + } + } + + int** solArr = new int*[n]; + for(int i=0;i Date: Wed, 5 Oct 2022 00:21:29 +0530 Subject: [PATCH 40/48] Create lengthOfLongestSubstring.java --- lengthOfLongestSubstring.java | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lengthOfLongestSubstring.java diff --git a/lengthOfLongestSubstring.java b/lengthOfLongestSubstring.java new file mode 100644 index 0000000..9376bb9 --- /dev/null +++ b/lengthOfLongestSubstring.java @@ -0,0 +1,58 @@ +// Java program to find the length of the +// longest substring without repeating +// characters +import java.io.*; +import java.util.*; + +class sk{ + +// This function returns true if all characters in +// str[i..j] are distinct, otherwise returns false +public static Boolean areDistinct(String str, + int i, int j) +{ + + // Note : Default values in visited are false + boolean[] visited = new boolean[26]; + + for(int k = i; k <= j; k++) + { + if (visited[str.charAt(k) - 'a'] == true) + return false; + + visited[str.charAt(k) - 'a'] = true; + } + return true; +} + +// Returns length of the longest substring +// with all distinct characters. +public static int longestUniqueSubsttr(String str) +{ + int n = str.length(); + + // Result + int res = 0; + + for(int i = 0; i < n; i++) + for(int j = i; j < n; j++) + if (areDistinct(str, i, j)) + res = Math.max(res, j - i + 1); + + return res; +} + +// Driver code +public static void main(String[] args) +{ + String str = "geeksforgeeks"; + System.out.println("The input string is " + str); + + int len = longestUniqueSubsttr(str); + + System.out.println("The length of the longest " + + "non-repeating character " + + "substring is " + len); +} +} + \ No newline at end of file From 6703979e1dd9b9bb2a63793b872f3df5a5d31e30 Mon Sep 17 00:00:00 2001 From: Rashmi Kumari <76115061+thakurRashmi@users.noreply.github.com> Date: Wed, 5 Oct 2022 00:37:23 +0530 Subject: [PATCH 41/48] Create Median_of_TwoSortedArrays_OptimisedCode.cpp This is an implementation of the most efficient approach to finding the median value of two sorted Arrays of different sizes. Time Complexity is O(min(log n1, log n2)) while Space Complexity is O(1). --- Median_of_TwoSortedArrays_OptimisedCode.cpp | 83 +++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Median_of_TwoSortedArrays_OptimisedCode.cpp diff --git a/Median_of_TwoSortedArrays_OptimisedCode.cpp b/Median_of_TwoSortedArrays_OptimisedCode.cpp new file mode 100644 index 0000000..a3c6967 --- /dev/null +++ b/Median_of_TwoSortedArrays_OptimisedCode.cpp @@ -0,0 +1,83 @@ +// Most Optimised and Efficient approach to find the median of Two sorted Arrays of different sizes + +#include +using namespace std; + +// Binary Search Method to find median +double MedianOfSortedArrays(vector& nums1, vector& nums2) +{ + if(nums2.size() < nums1.size()) return MedianOfSortedArrays(nums2,nums1); + // Swapping to make first array i.e. nums1 smaller + + int n1 = nums1.size(); + int n2 = nums2.size(); + + int low = 0; + int high= n1; + + while (low <= high) + { + int cut1 = (low+high) >> 1; // (low+high)/2 + int cut2 = (n1+n2+1) / 2 - cut1; + + int left1=cut1==0 ? INT_MIN : nums1[cut1-1]; + int left2=cut2==0 ? INT_MIN : nums2[cut2-1]; + + int right1=cut1==n1 ? INT_MAX : nums1[cut1]; + int right2=cut2==n2 ? INT_MAX : nums2[cut2]; + + + // if correct partition is done + if (left1<= right2 and left2<=right1) + { + if((n1+n2)%2 ==0 ) return (max(left1,left2)+ min(right1,right2))/2.0; + else return max(left1,left2); + } + else if (left1 > right2) + { + high = cut1-1; + } + else + { + low = cut1 + 1; + } + } + return 0.0; +} + +// Driver code +int main() +{ + cout<<"Enter the size of first array"<>n1; + vector arr1 ; + int a; + cout<<"Enter the elements of First array"<>a; + arr1.push_back(a); + } + + cout<<"Enter the size of second array"<>n2; + vector arr2; + + cout<<"Enter the elements of Second array"<>a; + arr2.push_back(a); + } + + cout << "Median of the two arrays are" << endl; + cout << MedianOfSortedArrays(arr1, arr2); + return 0; + + // Time Complexity: O(min(log n1, log n2)) [Since binary search is being applied on the smaller of the 2 arrays] + // Auxiliary Space: O(1) [ As no extra space is used ] + + +} From 83aed4bc8c2227b7c5e70f6f05578b652c5ca88e Mon Sep 17 00:00:00 2001 From: Rashmi Kumari <76115061+thakurRashmi@users.noreply.github.com> Date: Wed, 5 Oct 2022 01:20:27 +0530 Subject: [PATCH 42/48] Create SumOfElements_between_k1Smallest_and_k2SmallestElements.cpp This is a program implementation to find the sum of elements of the Array between k1 Smallest and k2 Smallest elements in the Array. Time Complexity: O(n logk) + O(n) . [ O(n logk) to find the kth Smallest element and O(n) to find the sum of in between elements in the array] --- ...ween_k1Smallest_and_k2SmallestElements.cpp | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 SumOfElements_between_k1Smallest_and_k2SmallestElements.cpp diff --git a/SumOfElements_between_k1Smallest_and_k2SmallestElements.cpp b/SumOfElements_between_k1Smallest_and_k2SmallestElements.cpp new file mode 100644 index 0000000..bb150af --- /dev/null +++ b/SumOfElements_between_k1Smallest_and_k2SmallestElements.cpp @@ -0,0 +1,52 @@ + +// Program to find the sum of all elements of the array between k1 smallest and k2 smallest element of the Array. + +#include +using namespace std; + +// This function will return the K_th smallest element in the array +int kth_Smallest(int arr[], int k, int size) +{ + priority_queue maxh; // max heap initialisation + for(int i=0; ik) // if the size of the max heap exceeds k , it will remove the top element of the max heap + { + maxh.pop(); + } + } + return maxh.top(); // top element of the max heap will be the k_th smallest element of the array +} + + +// Driver Code +int main() +{ + int k1,k2; + cin>>k1>>k2; + + int n; + cin>>n; + int arr[n]; + for(int i=0; i>arr[i]; + } + + int first = kth_Smallest(arr,k1,n); // k1 smallest element in the array + int second = kth_Smallest(arr,k2,n);// k2 smallest element in the array + int sum=0; + + for(int i=0; ifirst and arr[i] Date: Wed, 5 Oct 2022 01:57:33 +0530 Subject: [PATCH 43/48] Create PeakElement_of_an_Array.cpp This is a program implementation in C++ to find the peak element in an Array. If the array contains more than one peak element then this program will return any of the peak elements present in the Array. Time Complexity: O(log n), where n is the number of elements in the Array. Space Complexity: O(1), as no extra space is used. --- PeakElement_of_an_Array.cpp | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 PeakElement_of_an_Array.cpp diff --git a/PeakElement_of_an_Array.cpp b/PeakElement_of_an_Array.cpp new file mode 100644 index 0000000..83cf0d9 --- /dev/null +++ b/PeakElement_of_an_Array.cpp @@ -0,0 +1,52 @@ +// C++ program to find a peak element in an array using iterative Binary Search + +#include +using namespace std; + +// A binary search based function that returns index of a peak element in an array + +int PeakElement(int arr[], int size) +{ + int start = 0; + int end = size-1; + while(start <= end) + { + // finding mid element + int mid= start + (end - start)/2; + + if(mid>0 and mid arr[mid-1] and arr[mid] >arr[mid+1]) return mid; + else if(arr[mid-1] > arr[mid]) end=mid-1; + else start=mid+1; + } + else if(mid==0) + { + if(arr[0]>arr[1]) return 0; + else return 1; + } + else if(mid == size-1) + { + if(arr[size-1]>arr[size-2]) return size-1; + else return size -2; + } + + } + + return -1; +} + +// Driver Code +int main() +{ + int arr[] = { 10, 20, 15, 2, 23, 90, 67 }; + int N = sizeof(arr) / sizeof(arr[0]); + cout << "Index of a peak point is " << PeakElement(arr, N); + return 0; +} + +/* Time Complexity: O(log n), Where n is the number of elements in the input array +[ In each step our search becomes half,hence we can compare it to Binary search.So, The time complexity is O(log n) ] + + Space Complexity: O(1) [ Since no extra space is required ] + */ From ae25e9dd20db3fb6aa9787de5e7f034f0c9728c0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernardo Date: Tue, 4 Oct 2022 16:55:27 -0400 Subject: [PATCH 44/48] print rax in assembly language --- print_rax.asm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 print_rax.asm diff --git a/print_rax.asm b/print_rax.asm new file mode 100644 index 0000000..719e4f3 --- /dev/null +++ b/print_rax.asm @@ -0,0 +1,44 @@ +section .data +codes: + db '0123456789ABCDEF' + + +section .text +global _start +_start: + ; number 1122... in hexadecimal format + mov rax, 0x1122334455667788 + + mov rdi, 1 + mov rdx, 1 + mov rcx, 64 + ; Each 4 bits should be output as one hexadecimal digit + ; Use shift and bitwise AND to isolate them + ; the result is the offset in 'codes' array +.loop: + push rax + sub rcx, 4 + + ; cl is a register, smallest part of rcx + ; rax -- eax -- ax -- ah + al + ; rcx -- ecx -- cx -- ch + cl + sar rax, cl + + and rax, 0xf + lea rsi, [codes + rax] + mov rax, 1 + + ; syscall leaves rcx and r11 changed + push rcx + syscall + pop rcx + + pop rax + ; test can be used for the fastest 'is it a zero?' check + ; see docs for 'test' command + test rcx, rcx + jnz .loop + + mov rax, 60 ; invoke 'exit' system call + xor rdi, rdi + syscall \ No newline at end of file From 97c1c43564b1395b6a7706a5d05b898c8230fe62 Mon Sep 17 00:00:00 2001 From: Rashmi Kumari <76115061+thakurRashmi@users.noreply.github.com> Date: Wed, 5 Oct 2022 03:07:51 +0530 Subject: [PATCH 45/48] Create Top_k_Frequent_Numbers_InAnArray.cpp This is an implementation program in C++ to print the Top k frequent Numbers in a given array. Time Complexity: O( k logd + d logd) [ To remove the top of the priority queue O(log d) time is required, so if k elements are removed then O(k log d) time is required, and To construct a priority queue with d elements, O(d logd) time is required] Space Complexity: O(d), where d is the count of distinct elements in the Array. --- Top_k_Frequent_Numbers_InAnArray.cpp | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Top_k_Frequent_Numbers_InAnArray.cpp diff --git a/Top_k_Frequent_Numbers_InAnArray.cpp b/Top_k_Frequent_Numbers_InAnArray.cpp new file mode 100644 index 0000000..2694251 --- /dev/null +++ b/Top_k_Frequent_Numbers_InAnArray.cpp @@ -0,0 +1,58 @@ +// C++ Program to print Top k Frequent Numbers in a given Array + +#include +using namespace std; + +void Top_K_FrequentNumbers(int arr[], int n, int k) +{ + priority_queue , vector>, greater< pair> > minh; + unordered_map mp; + for(int i=0; isecond, i->first}); + + if(minh.size()>k) + { + minh.pop(); + } + } + + while(minh.size()>0) + { + cout<>n; + + int k; + cin>>k; + + int arr[n]; + cout<<"Enter the elements of the Array"<>arr[i]; + } + + Top_K_FrequentNumbers(arr,n,k); + + return 0; +} + +/* Time Complexity: O(K logd + d logd) + [ To remove the top of the priority queue O(log d) time is required, so if k elements are removed then O(k log d) time is required, and + To construct a priority queue with d elements, O(d logd) time is required] + + Space Complexity: O(d), where d is the count of distinct elements in the array. + */ From 20406bbefc93e8629e477ec57e028492c7ffd421 Mon Sep 17 00:00:00 2001 From: Akshay Khatter <30326830+akshaykhatter@users.noreply.github.com> Date: Wed, 5 Oct 2022 03:33:15 +0530 Subject: [PATCH 46/48] added balancedParenthesis --- balancedParenthesis.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 balancedParenthesis.cpp diff --git a/balancedParenthesis.cpp b/balancedParenthesis.cpp new file mode 100644 index 0000000..2ef3cd6 --- /dev/null +++ b/balancedParenthesis.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; +int main() +{ +int st[16], i, j, k, temp; +cout<<"enter 5 elements only to sort n:-"; +for (i = 0; i < 5; i++) +{ +cin>>st[i]; +} +for (i = 1; i < 5; i++) +{ +for (j = i; j >= 1; j--) +{ +if (st[j] < st[j-1]) +{ +temp = st[j]; +st[j] = st[j-1]; +st[j-1] = temp; +} +else +break; +} +} +cout<<"sorted array n "< Date: Wed, 5 Oct 2022 13:18:35 +0530 Subject: [PATCH 47/48] added program to sort an input array in wave form --- sort_array_waveform.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 sort_array_waveform.cpp diff --git a/sort_array_waveform.cpp b/sort_array_waveform.cpp new file mode 100644 index 0000000..3179464 --- /dev/null +++ b/sort_array_waveform.cpp @@ -0,0 +1,35 @@ +// program to sort an input array in wave form + +#include +using namespace std; + +void swap(int *x, int *y) +{ + int temp = *x; + *x = *y; + *y = temp; +} + +void sortInWave(int arr[], int n) +{ + + for (int i = 0; i < n; i += 2) + { + + if (i > 0 && arr[i - 1] > arr[i]) + swap(&arr[i], &arr[i - 1]); + + if (i < n - 1 && arr[i] < arr[i + 1]) + swap(&arr[i], &arr[i + 1]); + } +} + +int main() +{ + int arr[] = {10, 90, 49, 2, 1, 5, 23}; + int n = sizeof(arr) / sizeof(arr[0]); + sortInWave(arr, n); + for (int i = 0; i < n; i++) + cout << arr[i] << " "; + return 0; +} From e4570cfb7be05fae42e4acde8a71c61b9a8183cc Mon Sep 17 00:00:00 2001 From: gaurav Date: Wed, 12 Oct 2022 18:37:32 +0530 Subject: [PATCH 48/48] heapSort in python --- heapSort.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 heapSort.py diff --git a/heapSort.py b/heapSort.py new file mode 100644 index 0000000..69a44eb --- /dev/null +++ b/heapSort.py @@ -0,0 +1,61 @@ +# Python program for implementation of heap Sort + +# To heapify subtree rooted at index i. +# n is size of heap + + +def heapify(arr, n, i): + largest = i # Initialize largest as root + l = 2 * i + 1 # left = 2*i + 1 + r = 2 * i + 2 # right = 2*i + 2 + +# See if left child of root exists and is +# greater than root + + if l < n and arr[i] < arr[l]: + largest = l + +# See if right child of root exists and is +# greater than root + + if r < n and arr[largest] < arr[r]: + largest = r + +# Change root, if needed + + if largest != i: + (arr[i], arr[largest]) = (arr[largest], arr[i]) # swap + +# Heapify the root. + + heapify(arr, n, largest) + + +# The main function to sort an array of given size + +def heapSort(arr): + n = len(arr) + +# Build a maxheap. +# Since last parent will be at ((n//2)-1) we can start at that location. + + for i in range(n // 2 - 1, -1, -1): + heapify(arr, n, i) + +# One by one extract elements + + for i in range(n - 1, 0, -1): + (arr[i], arr[0]) = (arr[0], arr[i]) # swap + heapify(arr, i, 0) + + +# Driver code to test above + +arr = [12, 11, 13, 5, 6, 7, ] +heapSort(arr) +n = len(arr) +print('Sorted array is') +for i in range(n): + print(arr[i]) + +# This code is contributed by Gaurav Agarwal