wood burning stoves 2.0*
The moose likes Java in General and the fly likes find covering prefix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "find covering prefix" Watch "find covering prefix" New topic

find covering prefix

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 321

I am trying to find a covering prefix

my code is:

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39537
What do you mean by "adding a new value dynamically"? Do you mean to increase the array's length? If so, then that can't be done. You could use a List<Integer> instead of an int[] - that can be extended dynamically.

Ping & DNS - updated with new look and Ping home screen widget
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 7029

Angus Ferguson wrote:I am trying to find a covering prefix...

Well, first: you need to define what a "covering prefix" is (I had to look it up); because it will be different for an int[] than it is for a String[] (at least the way of calculating it will be very different). Furthermore, it's quite possible that there are types for which it is simply not applicable ('can't think of one, based on what I've read; but it's worth thinking about).

However, for an int[], it would appear to be a byproduct of the max() function; so you might want to look at Math.max().


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
jQuery in Action, 2nd edition
subject: find covering prefix
Similar Threads
Floyd's Algorithm
Big-O Notation??? (Don't understand)
what will be the output of this two dimentional array and why
Search Element in array Problem
Increment Test