Instantly share code, notes, and snippets.

# mycodeschool

Last active July 10, 2024 16:15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include using namespace std; int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n) { int ans = A[0],sum = 0; for(int i = 1;i < n; ++i) //Check if all are negative ans = max(ans,arr[i]);
Created June 23, 2014 13:47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include using namespace std; int Max_Subarray_Sum(int arr[],int n) { if(n==1) { return arr[0];
Last active October 13, 2023 19:48
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include using namespace std; int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n^2) { int ans = INT_MIN; for(int start_index = 0;start_index < n; ++start_index) //O(n) {
Created June 23, 2014 13:45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include using namespace std; int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n^3) { int ans = INT_MIN; // #include for(int sub_array_size = 1;sub_array_size <= n; ++sub_array_size) //O(n) {
Last active October 13, 2023 19:47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include using namespace std; struct Node { int data; struct Node *next; }; int length(struct Node *head) {
Last active October 29, 2023 09:20
C++ program to find Inorder successor in a BST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* C++ program to find Inorder successor in a BST */ #include using namespace std; struct Node { int data; struct Node *left; struct Node *right; }; //Function to find some data in the tree
Last active May 17, 2024 05:43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* Deleting a node from Binary search tree */ #include using namespace std; struct Node { int data; struct Node *left; struct Node *right; }; //Function to find minimum in a tree. Node* FindMin(Node* root)
Last active May 20, 2024 08:50
Binary tree traversal: Preorder, Inorder, Postorder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* Binary Tree Traversal - Preorder, Inorder, Postorder */ #include using namespace std; struct Node { char data; struct Node *left; struct Node *right; };
Last active July 2, 2024 12:39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* Merge sort in C */ #include #include // Function to Merge Arrays L and R into A. // lefCount = number of elements in L // rightCount = number of elements in R. void Merge(int *A,int *L,int leftCount,int *R,int rightCount) { int i,j,k;
Last active May 19, 2024 03:09
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /* Binary tree - Level Order Traversal */ #include #include using namespace std; struct Node { char data; Node *left; Node *right; };