Click to See Complete Forum and Search --> : Linked List
Mike Middendorf
March 30th, 1999, 02:01 AM
I need help. My C++ prof is terrible. He has taught us the ideas of how
pointers and structs are used in a linked list and how it works, but he has
shown us the code of how to create a linked list from the pointers and structs.
I would be very appreciatve if some one could show me an example of this being
done.
Sincerely,
Mike Middendorf.
Franky Braem
March 30th, 1999, 02:20 AM
class Node
{
Node() { pNext = NULL; pPrev = NULL; }
Node *pNext;
Node *pPrev;
void AddNode (Node *);
};
Node::AddNode(Node *pNode)
{
pNode->pPrev = this;
if ( this->pNext )
this->pNext->pPrev = pNode;
this->pNext = pNode;
}
This code inserts a node in the list.
pNode->pPrev must point to the current node(=this).
If the current node has a next node then the next node previous becomes the new node.
this->pNext must point to the new node.
Yossi Admon
February 27th, 2000, 09:44 AM
You can see a very good example of implementing a link list in the MFC code under list.
Jase
March 3rd, 2000, 04:40 PM
Mike --
I was in your shoes last semester... I wouldn't mind at all helping you, and I think I could explain it better than the previous posts (possibly overly complicated) if you would give me some more info on how much you know.
==Jason==
Paul McKenzie
March 3rd, 2000, 06:00 PM
Sorry, but I felt that the professor needed to be defended here.
I have to respond to this:
I need help. My C++ prof is terrible. He has taught us the ideas of how pointers and structs are used in a linked list and how it works, ...
This is not an indication that the person is a terrible professor. You say that he has taught you the idea of how pointers and structures are used in a linked list and how they work. What else do you want? I'm surprised that your textbook(s) do not have examples of linked lists. I'm giving the professor the benefit of the doubt, and assuming that he/she has faith that you did study from the textbook that was assigned.
Regards,
Paul McKenzie (adjunct Comp Sci. professor)
Anish Mistry
March 3rd, 2000, 06:39 PM
I would have to agree with Paul here, because from what you said your proffeser explained everything he should have. From my experience with Linked-lists it was much easier to grasp if I see a picture of what was going on in memory.
Here is a link that I found with a diagram->http://www.sob.cencol.on.ca/faculty/bleibel/cedp918/ch6.htm
Anish Mistry
"The seeds of the future lie buried in the past."
--The Oracle
http://am-productions.8m.com/
amistry@am-productions.8m.com
Jase
March 4th, 2000, 05:09 PM
Although this is off-topic, I do feel it is worth
the time to discuss it, since I am a Comp. Sci.
student on the other side of the fence...
>What else do you want? I'm surprised that your
>textbook(s) do not have examples of linked
>lists.
I first want to assume that the comment the
student made about the absence of examples was
true. Having had one of the best professors in
existence (in my limited scope of experience)
last semester for my CS class, I know that
the examples out of the book are never enough.
It is much easier to learn by example from the
mouth of a down-to-earth human being who is
willing to level with you. If texts books were
sufficient, what would we need professors for?
If either you, Mike's professor, or any other
professor choose to leave this out of their
teaching agenda, I seriously question either
your credibility or theirs as a professor. I
believe this is what Mike meant (although
possibly exaggerated as a result of reasonable
frustration) when he called his professor
"terrible" one year ago. Thank you.
Jason
Jase
March 4th, 2000, 05:29 PM
A quick reply:
>from what you said your proffeser explained
>everything he should have
I would like to make two corrections on this
comment, one more nit-picky than the other
(again, this is assuming what the student said
is true):
1) "proffeser" is actually spelled "professor"
2) the professor explained everything he was
required to. That's the problem with many
professors in my experience (see post in reply to
Paul). Very few professors are willing to go
that extra mile.
Jason
Sam Hobbs
March 4th, 2000, 05:30 PM
I must say that I have learned most everything I know about C, C++ and Windows from Microsoft documentation. It can be very frustrating sometimes but I do it. I have never had a professor or any other such teacher teach me. I do agree though that for those trying to learn from a teacher there are some teachers that are more likely to confuse students than teach students.
This forum always has plenty of examples of people asking for help with problems that, if they were my problems, I would get answers to on my own. Some of the answers asked for here are very easy to find.
Something that probably does not apply to the situation in the original post, but I would like to throw in anyway, is that if a student expects to be taught everything, they will always be unsatisfied.
Jase
March 4th, 2000, 06:05 PM
>if a student expects to be taught everything,
>they will always be unsatisfied.
Although you did explicitly mention that this may not pertain to the original post, I want to mention that although this is true, it in fact does not pertain to the original post in that (in my opinion again) what the student wanted from his professor was far too elementary to be left out. I do want to agree with you regarding the comment about the simplicity of a lot of questions in this forum, especially considering it is on a website called codeguru.developer.com! The way people perform best when learning is not limited in the least, and although you may have been able to learn well out of the book (even if it did involve frustration), that frustration may have a greater load bearing on another student who will not perform as well under the same conditions. Good discussion!
Jason
Paul McKenzie
March 4th, 2000, 11:01 PM
And what is the reason why you rated a post negatively?? The posting concept for CodeGuru is not meant for you to take out your own frustrations on perfectly valid posts that share a different opinion than yours. If you need to know what type of teacher I am, an example is the number of answers that I've given on CodeGuru (close to 1000).
"If either you, Mike's professor, or any other professor choose to leave this out of their teaching agenda, I seriously question either your credibility or theirs as a professor"
Was this attempt of a personal attack out of frustration?
Regards,
Paul McKenzie
sally
March 5th, 2000, 03:15 AM
It is good to know as an intellectual excersice, but in real life in C++, iy is better to use std::list<> from the Standard Template Library (STL). It is very easy to use, it is fast and a standard part of C++. LIfe can't get much easier than STL.
Sally
Sally
March 5th, 2000, 03:15 AM
It is good to know as an intellectual excersice, but in real life in C++, iy is better to use std::list<> from the Standard Template Library (STL). It is very easy to use, it is fast and a standard part of C++. LIfe can't get much easier than STL.
Sally
Jase
March 5th, 2000, 04:42 PM
Although hypocritical even on my own behalf, I believe this reply is necessary to defend my position:
>And what is the reason why you rated a post negatively??
If you will look at the drop-down list of options to rate a post, you will notice that the choice I made was "-1 : Not useful / wrong / off-topic" I expressed my opinion about the post as being negative in that your response was in no way helpful to the individual in answering his question (off-topic).
>The posting concept for CodeGuru is not meant
>for you to take out your own frustrations on
>perfectly valid posts that share a different
>opinion than yours
If your response to the student was not exactly this, then what was it?
>If you need to know what type of teacher I
>am, an example is the number of answers that
>I've given on CodeGuru (close to 1000).
This has little to do with your ability to teach a class effectively.
>Was this attempt of a personal attack out
>of frustration?
No, it was not an "attack", although it is quite frustrating when you pay so much money and receive a professor that has little knowledge of what good teaching is. This is not to say that you necessarily fall under that category, unless you in fact carry the characteristics I previously outlined as belonging to that category. I do want to end this discussion on this forum specifically, since it is off-topic. If you have a reply, please feel free to write me at my email address directly, minus the "N.O.S.P.A.M" ... thank you.
Jason
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.