Help me PlZ
1- Write a function noDuplicates that insert an item but before inserting the item it checks whether the item is already in the list. If the item to be inserted is already in the list, the function outputs an appropriate error message.
2- write a function that returns the info of the kth element of the linked list. If no such element exists, output an appropriate message.
by using link list
for the first function i tried this
void linkedListType<Type>::noDuplicates(Type elem)
while (cur !=NULL)
if (cur->info ==elem)
cout<<"Item you are trying to insert is already in the list";
the second function
i didnt understand what they want exactly !!!
i think it's like retrieve function ,but i dont know how to write it by using linked list
It looks like you forgot to initialise cur to the head of the linked list, and then you should break out of the loop once a match is found. You also need to improve your indentation.