Skip to main content
edited body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

You are taking an index-based approach to a problem in which there is no use of index at all. In _sort(..), you call list.listIterator(index) every time and it in turn calls findNode(..) which is O(n)\$O(n)\$. This dramatically inscreasesincreases your runtime. I don't see any other reason for the overall O(n^2)\$O(n^2)\$ runtime. Take a look at the classical merge sort for linkedlistslinked lists.

You are taking an index-based approach to a problem in which there is no use of index at all. In _sort(..), you call list.listIterator(index) every time and it in turn calls findNode(..) which is O(n). This dramatically inscreases your runtime. I don't see any other reason for the overall O(n^2) runtime. Take a look at the classical merge sort for linkedlists.

You are taking an index-based approach to a problem in which there is no use of index at all. In _sort(..), you call list.listIterator(index) every time and it in turn calls findNode(..) which is \$O(n)\$. This dramatically increases your runtime. I don't see any other reason for the overall \$O(n^2)\$ runtime. Take a look at the classical merge sort for linked lists.

Source Link
user66619
user66619

You are taking an index-based approach to a problem in which there is no use of index at all. In _sort(..), you call list.listIterator(index) every time and it in turn calls findNode(..) which is O(n). This dramatically inscreases your runtime. I don't see any other reason for the overall O(n^2) runtime. Take a look at the classical merge sort for linkedlists.