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

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

#31 mike73  Icon User is offline

  • D.I.C Addict

Reputation: 164
  • View blog
  • Posts: 645
  • 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 offline

  • D.I.C Addict

Reputation: 164
  • View blog
  • Posts: 645
  • 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
  • +
  • -

#34 AYOOB12  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 10-December 14

Posted 10 December 2014 - 09:35 AM

hi guys

i did the functions as same and it compiles

but when i test it the program gives me an random output

how can i fix it ?

and i hope somebody can send me the code file and today please.
Was This Post Helpful? -1
  • +
  • -

#35 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9574
  • View blog
  • Posts: 36,268
  • Joined: 12-June 08

Posted 10 December 2014 - 09:37 AM

Perhaps start a thread, in the language forum, with your code and errors. If you are not getting the right output then explain what you are inputting, what you are getting back, and what you think you should get back.

Also observe the rules about asking for people to do your work for you. Hint - that is a no-no.
Was This Post Helpful? 0
  • +
  • -

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