Finding the middle element of the list for splitting Merge subroutine to merge two sorted listsįor(Node current = dummyHead a != null & b != null current = current.next ) Return merge(merge_sort(left_head), merge_sort(right_head)) //recurse on that Middle.next = null //split the list into two halfs Node middle = getMiddle(head) //get the middle of the list Wonder why it should be big challenge as it is stated here, here is a straightforward implementation in Java with out any "clever tricks".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |