template<typename T>
void List<T>::push_back(T data)
{
if (m_Head == nullptr)
m_Head = new Node<T>(data);
else
{
Node<T>* current = m_Head;
while (current->pNext)
current = current->pNext;
current->pNext = new Node<T>(data);
}
}
Why people say that time complexity for adding new element to list is O(1) when here we have to iterate through the list to add new element, so shouldn`t it be O(n)?