Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Building a linked list

Thread view: 
bribriLA@gmail.com - 20 Sep 2007 00:13 GMT
Hi everybody, I'm stuck and was hoping someone here could help.  I am
implementing a linked list, with a class node, which has a String
object text and a node next as its definition.  I'm all set on adding,
deleting, inserting, etc.  But for the life of me, I cannot figure out
how to insert the original data to build the list initially.  Any help
would be great, and if you need more info just let me know.

Thanks in advance :)
Joshua Cranmer - 20 Sep 2007 00:40 GMT
> Hi everybody, I'm stuck and was hoping someone here could help.  I am
> implementing a linked list, with a class node, which has a String
[quoted text clipped - 4 lines]
>
> Thanks in advance :)

1. What is the format of the original data?
2. For what purpose are you writing your own linked list implementation?

Signature

Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth

brianlaca@gmail.com - 20 Sep 2007 05:42 GMT
> bribr...@gmail.com wrote:
> > Hi everybody, I'm stuck and was hoping someone here could help.  I am
[quoted text clipped - 12 lines]
> Beware of bugs in the above code; I have only proved it correct, not
> tried it. -- Donald E. Knuth

Sorry about the delay in responding...  it is for my data structures
class.  The format of the original data is in a text file, read in
line by line, each node being one line.  This will implement a very
rudimentary editor.
Roedy Green - 20 Sep 2007 01:08 GMT
>Hi everybody, I'm stuck and was hoping someone here could help.  I am
>implementing a linked list, with a class node, which has a String
>object text and a node next as its definition.  I'm all set on adding,
>deleting, inserting, etc.  But for the life of me, I cannot figure out
>how to insert the original data to build the list initially.  Any help
>would be great, and if you need more info just let me know.

You can peek at two LinkedList implemenations.
One is Sun's in src.zip  java.util.LinkedList

and mine written before Sun's was written.
http://mindprod.com/jgloss/products2.html#LINKEDLIST
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Robert - 20 Sep 2007 01:11 GMT
On Sep 19, 4:13 pm, bribr...@gmail.com wrote:
> Hi everybody, I'm stuck and was hoping someone here could help.  I am
> implementing a linked list, with a class node, which has a String
[quoted text clipped - 4 lines]
>
> Thanks in advance :)

If you're all set on adding that's what you do.  Add the nodes one at
a time to build your list.  Am I confused here?
Lew - 20 Sep 2007 01:39 GMT
> On Sep 19, 4:13 pm, bribr...@gmail.com wrote:
>> Hi everybody, I'm stuck and was hoping someone here could help.  I am
>> implementing a linked list, with a class node,

You are well advised to name this class with an initial upper-case letter.

>> which has a String object text and a node next as its definition.  I'm all set on adding,
>> deleting, inserting, etc.  But for the life of me, I cannot figure out
[quoted text clipped - 5 lines]
> If you're all set on adding that's what you do.  Add the nodes one at
> a time to build your list.  Am I confused here?

They probably want the advice to declare a variable (of, say, type Node) to
point to the start of the LincolnList, and to set it to a new node (of, say,
type Node) as a new item comes into the LL.

Presumably with that advice they'd know what to do with the `next' reference
when the next item comes into the list.

There was a darned good hint on this very problem (could it already be the
start of a new semester?) in a thread on this very problem just a day or two
ago.  To the OP:  do you know how to search the newsgroup archives?

Also, GIYF.

Signature

Lew

brianlaca@gmail.com - 20 Sep 2007 05:44 GMT
> > On Sep 19, 4:13 pm, bribr...@gmail.com wrote:
> >> Hi everybody, I'm stuck and was hoping someone here could help.  I am
[quoted text clipped - 27 lines]
> --
> Lew

I do and my apologies for posting prior to searching.  Will
extensively search the archives in the future.
Lew - 20 Sep 2007 06:01 GMT
> I do and my apologies for posting prior to searching.  Will
> extensively search the archives in the future.

An apology wasn't the point of my comment but rather to provide a clue where
some useful information might reside.

Roedy Green's website,
<http://www.mindprod.com/>
in its "Java" section has excellent advice on getting started with problems,
buried amongst all the other excellent advice there.

Patricia Shanahan gets into the nitty gritty of how to approach such problems
in her article at
<http://home.earthlink.net/~patricia_shanahan/beginner.html>

Read her
<http://home.earthlink.net/~patricia_shanahan/debug/index.html>
also.

>  it is for my data structures class.

Did your class discuss the algorithms of a linked list?

That is, do you understand in abstract terms how to do it, so that only Java
is the difficulty?

If that's all you've got, how about you post the logic you have, in pseudocode
or some suitable "logic" form?

If you have Java code already, what is the exact difficulty?

As Robert advised and asked:
> If you're all set on adding that's what you do.  Add the nodes one at
> a time to build your list.  Am I confused here?

You could show us what you've got so far and tell us what part of it is giving
you /agita/.

Signature

Lew

nebulous99@gmail.com - 21 Sep 2007 15:04 GMT
> You could show us what you've got so far and tell us what part of it is giving
> you /agita/.

The only source of /agita/ around here is the need some people seem to
feel to put at least /one/ obscure or foreign word, neologism, or
acronym in every post ... :)
Lew - 21 Sep 2007 16:44 GMT
Lew wrote:
>> You could show us what you've got so far and tell us what part of it is giving
>> you /agita/.
>
> The only source of /agita/ around here is the need some people seem to
> feel to put at least /one/ obscure or foreign word, neologism, or
> acronym in every post ... :)

:-)

<http://www.google.com/search?q=agita>
First hit.  Also the second, third or fourth.  UrbanDictionary.com is probably
the most fun.

Not really a very obscure word, but hey, there's the definition if you need it.

It's only "foreign" if you aren't from the United States, which is certainly
true of a lot of people here but I still wonder at your use of the term.

For the benefit of the world community:
> In American English, the terms /agita/ and /heartburn/ are also used
> as idioms to describe an annoying person or situation, as in
> "Stop it already, you are giving me a case of agita."
<http://encyclopedia.thefreedictionary.com/agita>

GIYF - one assumes a certain level of competence in this community, so the
risk from the use of such fairly common terms is not really so high - those
not excessively lazy can easily figure it out in about the same amount of time
it takes to post a message asking the question, much less the time until
someone answers.

Signature

Lew

bbound@gmail.com - 21 Sep 2007 16:56 GMT
[a whole bunch of stuff liberally laced with insults]

The term is hardly "common" or I'd surely have run across it before.
And it's plainly not English; looks French or perhaps Spanish, Latin,
or one of those. Hell, you even italicized it, as one typically does
with a foreign word embedded in English. Also, your lack of a sense of
humor and quickness to insult people is frankly getting tiresome. :P
Lew - 21 Sep 2007 17:03 GMT
Lew wrote:
> [a whole bunch of stuff liberally laced with links to the requested information]

> The term is hardly "common" or I'd surely have run across it before.

Surely.

> And it's plainly not English; looks French or perhaps Spanish, Latin,
> or one of those. Hell, you even italicized it, as one typically does
> with a foreign word embedded in English. Also, your lack of a sense of
> humor and quickness to insult people is frankly getting tiresome. :P

bbound, are you also known as nebulous?

I italicized it because it's slang, and of Italian-American derivation as the
links I provided explain.  Did you read those?  They clearly identify the term
as American, as did the quote I explicitly provided, which provided the
information you requested in order to save you the time and trouble to follow
the links.

Here is the quote again, for reference:
>> In American English, the terms /agita/ and /heartburn/ are also used as
>> idioms to describe an annoying person or situation, as in
>> "Stop it already, you are giving me a case of agita."
> <http://encyclopedia.thefreedictionary.com/agita>
>
> GIYF

Note the derivation: "In American English".

I wish you'd refrain from the /ad hominem/ comments.

Signature

Lew

bbound@gmail.com - 21 Sep 2007 17:19 GMT
> bbound, are you also known as nebulous?

Nebulous is apparently no more -- whoever destroyed the Twisted0n3
account apparently has struck again. Not only did it abruptly stop
working for posting, but attempting to log in and out was generating
spurious and incorrect error messages (when I'd certainly made no
error -- triple checked). Whoever zapped it did it around 9 Eastern
time. Not the same symptoms though -- the Twisted0n3 one was somehow
set to autologout on login, so it won't STAY logged in so I can post;
the nebulous one has been artificially bumped over their "posting
limit" instead. (I've posted maybe a dozen posts in the past three or
four days and it claims I've exceeded what I'd previously estimated as
a 25-post-per-day limit. I've made maybe that many in the past *week*
and haven't come close in any contiguous 24-hour period. My estimate
might of course not have been exact but I'm darn sure it's not off by
a full factor of two, either.)

> I italicized it because it's slang, and of Italian...

Well Latin was one of the things I'd been thinking, which is darn
close. I rest my case.

[snip needless repetition of things already said]

> I wish you'd refrain from the /ad hominem/ comments.

ExCUUUUSE me? You wish *I*'d refrain from ad hominem comments? *You*
are the one who lurks by his keyboard refreshing this newsgroup every
2 minutes night and day to see if there are new posts by me and then
posts a nasty followup to every one of them. I wish *you*'d refrain!
John W. Kennedy - 22 Sep 2007 03:28 GMT
> [a whole bunch of stuff liberally laced with insults]
>
> The term is hardly "common" or I'd surely have run across it before.

You think very highly of yourself, don't you?

> And it's plainly not English; looks French or perhaps Spanish, Latin,
> or one of those.

French? French?! I suppose you also think that the theme from "CSI:
Miami" is by the Beatles.

It's Italian, of course, and a well established denizen of American English.
Signature

John W. Kennedy
"When a man contemplates forcing his own convictions down another man's
throat, he is contemplating both an unchristian act and an act of
treason to the United States."
  -- Joy Davidman, "Smoke on the Mountain"

bbound@gmail.com - 22 Sep 2007 08:03 GMT
> bbo...@gmail.com wrote:
> > [a whole bunch of stuff liberally laced with insults]
>
> > The term is hardly "common" or I'd surely have run across it before.
>
> You think very highly of yourself, don't you?

What I said just follows from the definition of "common" and the fact
that I've been alive for several decades and using the net for more
than one and a half.

> > And it's plainly not English; looks French or perhaps Spanish, Latin,
> > or one of those.
>
> French? French?! I suppose you also think that the theme from "CSI:
> Miami" is by the Beatles.

Of course not, it's obviously by the Who.

> It's Italian, of course, and a well established denizen of American English.

Italian is basically what Latin, which I mentioned, became, and it is
clearly not a well established denizen of English as normally used
anywhere I normally go or, as I said before, I'd have seen it before.

Anyway why has my original humorous comment turned into a huge debate?
Oh yeah, because that a.shole Lew feels an obsessive need to follow up
to anything I write with an attempt to denigrate me, that's why. :P
Lew - 22 Sep 2007 15:15 GMT
> ... that a.shole Lew ... :P

:-)

Signature

Lew

Roedy Green - 21 Sep 2007 17:31 GMT
>The only source of /agita/ around here is the need some people seem to
>feel to put at least /one/ obscure or foreign word, neologism, or
>acronym in every post ... :)

I like people who do that.  Children learn many new words each day.
Why should we stop as adults?
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 21 Sep 2007 17:30 GMT
>Roedy Green's website,
><http://www.mindprod.com/>
>in its "Java" section has excellent advice on getting started with problems,
>buried amongst all the other excellent advice there.

The entries that may be of particular help include:

http://mindprod.com/jgloss/homework.html
and
http://mindprod.com/jgloss/tackling.html

This is very general problem-solving advice.  I was using it back in
the 60s tutoring people in math and physics.

The best teachers are not necessarily the brightest people.  They are
the ones who struggled hard to master the material, and who remember
that struggle, and all the dead ends based on erroneous assumptions.
Brilliant people don't need strategies to solve easy problems.

This is why I like to write my first cut at explanatory essays shortly
after I encounter material, even if they are not completely correct. I
can make corrections later.  I can't remember the difficulties later.
The other advantage is other people feel compelled to help my
education by correcting my errors.  It is sort of like taking off all
your clothes for the doctors to have a good look at your failings.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 20 Sep 2007 06:06 GMT
Lew wrote:
>> There was a darned good hint on this very problem (could it already be the
>> start of a new semester?) in a thread on this very problem just a day or two
>> ago.  To the OP:  do you know how to search the newsgroup archives?

The thread in question was "A question regarding singly-linked lists." in this
newsgroup (clj.programmer).

OP "mmoski" on 2007-09-17.

Signature

Lew

Mark Space - 20 Sep 2007 01:48 GMT
> Hi everybody, I'm stuck and was hoping someone here could help.  I am
> implementing a linked list, with a class node, which has a String
> object text and a node next as its definition.  I'm all set on adding,
> deleting, inserting, etc.  But for the life of me, I cannot figure out
> how to insert the original data to build the list initially.  Any help
> would be great, and if you need more info just let me know.

The code you already have written would be a big help.  Hard to guess
what you are stuck on without a sample listing.

A short, complete & compilable listing is best.  Hard to guess what is
going on if you leave sections out that are needed to diagnose the
problem.  "Short" because no one wants to read five pages of text just
to find one little typo.  If you can show us the problem using just one
class, that's best.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.