Data structures in java

B

bidyut

I am facing problem in doing java programming mainly for data
structures part.I want to get a good book on data structures through
java by an Indian writer.Please help me as far as you can.
 
G

GArlington

I am facing problem in doing java programming mainly for data
structures part.I want to get a good book on data structures through
java by an Indian writer.Please help me as far as you can.

Is it a language problem, or race/nationality discrimination?
Technically, java class with public attributes and NO methods is a
data structure...
 
B

bidyut

Is it a language problem, or race/nationality discrimination?
Technically, java class with public attributes and NO methods is a
data structure...

Sir I am facing problem in doing linked list(generic and integer
linked list),stack,queue etc in java programming.Because unlike C
language it has no pointer application.So please provide me the name
of a good Indian writer book(in english only).
 
T

Tim Smith

Sir I am facing problem in doing linked list(generic and integer
linked list),stack,queue etc in java programming.Because unlike C
language it has no pointer application.So please provide me the name

References in Java are pointers. Linked list of integers:

class IntItem
{
IntItem next;
int data;
}

class IntList
{
IntItem head;
IntItem tail;

IntList() { head = tail = null; }

IntList getHead() { return head; }

void append( int data )
{
IntItem item = new IntItem();
item.data = data;
item.next = null;
if ( head == null )
head = tail = item;
else {
tail.next = item;
tail = item;
}
}

void deleteHead()
{
if ( head != null )
head = head.next;
}
}

(Actually, you'd probably make a constructor for IntItem to set the
data, but I wanted to keep it a pure data structure for this example).
 
R

Robert Klemme

Sir I am facing problem in doing linked list(generic and integer
linked list),stack,queue etc in java programming.Because unlike C
language it has no pointer application.

Why reinvent the wheel? Go to java.util.* and you will find all you need.
So please provide me the name
of a good Indian writer book(in english only).

Why does it have to be an Indian writer if you require the book written
in English?

Cheers

robert
 
W

Wesley Mesquita

Why reinvent the wheel? Go to java.util.* and you will find all you
need.
Why does it have to be an Indian writer if you require the book written
in English?

Cheers

robert

I don´t know it is the case, but perhaps he want do it just for
learning porposes, and bacause this have to to it by hand.


Unless you have to explicity use Java, it is better to try
implementing your data structures in a low level language like C.
 
L

Lew

Wesley said:
Unless you have to explicity use Java, it is better to try
implementing your data structures in a low level language like C.

Ridiculous. How is Java's expression of such algorithms in any way inferior
to C's? If anything, it'll be clearer due to the lack of all those asterisks.
 
W

Wesley Mesquita

Ridiculous. How is Java's expression of such algorithms in any way inferior
to C's? If anything, it'll be clearer due to the lack of all those asterisks.

Where am I used "inferior"? It was a suggestion, just it.
But I think nobody will implement such primitive data structures (like
a linked list) in Java for some real application, if someone does it,
problably will get a worse code than the one implemented in Java API.
 
L

Lew

Wesley said:
Where am I used "inferior"? It was a suggestion, just it.

Where you said "it is better to try ... C", that implies by simple logical
transformation that Java is inferior. If A is better than B, then B is
inferior to A, by definition.
But I think nobody will implement such primitive data structures (like
a linked list) in Java for some real application, if someone does it,
problably will get a worse code than the one implemented in Java API.

The OP mentioned that this was a learning exercise, and already turned down
using API classes and methods for that reason.

Assuming that a particular "primitive data structure" like, say, a red-black
tree or a trie, doesn't already have a suitable implementation in the standard
API, one has little choice but to find a third-party library that does (such
as the Apache Commons Collections Java library), or to write it themselves.
In a real application.

Is there a reason why Java would not be suitable for that?
 
W

Wesley Mesquita

Where you said "it is better to try ... C", that implies by simple logical
transformation that Java is inferior. If A is better than B, then B is
inferior to A, by definition.


The OP mentioned that this was a learning exercise, and already turned down
using API classes and methods for that reason.

Assuming that a particular "primitive data structure" like, say, a red-black
tree or a trie, doesn't already have a suitable implementation in the standard
API, one has little choice but to find a third-party library that does (such
as the Apache Commons Collections Java library), or to write it themselves..
In a real application.
Is there a reason why Java would not be suitable for that?
I agree with your logic and now I see that I "told" Java is inferior
in this point of view. (I used "try" to avoid this, but it is ok).
There is no specific reason, it is personal. Sometime I prefer to C
instead of Java because I want myself to manage memory and pointers to
realize what is happening (just for learning porposes). Professionally
I use most Java (90% of time) than C. I use C just for some devices
that have only C APIs and I have to use JNI to send everything to
Java.

Problaly it is my poor english, but I didn´t wanna say that C is
better to Java, or something like this.
 
R

Robert Klemme

Where you said "it is better to try ... C", that implies by simple
logical transformation that Java is inferior. If A is better than B,
then B is inferior to A, by definition.

I may be a nitpick but if it helps to uncover a miscommunication...
Anyway, I believe Wesley did not claim that Java is inferior as a
language but he suggested that it is better to use C for the
implementation of a linked list. However, he did not disclose according
to what standards it's better (better learning experience, more fun
whatever).

I also would question this: because Java takes away the details of heap
management you can better focus on algorithms. In fact, if it was for
learning algorithms I would probably turn to Ruby which has even cleaner
syntax. Wesley, why do you need memory pointers in order to "realize
what is happening"?

Kind regards

robert
 
L

Lew

Robert said:
I also would question this: because Java takes away the details of heap
management you can better focus on algorithms. In fact, if it was for
learning algorithms I would probably turn to Ruby which has even cleaner
syntax. Wesley, why do you need memory pointers in order to "realize
what is happening"?

Bearing in mind, of course, that Java has such pointers.

Java's syntax is so C-like that it seems equally suitable for algorithm study
in such matters to C. As Robert states, it is likely even superior in certain
ways.
 
A

Arne Vajhøj

Lew said:
Ridiculous. How is Java's expression of such algorithms in any way
inferior to C's? If anything, it'll be clearer due to the lack of all
those asterisks.

I doubt that.

Those that need to code linked lists etc. will probably not
have a good understanding of simple data types versus
reference types.

In which case it becomes a bit muddy.

The asterisks make it very clear what is a point and what
is not.

Arne
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top