What is the order of inserting an element if the queue is of length n?
Few cases - 1. If it is ordered list, we can apply the binary search and insert an element o(log n). 2. If it is unordered then we can insert at whatever place we want i.e. o(1).
It is of order O(1),when we insert element from rear end.
Can someone help me with algorithm and code?
Result should be stored in new linked list.
Can someone help me with algo and code?