Building a linked list

B

bribriLA

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 :)
 
J

Joshua Cranmer

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 :)

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

Roedy Green

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
 
R

Robert

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 :)


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?
 
L

Lew

You are well advised to name this class with an initial upper-case letter.
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.
 
M

Mark Space

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.
 
B

brianlaca

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

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.
 
B

brianlaca

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



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.

I do and my apologies for posting prior to searching. Will
extensively search the archives in the future.
 
L

Lew

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
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/.
 
L

Lew

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

OP "mmoski" on 2007-09-17.
 
N

nebulous99

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 ... :)
 
L

Lew

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.
 
B

bbound

[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
 
L

Lew

Lew said:
[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:

Note the derivation: "In American English".

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

bbound

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!
 
R

Roedy Green

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.
 
R

Roedy Green

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?
 
J

John W. Kennedy

[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.
--
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"
 
B

bbound

[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.
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 asshole Lew feels an obsessive need to follow up
to anything I write with an attempt to denigrate me, that's why. :p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top