1 votes 1 votes Given the following list of numbers: [21, 1, 26, 45, 29, 28, 2, 9, 16, 49, 39, 27, 43, 34, 46, 40] which answer illustrates the list to be sorted after 3 recursive calls to mergesort? [16, 49, 39, 27, 43, 34, 46, 40] [21,1] [21, 1, 26, 45] [21] Algorithms algorithms merge-sort + – Naveen Chowdary 1 asked Jun 24, 2016 • retagged Jun 27, 2022 by makhdoom ghaya Naveen Chowdary 1 4.6k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 5 votes 5 votes when the mergesort firstly runs it breaks the list in two parts part1 = 21, 1, 26, 45, 29, 28, 2, 9 part2 = 16, 49, 39, 27, 43, 34, 46, 40 now first recursive call will take part1 as input and break into again two parts part1.a = 21, 1, 26, 45 part1.b = 29, 28, 2, 9 now second recursive call will take part1.a as input and break into again two parts part1.a.1 = 21, 1 part1.a.2 = 26, 45 now third recursive call will take part1.a.1 as input and break into again two parts part1.a.1.x = 21 part1.a.1.y = 1 so answer is 21 Tauhin Gangwar answered Jun 24, 2016 • edited Jun 26, 2016 by Tauhin Gangwar Tauhin Gangwar comment Share Follow See all 4 Comments See all 4 4 Comments reply ManojK commented Jun 24, 2016 i edited by ManojK Jun 24, 2016 reply Follow Share check ones 21 will be after 3 rd or 4rd recursive call ? 0 votes 0 votes Gaurab Ghosh commented Jun 24, 2016 reply Follow Share Yes ManojK 21 will be after 4th..I think. After third recursive the array to be sorted will be [21,1]. 1 votes 1 votes shivanisrivarshini commented Jun 24, 2016 i edited by shivanisrivarshini Jun 25, 2016 reply Follow Share initially we call mergesort in code then input is21, 1, 26, 45, 29, 28, 2, 9, 16, 49, 39, 27, 43, 34, 46, 40recursive call mergesort (21, 1, 26, 45, 29, 28, 2, 9) ------ 1recursive call mergesort (21, 1, 26, 45) -------- 2recursive call mergesort(21, 1) ------- 3 2 votes 2 votes Arjun commented Jun 25, 2016 reply Follow Share after a call means, the call is completed- so here should be just before 5th recursive call. 1 votes 1 votes Please log in or register to add a comment.
2 votes 2 votes answer is D) Kapil answered Jun 24, 2016 • edited Jun 24, 2016 by Kapil Kapil comment Share Follow See all 3 Comments See all 3 3 Comments reply Arjun commented Jun 24, 2016 reply Follow Share "after 3rd recursive call", 0 votes 0 votes shivanisrivarshini commented Jun 25, 2016 reply Follow Share initially we call mergesort in code then input is21, 1, 26, 45, 29, 28, 2, 9, 16, 49, 39, 27, 43, 34, 46, 40recursive call mergesort (21, 1, 26, 45, 29, 28, 2, 9) ------ 1recursive call mergesort (21, 1, 26, 45) -------- 2recursive call mergesort(21, 1) ------- 3 0 votes 0 votes Salim Ahmed Ali 1 commented Sep 6, 2018 reply Follow Share Oh thanks. Hadn't noticed that. 0 votes 0 votes Please log in or register to add a comment.