if i have a node that had a different number everytime and i want to delete only the nodes that are repeated(which has random numbers in them) and how would i count them to see how many of each i would have.

can i use if statements to count the same numbers and a if statment for the deleting ???

It would be easiest to check the list beginning to end to see if you have the value already, then not make the node if there's already one with that value.

Here is the basic idea behind what you're trying to do:

// Pseudocode
for ( i = first; i != last; i = next ( i ) ) {
  for ( j = next ( i ); j != last; j = next ( j ) ) {
    if ( i == j )
      unlink ( j );
  }
}

However, if your list is sorted then all you have to do is unlink one of two adjacent nodes that match.

Here is the basic idea behind what you're trying to do:

// Pseudocode
for ( i = first; i != last; i = next ( i ) ) {
  for ( j = next ( i ); j != last; j = next ( j ) ) {
    if ( i == j )
      unlink ( j );
  }
}

However, if your list is sorted then all you have to do is unlink one of two adjacent nodes that match.

but lets say that there is 10 numbers and they are random everytime would this still work or would i have to do something else.

>but lets say that there is 10 numbers and they are random everytime
You can say that, but you've already said it and I understood you completely the first time.

>would this still work
Yes, what I gave you was an inefficient algorithm that assumes nothing about the input sequence. So it will work with random numbers that potentially have duplicates. But you would have known that if you bothered to work through a sample sequence instead of coming back here to ask us without first thinking for yourself.

>but lets say that there is 10 numbers and they are random everytime
You can say that, but you've already said it and I understood you completely the first time.

>would this still work
Yes, what I gave you was an inefficient algorithm that assumes nothing about the input sequence. So it will work with random numbers that potentially have duplicates. But you would have known that if you bothered to work through a sample sequence instead of coming back here to ask us without first thinking for yourself.

yes i understand what u mean about tryng it buut i did and i dont know what to plugg into those variables that you did .. if you could please help

I already gave you code for a linked list that gives you more than enough information to translate the pseudocode into valid C++. You won't learn anything if I just do it for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.