Write a method called doubleList that doubles the size of a list by appending a copy of

Question:

Write a method called doubleList that doubles the size of a list by appending a copy of the original sequence to the end of the list. For example, if a variable list stores the values [1, 3, 2, 7] and we make the call of list.doubleList(); then after the call it should store [1, 3, 2, 7, 1, 3, 2, 7] . Notice that the list has been doubled in size by having the original sequence appear twice in a row. You may not make assumptions about how many elements are in the list. You may not call any methods of the class to solve this problem. If the original list contains N nodes, then you should construct exactly N nodes to be added. You may not use any auxiliary data structures such as arrays or ArrayLists to solve this problem. Your method should run in O(N) time where N is the number of nodes in the list.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: