From b696d862465ed421518d199ee5e3b427573ca3d3 Mon Sep 17 00:00:00 2001 From: Tarun Srivastava <120120552+Lord-Morpheus@users.noreply.github.com> Date: Wed, 4 Oct 2023 20:48:37 +0530 Subject: [PATCH] Delete DSA algorithms directory --- .../Two Pointer/Kadane's_Algorithm.cpp | 44 ----------- DSA algorithms/graphs/cyclicity_in_graph.cpp | 77 ------------------- 2 files changed, 121 deletions(-) delete mode 100644 DSA algorithms/Two Pointer/Kadane's_Algorithm.cpp delete mode 100644 DSA algorithms/graphs/cyclicity_in_graph.cpp diff --git a/DSA algorithms/Two Pointer/Kadane's_Algorithm.cpp b/DSA algorithms/Two Pointer/Kadane's_Algorithm.cpp deleted file mode 100644 index 01b7d22..0000000 --- a/DSA algorithms/Two Pointer/Kadane's_Algorithm.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*KADANE'S ALGORITHM for finding maximum possible contiguous subarray sum*/ - -/*Algorithm - 1)initialize an integer(let's say int sum) with minimum value(INT_MIN) - 2)inititalize an integer(let's say int current) with value 0 - 3)iterate over an array(int a[]) - 4)update current=max(a[i],a[i]+current) - 4)if (current>=sum) update sum, make it equal to current - 5)if (current -using namespace std; - - -int maxSubArray(vector nums) { - - int ans=INT_MIN; - int cur=0; - for(int num:nums){ - cur=max(num,cur+num); - if(cur>=ans){ - ans=cur; - } - else{ - continue; - } - } - return ans; -} - -/*TWO POINTER APPROACH comes in play when we want to find the length of max subarray*/ -/* just initialize 3 more integers to save start & end indexes as 0 - update end whenever sum increases - update start whenever sum decreases -} -*/ -int main(){ - vectora={1,-2,-3,4,-1,2,1,-5,4}; - int ans=maxSubArray(a); - cout< -using namespace std; - -int find(int node,vector&parent){ - //finding the parent node - while(parent[node]!=node){ - node=parent[node]; - } - return node; -} - -void Union(int i,int j,vector&parent){ - // union of node, i.e, setting parent as same. - int iroot=find(i,parent); - int jroot=find(j,parent); - if(iroot!=jroot){ - parent[jroot]=iroot; - } -} - -bool dsu(vector>& edges) { - //setting parent of each node - vectorparent(edges.size()+1); - for(int i=0;i>graph={{1,2},{2,3},{3,4},{1,5},{1,4}}; - /* - graph is: - 2--1--5 - | | - 3--4 - */ - bool ans= dsu(graph); - - if(ans)cout<<"graph is cyclic!"<