Query regarding some techniques

talking about linked lists,
stl provides us a number of function we can apply on linked lists, but majority of the questions can’t be solved by the use of stl functions only we had to define our own class and its functions to solve the question but there are some functionalities like sorting a linked list which can be done in a single line using stl but when we are solving the problem using user defined classes and functions then to write a sort function it requires some good effort and time,so is it possible that we first declare a list using stl and add elements in it using pushback or initialisation and then sort it using stl , then after sorting, we will copy the elements of the list in an object of user defined class to make the question easy.

so can this be done i.e copying of elements from list to user defined object.

@Parmeet-Kalsi-1631789033630118 I dont understand why would you resort to copying the entire list in a user defined container in the first place?

that is not true at all. Here on hackerblocks, you are learning how to implement STL methods, so the questions are like that. But most questions will not need you to go to such lengths.

Anything can be done as long as you know how to implement it, but it’d be a waste of space and time. You can make your own functions and use them on STL objects if you want some additional functionality. You dont write your own vector class everytime you need to do something with vectors that is not available in the STL, other data structures are no different.

it is clear now thanks

1 Like