Welcome to Dream.In.Code
Become a Java Expert!

Join 150,102 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,847 people online right now. Registration is fast and FREE... Join Now!




HighArray in Java

 
Reply to this topicStart new topic

HighArray in Java

rose63
24 Jun, 2008 - 08:44 PM
Post #1

New D.I.C Head
*

Joined: 24 Jun, 2008
Posts: 4

I'm new in Java but at the same time I have these question. Anybody can help me?

a)Write a noDups() method for the HighArray class of the highArray.java program (Listing 2.3 Lafore 2003). This method should remove all duplicates from the array. That is, if three items with the key 17 appears in the array, noDups() should remove two of them. Don’t worry about maintaining the order of the items. One approach is to first compare every item with all the other items and overwrite any duplicate with a null (or a distinctive value that isn’t used for real keys).

b)Remove all the nulls. Of course, the array size will be reduced.

I don't know how to solve the problem. any body can help me please.

Tq
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: HighArray In Java
24 Jun, 2008 - 09:06 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well can you show us what you have put together already? Our first rule around here is that we ask people to show some kind of effort in attempting to solve the problem themselves. We don't do homework, but we will gladly help guide you through the problem and correct anything you might have wrong.

Some things to look at for this would be the use of two loops, one nested inside the other. The outer loop will move through the array one by one and the inner loop will start from the current position of your outer loop and loop through until the end.

So lets say you have 5 items in your array. The outer loop will start at zero and your inner loop will start at 1 and go to index 4. Then your outer loop will move to index 1 and your inner loop will start at 2 and go to index 4. See a pattern?

You would continue the outer loop until you are 1 less than the total size of the array, so for our example you would stop after processing index 3.

Hope that makes sense. Show us what you have and we can help you further. Oh and don't forget to use code tags... code.gif

smile.gif
User is offlineProfile CardPM
+Quote Post

rose63
RE: HighArray In Java
25 Jun, 2008 - 12:50 AM
Post #3

New D.I.C Head
*

Joined: 24 Jun, 2008
Posts: 4

QUOTE(Martyr2 @ 24 Jun, 2008 - 10:06 PM) *

Well can you show us what you have put together already? Our first rule around here is that we ask people to show some kind of effort in attempting to solve the problem themselves. We don't do homework, but we will gladly help guide you through the problem and correct anything you might have wrong.

Some things to look at for this would be the use of two loops, one nested inside the other. The outer loop will move through the array one by one and the inner loop will start from the current position of your outer loop and loop through until the end.

So lets say you have 5 items in your array. The outer loop will start at zero and your inner loop will start at 1 and go to index 4. Then your outer loop will move to index 1 and your inner loop will start at 2 and go to index 4. See a pattern?

You would continue the outer loop until you are 1 less than the total size of the array, so for our example you would stop after processing index 3.

Hope that makes sense. Show us what you have and we can help you further. Oh and don't forget to use code tags... code.gif

smile.gif



QUOTE(rose63 @ 25 Jun, 2008 - 01:49 AM) *

QUOTE(Martyr2 @ 24 Jun, 2008 - 10:06 PM) *

Well can you show us what you have put together already? Our first rule around here is that we ask people to show some kind of effort in attempting to solve the problem themselves. We don't do homework, but we will gladly help guide you through the problem and correct anything you might have wrong.

Some things to look at for this would be the use of two loops, one nested inside the other. The outer loop will move through the array one by one and the inner loop will start from the current position of your outer loop and loop through until the end.

So lets say you have 5 items in your array. The outer loop will start at zero and your inner loop will start at 1 and go to index 4. Then your outer loop will move to index 1 and your inner loop will start at 2 and go to index 4. See a pattern?

You would continue the outer loop until you are 1 less than the total size of the array, so for our example you would stop after processing index 3.

Hope that makes sense. Show us what you have and we can help you further. Oh and don't forget to use code tags... code.gif

smile.gif



User is offlineProfile CardPM
+Quote Post

1lacca
RE: HighArray In Java
25 Jun, 2008 - 01:17 AM
Post #4

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
Let's try this again.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:43AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month