Problems defining the array for quicksort
import java.io.*;
import java.util.*;
import chn.util.*;
public class Store
private Item [] myStore;
public Store (String fileName) {
fileName = "file50.txt";
/* public void displayStore ()
public String toString () { }
public void doSort () { }
*/ private void quickSort (Item[] lit, int lo, int hi) // I don't exactly know what Item[ ] lit will do. please explain it for me.
int h, l, p, t;
if (lo < hi) {
l = lo;
h = hi;
/* p = a[hi]; //my problem starts with the array 'a' (suppose to be item, but don't know how to modify that.
do {
while ((l < h) && (a[l] <= p)) l++;
while ((h > l) && (a[h] >= p)) h--;
if (l < h) {
t = a[l];
a[l] = a[h];
a[h] = t;
} while (l < h);
t = a[l];
a[l] = a[hi];
a[hi] = t;
private void loadFile (String inFileName)
FileInput inFile = new FileInput (inFileName = "file50.txt");
}The array 'a' should be replaced with the array 'Item' but some how I'm getting the errors that Item's not a valid type.
for more information, please see http://forum.java.sun.com/thread.jspa?threadID=699397&tstart=60 for more information (the original problem)
Here is what I suggest.
Use collections. I suggest an ArrayList. Using one array involves all sort of messy swapping around which really will make things difficult for you to grasp the basic concept of.
So let us assume a method like this
public void quicksort(List items)
items is a List of Items.
So here is how to write a quicksort
1) If the size of the list is 1 then return the list because it is down to it's final piece and doesn't need to be sorted further
2) Choose a pivot element of your list. The mid point is often chosen for this.
3) Create two new Lists. One for lower elements and one for higher and equal to elements.
4) Go through the list and use compareTo to compare the elements of the list with your pivot element. Take care to skip the pivot element. If elements are less than the pivot put them in the first list. If they are more than or equal to put them in the second list.
5) Recursively call quicksort(list) on the sublists we made.
6) Merge the sublists and pivot values back into one list
7) return the merged list
Similar Messages
-
How to let the user define the colors for each plots in the graph (I use LabVIEW 7)?
How to let the user define the colors for each plots in the graph (I
use LabVIEW 7)?Hi,
Take a look at this example, it uses property nodes to select tha
active plot and then changes the color of that plot.
If you want to make the number of plots dynamic you could use a for
loop and an array of color boxes.
I hope this helps.
Regards,
Juan Carlos
N.I.
Attachments:
Changing_plot_color.vi 38 KB -
Help define the requirements for an Oracle Spatial management tool
Hi,
We are developing a tool that, we hope, will be indispensable for all Oracle Spatial and Locator dbas/users. We've released version 1.0, but we need your help to define the requirements for the next version.
What features would you like to have in a management tool for your spatial databases?
The features we've got so far:
1. Viewing of vector data in a map + attributes
2. Loading from shapefiles
3. Exporting to shapefiles
4. Validating metadata, indexes and spatial data.
We are adding editing of vectors in the next version - basic stuff for add, update and delete.
But there must be a lot more. What do you find difficult to do in Oracle Spatial/Locator? What would you like in a tool such as this?
Any feedback either to myself or the forum is much appreciated.
cheers,
Andrew
[email protected]
PS If you like to have a look at what we have done so far, go to http://www.geometryit.com/products/spatialConsole.phpAndrew knows what I have asked for but for others to think about and to start
the ball rolling, here's what they are:
1. Ability to enter own SQL commands but with PARAMETERS for attributes
and shapes as in the following examples:
SELECT ...
FROM my_spatial_table a
WHERE a.ATTRIBUTE = :attr
AND MDSYS.SDO_RELATE(a.shape,:polygon,'mask=anyinteract') = 'TRUE'
When executed the attribute value is asked for via a input box (data type?)
and the user is asked to define the SDO_GEOMETRY for the :polgygon parameter via mouse clicks on the screen.
Similarly, this would work for INSERT, UPDATE and DELETE...
INSERT INTO my_spatial_table (shape) values(:polygon)
The data type of an attribute parameter could be determined in two ways:
a) By querying the Oracle catalog;
b) By using a "PARAMETERS" command before the query as follows
PARAMETERS name type [(size)] [, name type [(size)] ...]
The PARAMETERS declaration has these parts:
name The name of the parameter.
type The type of the parameter.
size The size of the parameter in characters or bytes.
2. When executing an SQL SELECT statement I would like the tool
to suggest the HINTS that are needed to improve performance.
3. Following on from 2, I would like to Tick an option that would return the
EXPLAIN PLAN that the query optimizer used when executing my query.
4. The tool has to support ALL Oracle's spatial vector data types.
5. It would be nice to be able to work with GeoRasters. Since Spatial Console
imports/exports shapefiles why not the same for rasters. However, the problem
with supporting foreign data formats is WHERE DO YOU STOP!!!!!
6. You could allow for the styling of the Spatial Console to be stored in the MapViewer catalogs or use the MapViewer catalogs when styling an Sdo_Geometry if it exists (I note that your tool extracts the SDO_METADATA
why not the MapViewer metadata as well)?
regards
S. -
Problems with the Search for room content
Hi,
I face a problem configuring the search for room content using KM search iView (com.sap.km.Search).
I found the chapter Configuring the Search for Room Content in the help. So I set up the following things :
1- I assign the room_id iView parameter to the roomid room parameter (in the template)
2- I added room_cm_search component to the component set (I added it at the bottom of the "component for basic search function")
3- I select the entry "Folder" as the default search scope in the search option set. I specify a root folder for search as well.
But it doesn't work properly. It always returns "no result found". And if I add the room_cm_search component at the top of the "component for basic search function", It runs the search on all the documents of the default search scope, and not only on the room documents.
Can you please tell me the right way to configure the search for room content using the com.sap.km.Search iView ?
I work on EP 7.0 SP 10.
Thanks a lot,
Loïc LEVEUGLEHi Loic,
the Room Content Search iView is a special Search iView that is filtering for documents that were created in the Room Context (all documents get a specific metadata that is keeping the roomiD) . The easiest thing is to use the standard iView used for the delivered templates from SAP.
I would advise to use the iView that is already preconfigured for a room template or part template and can be found and referenced in your template from the following path: Portal Content ->com.sap.ip.collaboration--> TemplateAndPartContent --> Generic -->iViews and take the iView "Search Room"
If you reference that iView in your room template or room part template, you have to think about the correct configuration in the template configuration iView. Just take as example the configuration of the part template "SAP Search Room".
Or even better: Copy a template (room or part) from SAP that is containing the Room Search and delete everything what you don´t need out of the template. You safe time and you can add all additional content you´ll need to your template. Some ideas can be found in the following "How to Guide":
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0496f69-cb70-2910-21a6-c4cf2cc66311
What you have written under 3 -> would never work as the root folder for search doesn´t make any sense as the documents of a room are stored in different folders and you can´t define a root folder. Therefor you have the specific room_id parameter that is filtering what documents belong to the room.
Good luck,
Anja -
Why can't I update my iPhone 4 to iOS 5.1? Every time I try it gets all the way done downloading it; however when it's processing the file the page tells me "There is a problem downloading the software for the iPhone. Network connection timed out. Make sure your network settings are correct and your network connection is active. or try again later." and next to the file it has err = -3259. I have tried this 17 times and it won't work. My iTunes is completely up to date. I have made sure that my connection is fine and I have tried turning my firewall off with no avail. This has happened to me before but usually the update will go through after 2-3 tries, never to this extent. I don't know what to do. Help!
Error -3259 is a network timeout error, usually. This article might help:
http://support.apple.com/kb/TS2799 -
I have an old iPhone 3Gs with software version 4.3.5, I am trying to use it again, and it works fine, but I have not been able to update the software. Every time I try, I get the following message:
"there was a problem downloading the software for the iPhone, the network connection could not be established". This happens even though I have a working internet connection.
Besides that, all the other functions work properly, even synchronize apps and library.
Will I be able to update the software?look around the forum tons of people repport that they can't update
makes you suspect that apples update servers can't meet the depand of too many users
trying to update at once -
Hi,
I tried to downgrade my iphone4s os from ios6 (beta 4) to ios 5.0.1(factory settings).
but all the time i am getting the following error.
"there was a problem downloading the software for the iphone "rams's iPhone" "
pls help me to downgrade my device.
I am from india, ios6 maps are not at all working for india so i want to go for old version so that i can have google maps.
Regards
RamYou couldn't go back to 5.0.1 even if you wanted to, it would have to be 5.1.1 but if you had a signed copy of the iOS 6 beta on your iPhone I don't believe you can go back.
You can try Google to see if you can find a workaround. Despite the map issue, if you are a developer don't you need the Beta on your iPhone? -
When trying to download and update the operating system software for my iPad and iPod I get the following message - "ERROR MESSAGE" There was a problem downloading the software for the iPad "Mikki's iPad". The network connection timed out. Make sure your network settings are correct and your network connection is active, or try again. later." Is this a setting on my computer - my network is working fine. I didn't have any trouble before but have just started having trouble. Please help...
Hi Robertfrom Denver.
Did you try the solution given, and if yes, did it work?
I have done several "attempted downloads, and see the full file download, typically taking 30 minutes to complete, and then something goes wrong.
I am happy to suspend AV and FW software, but would like to know if it is a good fix or not first?
HelenfromBroughton Astley -
I am trying to download an update to my iphone, but in the middle of the download, I get an error message that reads, 'There was problem downloading the software for the iphone. The network connection timed out'. Any idea how to reslove this issue?
Hi Robertfrom Denver.
Did you try the solution given, and if yes, did it work?
I have done several "attempted downloads, and see the full file download, typically taking 30 minutes to complete, and then something goes wrong.
I am happy to suspend AV and FW software, but would like to know if it is a good fix or not first?
HelenfromBroughton Astley -
I have an Iphone 4s 32gb and i'm trying to update it to ios 5.1. i've downloaded the software from itunes but when i click on it to install it to my actual phone it says: "There was a problem downloading the software for Iphone 'Donnbjj1's Iphone' . An unknown error occurred (1480)."
iOS: Resolving update and restore alert messages
For error -50: See error 13 and 14:
Error 13 and 14: These errors are typically resolved by performing one or more of the steps listed below:
Perform USB isolation troubleshooting, including trying a different USB port directly on the computer. See the advanced steps below for USB troubleshooting.
Put a USB 2.0 hub between the device and the computer.
Try a different USB 30-pin dock-connector cable.
Eliminate third-party security software conflicts.
There may be third-party software installed that modifies your default packet size in Windows by inserting one or more TcpWindowSize entries into your registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet-size modification for assistance. Or, follow this article by Microsoft: How to reset Internet Protocol (TCP/IP) to reset the packet size back to the default for Windows.
Connect your computer directly to your Internet source, bypassing any routers, hubs, or switches. You may need to restart your computer and modem to get online.
Try to restore from another known-good computer and network. -
I have an ipod touch 4th generation I want to update it but when I do it says there is a problem downloading the softward for the ipod an internal server error occured can someone help me please?
If you are updating via wifi then connect the iPod to your computer and try there. And the other way around too.
-
HI, i'm having this error message [There was a problem downloading the software for the iphone "banster's iphone". An unknown error occurred (-23)] when im doing the upgrading to IOS 5. anybody know how to slove it? Thanks
Yep, me to exactly the same problem, the error message keeps telling me to check my internet connection or try later. Nothing wrong with my internet connection. Is it an apple server problem?
-
Hi,
I cant seems to restore my iphone or even downloading the latest iOS 5 update. The error message is as per subject: "there was a problem downloading the software for the iphone. An unknown error occured (-23)"
Anyone know how to resolve this?
I have no issue with my network connection.
thanks
Alexisi had this problem too, check security updates, itunes update to 10.5, disable firewall and antivirus but still the same problem. Seems there is no answer to it.
-
"There was a problem downloading the software for the iPhone....An unknown error occurred (-23)." What should I do?
i have the same problem:
I have an iphone 4s and I have been trying for months to update my phone from iOS 6.1.3 to the new one.
I recently got a new computer (my old harddrive crashed and will not work at all) and I just now copied all my music and photos to the computer.
Now I have been trying to update to the iOS 7.1 both on iTunes and on the iPhone but neither one work. I keeps saying "unknown error" .
I am wondering if I restore it to factory settings and then update it will the install work?
also since i have backed up to the iCloud and my computer..will i be able to recover my music, contacts, notes and photos???
thanks in advance. -
Performance point Filter error : " There was a problem preparing the WebPart for display"
I’m going to create a performance point filter .I chose “Custom Table” type to select Project Name for my reports. I have some reports which have Project Name (ProjectUID as value) as parameter .So I’m going to create a filter based on Project Name (ProjectUID
as value) to use for all report. these are my settings:
Table: MSP_EpmProject_Userview
Key :ProjectUID
Parentkey: (none)
Display Value: ProjectName
Is default: (none)
But when I add these web part to my page I see this error:
“There was a problem preparing the WebPart for display.
Column 'ProjectName' does not allow nulls.”
I don’t know what should I do
is there any other wy to do this?Hi,
I have a similar issue, did you manage to find a solution?
Maybe you are looking for
-
When clicking on a link within our Website, the PDF results go to my download folder. To view my PDF results, I am required to go to my Adobe Reader and open that corresponding PDF file. It would be great if I could simply view the PDF on the screen
-
Anybody can help?
-
HT5824 how can i retrieve my photos and notes ?
My ipad mini stopped working in July, and Apple replaced it with a new device, however i lost all my notes and photos, so from the lesson learnt i have been taking downloads into my laptop. Today, when i tried the same, it displayed the new serial nu
-
How to add filter at select options?
Hi friends, I believe there should be a way to add filter, but I don't know where it is. The call is like this: wd_this->r_selopt->if_wd_select_options~add_selection_field( i_id = 'ACT_CAT' it_result
-
Re-route sales and cost of sales for shipments to vendors.
We are increasing a process where we will ship raw materials to a vendor, they will use this material in production for a finished good that the vendor will sell back to us. It is not sub-contracting, since we would sell these raw materials in bulk.