From 60a69ecf5821db9336dc9d9b332a7ac7ae7f5117 Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 01:44:53 +0530 Subject: [PATCH 1/7] Update heap_sort.c Added time complexities of functions used. --- sorting/heap_sort.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index d4c2a5636d..b5084cc101 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -1,3 +1,8 @@ +/** + * max_heapify takes O(logn). + * build_maxheap takes O(n). + * heapsort takes O(nlogn) since it requires above mentioned functions. + */ #include <stdio.h> void max_heapify(int *a, int i, int n); From ec8d670aea9ffc7510f64dc2d5d229db2ab57867 Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 04:27:27 +0530 Subject: [PATCH 2/7] Update heap_sort.c --- sorting/heap_sort.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index b5084cc101..ad50107e31 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -8,7 +8,9 @@ void max_heapify(int *a, int i, int n); void heapsort(int *a, int n); void build_maxheap(int *a, int n); - +/** + * max_heapify takes O(logn). + */ void max_heapify(int *a, int i, int n) { int j, temp; @@ -43,7 +45,9 @@ void heapsort(int *a, int n) max_heapify(a, 1, i - 1); } } - +/** + * build_maxheap takes O(n). + */ void build_maxheap(int *a, int n) { int i; From 18ee0c1546bc95e43cad013f0f7f19141de1758f Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 04:27:50 +0530 Subject: [PATCH 3/7] Update heap_sort.c --- sorting/heap_sort.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index ad50107e31..30b2208b08 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -1,8 +1,3 @@ -/** - * max_heapify takes O(logn). - * build_maxheap takes O(n). - * heapsort takes O(nlogn) since it requires above mentioned functions. - */ #include <stdio.h> void max_heapify(int *a, int i, int n); From 8de917de6e1be8aeb1d2d016ce4c0bcd426caa19 Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 04:28:23 +0530 Subject: [PATCH 4/7] Update heap_sort.c --- sorting/heap_sort.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index 30b2208b08..ba3ddb57fb 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -3,6 +3,7 @@ void max_heapify(int *a, int i, int n); void heapsort(int *a, int n); void build_maxheap(int *a, int n); + /** * max_heapify takes O(logn). */ @@ -40,6 +41,7 @@ void heapsort(int *a, int n) max_heapify(a, 1, i - 1); } } + /** * build_maxheap takes O(n). */ From 2ebc98620c4738e8ef1fae1488451f260d2344a5 Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 04:55:51 +0530 Subject: [PATCH 5/7] Update heap_sort.c --- sorting/heap_sort.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index ba3ddb57fb..dc9017368d 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -6,6 +6,10 @@ void build_maxheap(int *a, int n); /** * max_heapify takes O(logn). + * @param a pointer to array a containing heap elements. + * @param i element at which max_heapify needs to be performed. + * @param n where n is number of elemnts in array a. + * @returns void. */ void max_heapify(int *a, int i, int n) { @@ -44,6 +48,9 @@ void heapsort(int *a, int n) /** * build_maxheap takes O(n). + * @param a pointer to array a containing heap elements. + * @param n where n is number of elemnts in array a. + * @returns void. */ void build_maxheap(int *a, int n) { From 43087d6a1350bba79491a20ebc332bc9c3c60f1c Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 05:08:43 +0530 Subject: [PATCH 6/7] Update sorting/heap_sort.c Co-authored-by: David Leal <halfpacho@gmail.com> --- sorting/heap_sort.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index dc9017368d..361aca24ef 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -47,10 +47,10 @@ void heapsort(int *a, int n) } /** - * build_maxheap takes O(n). - * @param a pointer to array a containing heap elements. - * @param n where n is number of elemnts in array a. - * @returns void. + * build_maxheap takes O(n) + * @param a pointer to array a containing heap elements + * @param n where n is number of elemnts in array a + * @returns void */ void build_maxheap(int *a, int n) { From bf408191aea056933ea8f5803c6e49d4958396a1 Mon Sep 17 00:00:00 2001 From: Shezza221b <41204318+Shezza221b@users.noreply.github.com> Date: Thu, 1 Oct 2020 05:13:36 +0530 Subject: [PATCH 7/7] Update sorting/heap_sort.c Co-authored-by: David Leal <halfpacho@gmail.com> --- sorting/heap_sort.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sorting/heap_sort.c b/sorting/heap_sort.c index 361aca24ef..7e2e19f874 100644 --- a/sorting/heap_sort.c +++ b/sorting/heap_sort.c @@ -5,11 +5,11 @@ void heapsort(int *a, int n); void build_maxheap(int *a, int n); /** - * max_heapify takes O(logn). - * @param a pointer to array a containing heap elements. - * @param i element at which max_heapify needs to be performed. - * @param n where n is number of elemnts in array a. - * @returns void. + * max_heapify takes O(logn) + * @param a pointer to array a containing heap elements + * @param i element at which max_heapify needs to be performed + * @param n where n is number of elemnts in array a + * @returns void */ void max_heapify(int *a, int i, int n) {