My instructor just isn't breaking things down in enough detail and I don't know what to do about it. Trying to ask more questions is like beating a dead horse. There comes a point where there's no point anymore at all.
What I'd like help doing is tracking through, line by line and assignment by...
My instructor just isn't breaking things down in enough detail and I don't know what to do about it. Trying to ask more questions is like beating a dead horse. There comes a point where there's no point anymore at all.
What I'd like help doing is tracking through, line by line and assignment by assignment, what is happening with assignments when we change head to temp and then assign head's pointer to NULL. One distinction I need to pull out of this (or have recognized if you will) is the distinction between the whole struct and a member in the struct when talking about the assigment being made. In the end, another thing is seeing where there is an equivalent way to describe one or more of the assignments that occured.
I attached the file containing the entire example code we were given. I'll use two lines of code from within the function called "void insert(int num)" below.
So, now to try and give a more specific question(s) using two lines of code from our example code (location referenced in the paragraph above).
Quote:
If we say something like:
Head = temp;
Head -> nextPtr = NULL;
When we use "Head" in the first line we are referring to the entire structure right? (That would mean everything in it as well right? The int and the pointer it contains).
[Comment: By that, I meant to say: "hey, lets look at this "whole" in the context of being something that has stuff in it - not just make some generalization about it."]
Then, in the second line, we are referring to just one of the two members in that struct - namely the pointer in it.
[Comment: By this point (the point of considering that second line of code, in addition to the first - yes I'm looking at it as what the two lines are doing, together in my mind now) when I get to that second line, I'm seeing 3 things involved in my picture here, not just two. (1) The whole struct "Head" (2) The whole struct "temp" (3) The member "nextPtr"]
I understand that Head is a *pointer* to memory but there [still] has to be some way to think of the difference between setting values to the entire thing and referring to just a member in it (pointer to memory or not).
[Comment: The paragraph below ties in what I'm more concerned about. I can visualize the differenct between a whole something an a member inside it - I'm not a retard. It's sequentially tracking the assignments being made in the context of what it's being made to (whole or member) and especially what that means/ what it results in. Then it's to see if there is an equivalent way to view it (for instance if the whole "Head" equals the whole "temp" then when we later say "Head -> nextPtr = NULL" isn't that the same as saying "temp -> nextPtr = NULL" because Head was made equal to temp before that? See below...]
It's not just to make that distinction but to grasp it in the context of what is actually happening with the assignments we make. (In the first line Head is being assigned the value of temp (which is itself an instance of this struct), and in the second line, just an element in Head is being assigned the value NULL - but we already assigned Head the value of temp so does that mean it's really the nextPtr in temp that is set to NULL?).
|
Additionally but much lower priority: I know they always say it's not accurate to do this, but if I just had some image of something I already know that I could use to visualize linked lists and structs (linked list AND structs - one involves the other)... Something familiar to attach this new concept to... Some analogy... One that is simple in real life - boxes inside boxes not complicated thinkgs like skyscrapers, etc. You know? A good analogy.