Results 1 to 3 of 3
- 10-17-2011, 06:10 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 7
- Rep Power
- 0
- 10-17-2011, 06:22 AM #2
Re: How would I count number of nodes in linked list?
Maintain an instance variable. Each time a node is added increment it by one. Each time a node is deleted decrement it by one.
- 10-17-2011, 06:26 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: How would I count number of nodes in linked list?
Have you ever been in one of those "mystery tour" type competitions where you get instructions via a clue which lead you to the location of the next clue. Great fun especially if the nodes you are led to are pubs about the place.How, conceptually, should I think of approaching this?
Now it's a relatively simple matter to count the number of places you visit as you follow the clues. If you stick to orange juice.
Similar Threads
-
Linked List, Array List time complexity
By Rick99771977 in forum New To JavaReplies: 4Last Post: 08-18-2011, 05:37 AM -
How to access an element of a linked list inside another linked list?
By smtwtfs in forum New To JavaReplies: 4Last Post: 02-21-2011, 09:34 AM -
adding children to a node that has List of Nodes
By f1gh in forum New To JavaReplies: 0Last Post: 11-29-2010, 01:27 AM -
Linked list inside a linked list
By viperlasson in forum New To JavaReplies: 5Last Post: 07-26-2010, 11:15 PM -
linked list nodes all refernce same item.
By yllawwally in forum New To JavaReplies: 0Last Post: 12-18-2007, 08:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks