10 Replies - 680 Views - Last Post: 17 November 2010 - 08:36 AM Rate Topic: -----

#1 Guest_asdbabil*


Reputation:

Linked Lists

Posted 16 November 2010 - 06:58 PM

Hi guys,

I was trying to translate this code into plane English so I can figure out the output but I'm getting mixed up. The more I think about it, the more confused I get! I was able to Identify some of it, but it still confuses me... Please help..
list = new nodeType; //create a new node
list->info = 10; //assign 10 to the first node
	
ptr = new nodeType; //create a pointer
ptr->info = 13; //assign 13 to the first node
ptr->link = NULL; // the end of the pointer in null
list->link = ptr; //
	
ptr = new nodeType; //create a pointer
ptr->info = 18; //assign 18 to the first node
ptr->link = list->link;
list->link = ptr;
cout << list->info << " " << ptr->info << " ";
ptr = ptr->link;
cout << ptr->info << endl;



Is This A Good Question/Topic? 0

Replies To: Linked Lists

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Linked Lists

Posted 16 November 2010 - 07:01 PM

Post what you think the plain English explanation of this code is.

We can help put you right where you are wrong.

But we aren't going to do it all for you without you putting in the major effort.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_asdbabil*


Reputation:

Re: Linked Lists

Posted 16 November 2010 - 07:10 PM

View Postjanotte, on 16 November 2010 - 06:01 PM, said:

Post what you think the plain English explanation of this code is.

We can help put you right where you are wrong.

But we aren't going to do it all for you without you putting in the major effort.

I did put some comments and that's what I was able to come up with..so I don't see how you gonna "do it all" for me!!!
Was This Post Helpful? 0

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Linked Lists

Posted 16 November 2010 - 07:16 PM

Yes I saw you made the minor effort.
But those bits are not what the code 'does' now are they?
That's in the bits you've left uncommented.

What confuses you?
What are you unsure about?
What do you want help with?

That's what I was getting at.
The 'major effort' I am talking about is explaining what you are having trouble with beyond "it confuses me".
Was This Post Helpful? 0
  • +
  • -

#5 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: Linked Lists

Posted 16 November 2010 - 07:35 PM

list->link = ptr; //is it assigning the null value to the list->link?
ptr = new nodeType; //a different pointer is created 
ptr->info = 18;     // and 18 is stored in the node the pointer is pointing to? What happened with the first ptr?!

ptr->link = list->link; //what's happening here? 
list->link = ptr;//I guess this is the newer pointer is assigned to list->link?
cout << list->info << " " << ptr->info << " "; //it's outputing the list->info value and the the value of the newer pointer is pointing to?
ptr = ptr->link;//not sure what's happening here!!
cout << ptr->info << endl;//what's is printing this time?


Those are the things I'm not sure about

This post has been edited by asdbabil: 16 November 2010 - 07:41 PM

Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Linked Lists

Posted 16 November 2010 - 07:41 PM

Let's look at one part.

View Postasdbabil, on 17 November 2010 - 11:35 AM, said:

ptr->link = list->link; //what's happening here?

What does "=" mean? It means assignment, doesn't it?
So something is being assigned to something.
Just like
int x = 9;

Agreed?

So assignment always has a left side and a right side.

What's the left side?
What's the right side?

What is being assigned to what?
Was This Post Helpful? 0
  • +
  • -

#7 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: Linked Lists

Posted 16 November 2010 - 07:43 PM

View Postjanotte, on 16 November 2010 - 08:41 PM, said:

Let's look at one part.

View Postasdbabil, on 17 November 2010 - 11:35 AM, said:

ptr->link = list->link; //what's happening here?

What does "=" mean? It means assignment, doesn't it?
So something is being assigned to something.
Just like
int x = 9;

Agreed?

So assignment always has a left side and a right side.

What's the left side?
What's the right side?

What is being assigned to what?


Please don't insult my intelligence by asking me what's right or left.
Don't offer your help if you gonna talk to me that way..and of course the right side is being assigned to the left side.

This post has been edited by asdbabil: 16 November 2010 - 07:45 PM

Was This Post Helpful? -2
  • +
  • -

#8 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Linked Lists

Posted 16 November 2010 - 07:58 PM

View Postasdbabil, on 17 November 2010 - 11:43 AM, said:

Please don't insult my intelligence by asking me what's right or left.

I wasn't doing any such thing but you have certainly shown something very interesting about yourself by choosing to read it that way and react in the way you did.

If you can keep your thinking and reactions at a rational and adult level then this problem is solvable. If you can't then no-one can help you.

So how about a deep breath and stop trying to defend yourself against imaginary attacks and just focus on the problem at hand.

When I said "What is the left side" what I meant was this.
On the left side of the assignment is this code
ptr->link
What does that code represent?

Can you answer that simple, non-insulting, grown-up question with a non-emotional, grown-up answer?

"I don't know" is a fine answer. A childish tantrum is not fine.

This post has been edited by janotte: 16 November 2010 - 07:59 PM

Was This Post Helpful? 1
  • +
  • -

#9 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: Linked Lists

Posted 16 November 2010 - 08:20 PM

View Postjanotte, on 16 November 2010 - 08:58 PM, said:

View Postasdbabil, on 17 November 2010 - 11:43 AM, said:

Please don't insult my intelligence by asking me what's right or left.

I wasn't doing any such thing but you have certainly shown something very interesting about yourself by choosing to read it that way and react in the way you did.

If you can keep your thinking and reactions at a rational and adult level then this problem is solvable. If you can't then no-one can help you.

So how about a deep breath and stop trying to defend yourself against imaginary attacks and just focus on the problem at hand.

When I said "What is the left side" what I meant was this.
On the left side of the assignment is this code
ptr->link
What does that code represent?

Can you answer that simple, non-insulting, grown-up question with a non-emotional, grown-up answer?

"I don't know" is a fine answer. A childish tantrum is not fine.


I posted a question about Linked List and that should trigger something in your head that even though I'm not at an advanced level in c++ but at least I'm at a point beyond asking me questions about where right and left of the statement are. Plus, I did mention that the second statement
list->info = 10; //assign 10 to the first node
is assigning a value. And that's another indication that tells you that I'm aware of the assignment operation. But it looks like you're an arrogant person.
Was This Post Helpful? -2
  • +
  • -

#10 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Linked Lists

Posted 16 November 2010 - 10:16 PM

View Postasdbabil, on 17 November 2010 - 12:20 PM, said:

I'm at a point beyond asking me questions about where right and left of the statement are.

I didn't ask you 'where' they are. I asked you what they are.

If you choose to tell tell the world that you don't know the difference between where and what well that's your choice. I'd suggest you do yourself no favours by doing so.

I have already explained that to you that I was asking you to tell us What does that code represent?. That's exactly what I asked you. You even quoted it back at me so I know you saw it.

When your pathetic tantrum has burned itself out have a read of what I asked you and see if you feel like answering it.

So you don't have to go back up the thread here is the question again
On the left side of the assignment is this code
ptr->link
What does that code represent?

Was This Post Helpful? 1
  • +
  • -

#11 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: Linked Lists

Posted 17 November 2010 - 08:36 AM

View Postjanotte, on 16 November 2010 - 11:16 PM, said:

View Postasdbabil, on 17 November 2010 - 12:20 PM, said:

I'm at a point beyond asking me questions about where right and left of the statement are.

I didn't ask you 'where' they are. I asked you what they are.

If you choose to tell tell the world that you don't know the difference between where and what well that's your choice. I'd suggest you do yourself no favours by doing so.

I have already explained that to you that I was asking you to tell us What does that code represent?. That's exactly what I asked you. You even quoted it back at me so I know you saw it.

When your pathetic tantrum has burned itself out have a read of what I asked you and see if you feel like answering it.

So you don't have to go back up the thread here is the question again
On the left side of the assignment is this code
ptr->link
What does that code represent?


I see how hurtful you are by actually taking the time to format the where and what..Oh I forgot to mention to your pathetic self that I figured out the answer on my own ..so I don't need your worthless help... ..get lost you little childish expert..
Was This Post Helpful? -5
  • +
  • -

Page 1 of 1