Skip to content
Advertisement

Tag: complexity-theory

Space complexity in shallow vs deep copy

Consider the problem of merging two sorted linked lists whilst keeping the order. For instance if L1: 1->1->2->4 and L2: 2->3->5 Then the result should be 1->1->2->2->3->4->5. In Elements of Programming Interview, the author presents the following solution in Java, which consists of running through both lists and choosing the smallest value to add to a dummy head: The author

Advertisement