• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding to the head of a link list  RSS feed

 
Aron Silvester
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just need to verify something. The insert at head method will insert values to the left of the list? I ran my addToHead() method and this is what I have below.

run:
TESTING addToHead()

Adding 23, 24, and 25 in the list

The list contains: 25, 24, 23
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Left" doesn't make sense in terms of a linked list. It should add the value to the beginning of the list.
 
Aron Silvester
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:"Left" doesn't make sense in terms of a linked list. It should add the value to the beginning of the list.


So what I have shown is correct I assume?
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only if you print the list head left tail right. But then yes.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!