- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Wave)
I want to write an algorithm, that merges two unsorted lists and returns a pointer to the first list, that should then contain both the elements of the first and the second list.
The algorithm should have a constant time complexity.
To do that, shouldn't we traverse the first list and then make the pointer of the last element to show to the first element of the second list? But wouldn't the complexity be, in this case, $O(n)$ ?
How could we merge two unsorted lists with a constant time complexity? (Worried)
I want to write an algorithm, that merges two unsorted lists and returns a pointer to the first list, that should then contain both the elements of the first and the second list.
The algorithm should have a constant time complexity.
To do that, shouldn't we traverse the first list and then make the pointer of the last element to show to the first element of the second list? But wouldn't the complexity be, in this case, $O(n)$ ?
How could we merge two unsorted lists with a constant time complexity? (Worried)