• (3 Pages)
  • +
  • 1
  • 2
  • 3

Linked List Tutorial Rate Topic: ***** 4 Votes

#31 mike73  Icon User is online

  • D.I.C Addict

Reputation: 161
  • View blog
  • Posts: 625
  • Joined: 24-April 10

Posted 18 May 2014 - 02:51 PM

Edit: I answered my own question by asking it.

Great tutorial!

This post has been edited by mike73: 18 May 2014 - 02:52 PM

Was This Post Helpful? 0
  • +
  • -

#32 mike73  Icon User is online

  • D.I.C Addict

Reputation: 161
  • View blog
  • Posts: 625
  • Joined: 24-April 10

Posted 11 August 2014 - 07:28 AM

1	public void add(E elem){
02	   //if we don't have any elems in our LinkedList
03	   if(head == null){
04	   head = tail = new Node<E>();
05	    head.elem = elem;
06	   head.next = tail;
07	   tail = head;
08	}

Is line 7 here in this case redundant since we have already made this assignment on line 4? Or am I missing something here?
Was This Post Helpful? 0
  • +
  • -

#33 johnf99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-October 13

Posted 11 August 2014 - 09:05 AM

Lines 4 and 7 both leave the nodes head and tail being equal, but the lines between (5 and 6) change the state of one of them (head) leaving them different. So line 7 equates them again.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3