[PR #914] fix: fixed index of parent in sorting/heap_sort_2.c #1443

Closed
opened 2026-01-29 15:20:43 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/TheAlgorithms/C/pull/914

State: closed
Merged: Yes


Fixed index of Parent in heapifyUp process!

parentIndex = [childIndex / 2] for 1-based indexing , but here we are doing the process in 0-based indexing, so the parentIndex should be = [(childIndex - 1) / 2]

References

Checklist

  • Added description of change
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

**Original Pull Request:** https://github.com/TheAlgorithms/C/pull/914 **State:** closed **Merged:** Yes --- #### Fixed index of Parent in heapifyUp process! > **_parentIndex = [childIndex / 2]_** for **_1-based indexing_** , but here we are doing the process in **_0-based indexing_**, so the _**parentIndex**_ should be = _**[(childIndex - 1) / 2]**_ <!-- Thank you for your Pull Request. Please provide a description above and review the requirements below. Contributors guide: https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md --> #### References <!-- Add any reference to previous pull-request or issue --> #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] Added description of change - [x] Relevant documentation/comments is changed or added - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [x] I acknowledge that all my contributions will be made under the project's license. Notes: <!-- Please add a one-line description for developers or pull request viewers --> <a href="https://gitpod.io/#https://github.com/TheAlgorithms/C/pull/914"><img src="https://gitpod.io/button/open-in-gitpod.svg"/></a>
claunia added the pull-request label 2026-01-29 15:20:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#1443