From ccdc7a974edf3a3720f06caab2ca360e63a375c1 Mon Sep 17 00:00:00 2001 From: aparnagopalakrishnan432 Date: Tue, 20 Oct 2020 15:54:04 +0530 Subject: [PATCH 1/4] shortest job first scheduling added --- scheduling/shortest_job_first.c | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 scheduling/shortest_job_first.c diff --git a/scheduling/shortest_job_first.c b/scheduling/shortest_job_first.c new file mode 100644 index 0000000000..50957a91d6 --- /dev/null +++ b/scheduling/shortest_job_first.c @@ -0,0 +1,92 @@ +/*Program for Shortest Job First Scheduling*/ +#include +#include + +/*function to swap two pointers*/ +void swap(int* a, int* b) +{ + int temp=*a; + *a=*b; + *b=temp; + +} + +/*function to sort burst time and process numbers arrays based on burst times using selection sort*/ +void burst_sort(int* burst,int* p_no,int n) +{ + int pos; + for(int i=0;i Date: Tue, 27 Oct 2020 12:31:03 +0530 Subject: [PATCH 2/4] =?UTF-8?q?=C2=96feat:=20added=20leaf=20count=20in=20b?= =?UTF-8?q?inary=20search=20tree=20algorithm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary_trees/binary_search_tree.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/data_structures/binary_trees/binary_search_tree.c b/data_structures/binary_trees/binary_search_tree.c index 9af1d5fa01..a4c2c41412 100644 --- a/data_structures/binary_trees/binary_search_tree.c +++ b/data_structures/binary_trees/binary_search_tree.c @@ -244,6 +244,25 @@ void inOrder(node *root) inOrder(root->right); } } +/** Recursive utilitary procedure to find number of leaf nodes of the binary tree + * @param root pointer to parent node + * @returns 1 if node is a leaf + * @returns sum of number of leaves in left and right branches + * @returns 0 if tree is empty + */ +int leafcount(node *root) + { + int l,r; + if(root!=NULL) + { + if((root->left==NULL)&&(root->right==NULL)) + return 1; + l=leafcount(root->left); + r=leafcount(root->right); + return(l+r); + } + return 0; + } /** Main funcion */ int main() @@ -259,7 +278,7 @@ int main() { printf( "\n\n[1] Insert Node\n[2] Delete Node\n[3] Find a Node\n[4] Get " - "current Height\n[5] Print Tree in Crescent Order\n[0] Quit\n"); + "current Height\n[5] Print Tree in Crescent Order\n[6] Number of leaf nodes\n[0] Quit\n"); scanf("%d", &opt); // reads the choice of the user // processes the choice @@ -298,6 +317,9 @@ int main() case 5: inOrder(root); break; + case 6: + printf("The number of leaf nodes in the tree is: %d\n", leafcount(root)); + break; } } From 88758075f315b25430154c3b2650912bb50a24fb Mon Sep 17 00:00:00 2001 From: aparnagopalakrishnan432 Date: Tue, 27 Oct 2020 12:35:34 +0530 Subject: [PATCH 3/4] =?UTF-8?q?=C2=83=C2=96=C2=96=C2=96feat:=20added=20lea?= =?UTF-8?q?f=20count=20in=20binary=20search=20tree=20algori?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scheduling/shortest_job_first.c | 92 --------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 scheduling/shortest_job_first.c diff --git a/scheduling/shortest_job_first.c b/scheduling/shortest_job_first.c deleted file mode 100644 index 50957a91d6..0000000000 --- a/scheduling/shortest_job_first.c +++ /dev/null @@ -1,92 +0,0 @@ -/*Program for Shortest Job First Scheduling*/ -#include -#include - -/*function to swap two pointers*/ -void swap(int* a, int* b) -{ - int temp=*a; - *a=*b; - *b=temp; - -} - -/*function to sort burst time and process numbers arrays based on burst times using selection sort*/ -void burst_sort(int* burst,int* p_no,int n) -{ - int pos; - for(int i=0;i Date: Tue, 27 Oct 2020 12:37:20 +0530 Subject: [PATCH 4/4] =?UTF-8?q?=C2=83=C2=96=C2=96=C2=96feat:=20added=20lea?= =?UTF-8?q?f=20count=20in=20binary=20search=20tree=20algorithm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_structures/binary_trees/binary_search_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/binary_trees/binary_search_tree.c b/data_structures/binary_trees/binary_search_tree.c index a4c2c41412..b6de148735 100644 --- a/data_structures/binary_trees/binary_search_tree.c +++ b/data_structures/binary_trees/binary_search_tree.c @@ -264,7 +264,7 @@ int leafcount(node *root) return 0; } -/** Main funcion */ +/** Main function */ int main() { // this reference don't change.