The algorithms in my homework

hello
1. A cost-map contains M*N cells, we have the cost rate for each individual cell.
2. The path is defined as a sequence of cells that connect to each other directly.
3. If two cells are in the same row or column, and there is no cell between them, these two cells are defined as directly connected.
4. The cost of a path is the summary of all the cells’ costs involved.
question:
you are required to find out a cheapest path from one specified cell to another.
i have designed several class architecture as follow,maybe they are not complete,but it is not important,what i more care about is:how can i implement the algorithm to find the cheapest path?,who can give me the code snippet about the algorithm to get the cheapest path?or where can i find it?
thank you!
public class Map{
int A;
int B;
public Cell getCell(int row, int col){
public Cell getStartCell(){
public Cell getTargetCell(){
A: is the row number of the map
B: is the column number of the map
getCell returns the Cell with row and column specified. The start index is 0.
getStartCell and GetTargetCell return the start and end cell of the problem.
public class Cell{
int row;
int col;
public int getCost(){
public class Trace{
public int getTraceLength(){}
public Cell getCell(int n){}
public int getCost(){}
getTraceLength returns how many cells are involved in this trace.
getCell returns the number n cell in this trace.
getCost returns the total cost of this trace.

>
i have designed several class architecture as
follow,maybe they are not complete,Obviously.
but it is not important,Yes it is. If you'd done more you might have gotten some help. What you're asking is: "Will someone do my homework for me?" That's not what the forum is about.
what i more care about is:I'll bet it is.
how can i implement the algorithm to find the cheapest path?,
Write more Java code.
who can give me the code snippet about the algorithm to get the cheapest path?or where can i find
it?Try a Google search or go to the library. I'm sure the algorithm is in a book somewhere. - MOD

Similar Messages

  • Help required in implementing the algorithm

    Actually I am brand new to the java programming, and i need some help to implement the algorithm below in java.
    I have the dataset required for the execution,
    Can any body please help me?
    Input: (1) a source database D,
    (2) a min support,
    (3) a min confidence,
    (4) a set of recommended items Y
    Output: a transformed database D, where rules containing
    Y on RHS will be hidden
    1. Find large 1-item sets from D;
    2. For each hidden item y �� Y
    3. If y is not a large 1-itemset, then Y := Y − {y};
    4. If Y is empty, then EXIT;// no AR contains Y in RHS
    5. Find large 2-itemsets containing items in Y from D;
    6. For each y �� Y {
    7. For each large 2-itemset containing y {
    8. Compute confidence of rule U, where U is a rule likex �� y;
    9. If confidence(U) �� min conf, then { //Calculate # of transactions required to lower the confidence of U
    10. Calculate iterNumConf = _|D|∗(supp(xy) − minconf ∗supp(x))_;
    //Calculate # of transactions required to lower the support of U
    11. Calcualte iterNumSupp = _|D|∗(supp(xy)− min supp)_;
    12. Calculate k = minimum (iterNumConf, iterNumSupp);
    13. Calculate |TR| = |xy|; //|TR|: # of transactions inTR
    14. if k > |TR|
    15. Can not hide U;
    16. else {
    17. Find T kR = first k transactions that contain xy;
    18. Sort T kR in ascending order by the number of items;
    19. for i = 1 to iterNum do { 20. Choose the first transaction t from T kR ;
    21. Modify t so that y is not supported, the RHS(U);
    22. |xy| = |xy| − 1; // update support count of xy
    23. confidence(U) = |xy|/|x|; // update confidence
    24. Remove and save the first transaction t from T kR ;
    25. }; // end for iterNum
    26. }; // end if confidence(U)
    27. }; // end of each large 2-itemset
    28. Remove y from Y;
    29. } // end of for each y
    30. Output updated D, as the transformed D;

    The way you post that, it looks very much like "Do my work for me". Nobody around here likes that kind of post, they consider it lazy and selfish. But perhaps you didn't mean it that way? Why don't you explain what you have done and what parts of it you are having problems with. Explain those problems in detail.

  • I want to know the algorithm of interpolation of 2-D array in LabVIEW.

    I want to know the algorithm of interpolation of 2-D array in LabVIEW.Is there any formation about it?

    Hi ,
    For all delta and full DTP loads you can get  information in table  RSICCONT .Check table  RSMONICDP  this will give you detail information .Here you will get all the information with timestamp and request id .
    Hope these tables will serve your purpose .
    Regards,
    Jaya

  • Constraining the algorithm for assignment of multiple plot colors

    I would like to know if there is some way to modify the algorithm that
    LabVIEW uses to automatically assign different colors when a graph
    displays multiple plots. In particular, given the default background
    color (black), it appears that black is never used for a plot color.
    However, if I programmatically change the background color to white,
    for example, I would like the plot color assignment to not use white. I
    would also like to know if it is possible to constrain the plot color
    assignment to a single color a priori, without having to go back and
    explicitly assign the colors of each plot via the property node in a
    loop.
    Thanks.
    Lyle

    I think you will have to create your own plot color assignment function to do this.
    You can set the color of each plot by using the active plot property (index of the plot you want to change) and then set the plot color property (just expand one and the same property ndoe to set both at the same time).
    You can then make that function check the background color and choose a color table that fits. If this is in a built application you would run this function when a color change is detected, if it's in the development environment you need this feature make the function ask for a VI and plot name (so that it can get a reference to the plot) and put it in your projects folder. That way whenever you need to set the plot colors differently you just select this function from the Tools menu of LabVIEW. An easier alternative though would be to just create the different graphs you need (with the colors for all plots already defined correctly for that background etc.) and save them as custom indicators...
    MTO

  • What is the algorithm for this?

    if I have a string 000111 (or any amount of zeros and ones), what is the algorithm for me to get all possible combinations? (001011, 001101, ...)

    Odd but the following code does not yeild the results you list in your post. Maybe you have a mistake? Or am I missing something?
    class test
    public int[] getC(int[] c, int n)
              int m= c.length;
              for (int i= m; i-- > 0;)
                   if (++c[i] <= n-(m-i))
                        while (++i < m)
                             c= c[i-1]+1;
                        return c;
              return null;
         public static void main(String[] args)
              test t = new test();
              int[] input = {0,1};
              int n = 4;
              int[] res = t.getC(input, n);
              for (int i = 0; i < res.length; i++)
                   System.out.println(res[i]);

  • Compare the algorithm development  processs and the SDLC is related or not?

    Compare the algorithm development processs and the SDLC. are these 2 things related or not related concepts?
    or these 2 things are two different concepts? or do they have siimiilar things? or can they inter apply the concepts?
    For algo, from the problem ---> prototype ---> Pseudo code----> program ----->program model ( not 100% correct for each phase)
    For SDLC, from Requirment ans Analysis (collect client requiremens and analyise it.) ---->Design phase(prepare design according to the requirements) ----->Coding phase(actul programing has been done)----->Testing phase(the tester find the bugs)------>Implementation -----> Maintanence
    Edited by: 799630 on 2010年10月2日 下午8:43

    We can't bust heads like we used to. But we have our ways. One trick is to tell stories that don't go anywhere. Like the time I caught the ferry to Shelbyville. I needed a new heel for m'shoe. So I decided to go to Morganville, which is what they called Shelbyville in those days. So I tied an onion to my belt. Which was the style at the time. Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on 'em. Gimme five bees for a quarter, you'd say. Now where was I... oh yeah. The important thing was that I had an onion tied to my belt, which was the style at the time. You couldn't get white onions, because of the war. The only thing you could get was those big yellow ones...

  • Please send the algorithm and project code for temperature sensing using daq usbdux fast if possible code also for general text gui icon programming.

    I have a daq card usb dux fast and I'm using linux zenwalk,
    so please if any one has done a program on daq using comedi language or any language or any other related to it.
    please send me the code and algorithm for it.
    if possible a algorithm and code for general gui text icon programming to [email protected]
    thanking you,

    Hi Vinay,
    you know you're posting in a LabVIEW forum?
    When you have questions on Comedi you should post in a Comedi-related forum!
    Or read some papers/manuals like this, easily found by Google...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • What is the Algorithm Used by the LabVIEW Remote panels?

    Hi
    Has any one had any idea about how dose "LabVIEW Remote Front Panels " works and its Algorithm?

    Is it possible to intercept data values transferred from server to
    remote computer display and put them in a text file for post-processing
    ? Each data value is accessible individually with graphic cursor but I
    don't know how to store the whole set of data.
    Thank you for your help
    Greg McKaskle a écrit:
    >> Has any one had any idea about how dose "LabVIEW Remote Front Panels "
    >> works and its Algorithm?
    >
    >
    > I'm not sure I know what it is you are asking. Roughly, the Remote
    > Front Panels feature transfers the panel of a given VI from the server
    > to your remote client machine. The client machine must be running
    > either a LV debugging environment, a plugin app, or a plugin ActiveX
    > control -- the latter two will also use the runtime en
    gine. The plugin
    > app will load the LV front panel and connect keep a connection to the
    > server. Each time the server updates a value or property on a panel, it
    > will send the information to the remote computer(s). This allows for
    > remote viewing of a panel running on the server.
    >
    > If you take control of the VI on the client by right clicking and
    > selecting the menu item, the client will also be sending the clicks and
    > keys sent to the remote panel to the server. The server will process
    > them in the diagram, and the results will affect panels.
    >
    > Please be more specificif this didn't answer your question.
    >
    > Greg McKaskle
    >

  • Help me to get the algorithm for this assingment.

    I have tried to draw the x-y axis and the rectangle. I hava a problem to draw the rectangle inside of the lablled grid.
    NEED EVERYONE'S HELP HERE!
    Assignment #4
    Goal:
    �     This lab gives students more experience in
    �     developing proper algorithms for real-life problems;
    �     using program constructs � sequential, selection, and repetition.
    Algorithm. An algorithm is a description of steps to solve a problem that is unambiguous, executable, and terminating. In order to solve a problem by computer, you must know an algorithm for finding a solution.
    Problem Description
    Develop an algorithm and then write a java program that can accept commands from the user to draw a rectangle. The program should accept the xy-coordinate pair of the upper-left corner, and the width and height of a rectangle. It should then draw the rectangle pattern on a 40 X 20 labelled grid. For example, if the upper-left corner is (5, 10) with a width of 10 and height of 5, then the program would display:
    ^
    20+
    |     
    |
    |
    |
    |     
    15+
    |
    |
    |
    |     
    10+
    | ++++++++++
    | ++++++++++
    | ++++++++++
    | ++++++++++
    5+ ++++++++++
    |
    |
    |
    |     
    ________________________________>
    0 5 10 15 20 25 30 35 40     
         Upper Left (5,10) width:10, Height: 5
    NOTE:
    �     Your display should include the labelled axis, as shown on the previous page, and also the lines that are drawn horizontally across the page.
    �     Make sure the rectangle will fit on the 40X20 grid.
    �     Appropriate error messages must be displayed for invalid data provided by the user.

    If you format your code, it looks like thispublic class Rectangle {
      public static void main(String[] args) {
        int maxYAxisPoint = 20;
        int maxXAxisPoint = 40;
        int xCoodinate = 5;
        int yCoodinate = 10;
        int width = 5;
        int height = 10;
        int leftLowPoint;
        System.out.println("This program draw a rectangle pattern on a 40*20 labelled grid.");
        System.out.println("Please enter the x-coordinate of the upper left point: ");
        xCoodinate = MyIO.readLineInt();
        System.out.println("Please enter the y-coordinate of the upper left point: ");
        yCoodinate = MyIO.readLineInt();
        System.out.println("Please enter the width of the rectangle: ");
        width = MyIO.readLineInt();
        System.out.print("Enter the height of the rectangle:");
        height = MyIO.readLineInt();
        if (yCoodinate < maxYAxisPoint && yCoodinate + width < 40 ||
            xCoodinate + width < maxXAxisPoint &&
            xCoodinate + height < maxYAxisPoint) {
          System.out.println(" ^");
          for (maxYAxisPoint = 20; maxYAxisPoint >= 0; maxYAxisPoint--) {
            if ( (maxYAxisPoint % 5) == 0) {
              System.out.println(maxYAxisPoint + "+");
              for (leftLowPoint = (maxYAxisPoint - height) + 1;
                   leftLowPoint <= yCoodinate; leftLowPoint--) {
                System.out.println("+");
              //Draw the x-axis
              for (maxXAxisPoint = 0; maxXAxisPoint <= 40; maxXAxisPoint++) {
                System.out.print("+____");
                System.out.println("+>");
              for (maxXAxisPoint = 0; maxXAxisPoint <= 40; maxXAxisPoint++) {
                System.out.print(maxXAxisPoint + " ");
            } else {
              System.out.print(" | \n" + " |\n" + " |\n" + " |");
        } else {
          System.out.print("You entered a wrong x-y coordinate of the rectangle,\n the rectangle is not in the labelled grid.");
        System.out.print("Upper Left(" + xCoodinate + "," + yCoodinate + ")");
        System.out.print("width:" + width);
        System.out.println("height: " + height);
    }You have nested your loops. I'm pretty sure you don't want to do this. Here's an example of the difference. First a nested looppublic class Test2 {
      public static void main(String[] args) {
        for (int i=0; i<3; i++) {
          System.out.println("i="+i);
          for (int j=0; j<4; j++) {
            System.out.println("  j="+j);
    Outputs this
    i=0
      j=0
      j=1
      j=2
      j=3
    i=1
      j=0
      j=1
      j=2
      j=3
    i=2
      j=0
      j=1
      j=2
      j=3Now an unnested looppublic class Test2 {
      public static void main(String[] args) {
        for (int i=0; i<3; i++) {
          System.out.println("i="+i);
        for (int j=0; j<4; j++) {
          System.out.println("  j="+j);
    outputs this
    i=0
    i=1
    i=2
      j=0
      j=1
      j=2
      j=3This means you are printing the x-axis for every point on the graph.

  • Does anyone know the algorithm behind photoshop's Trace Contour Filter?

    Hello There!
    I am a student currently working on a Computer Science project and using Photoshop's Trace Contour filter is excellent at tracing edges of any image.  Does anyone know the exact algorithm that Adobe uses to implement the Trace Contour Filter? Online it just says that it looks at difference in brightness to trace the edges, but is it a modification of Canny, Sobel or any other known Algorithms? Does it use Moore neighborhood to calculate it the edges? If anyone has any idea, I would appreciate it.
    Thanks!

    Set this option:
    -Noel

  • Shell Sort - Printing Each step in the algorithm

    i have this shell sort algorithm, and i want to print out each step it takes to sort the array of numbers... i just am having trouble finding the proper spot to insert the print(a); statement
    public class ShellSort
    { public static void main(String[] args)
    { int[] a = { 59,20,17,13,28,14,23,83,36,98,11,70,65,41,42,15 };
    sort(a);
    print(a);
    public static void print(int[] a)
    { for (int i=0; i
    System.out.print(a +" ");
    System.out.println();
    public static void sort(int[] a)
    { int d=1, j, n=a.length; // step 1
    while (9*d
    d = 3*d + 1; // step 3
    while (d>0) // step 4
    { for (int i=d; i
    { int temp=a ;
    j=i;
    while (j>=d && a[j-d]>temp)
    { a[j] = a[j-d];
    j -= d;
    a[j] = temp;
    d /= 3; // step 6
    }any suggestions or hints???
    thanks,
    scott.

    i'm sorry about the readability...
    //  Scott Garshwiler
    //  Example 13.2 taken from page 244 of Schaum's Outline
    //  Testing the Shell Sort
    //  Everything works  cost= theta(n^1.5)
    public class ShellSort
    { public static void main(String[] args)
      { int[] a = { 59,20,17,13,28,14,23,83,36,98,11,70,65,41,42,15 };
        sort(a);
        print(a);
      public static void print(int[] a)
      { for (int i=0; i<a.length; i++)
          System.out.print(a[i]+" ");
        System.out.println();
      public static void sort(int[] a)
      { int d=1, j, n=a.length; // step 1
        while (9*d<n) // step 2
          d = 3*d + 1; // step 3
        while (d>0) // step 4
        { for (int i=d; i<n; i++) // step 5
          { int temp=a;
    j=i;
    while (j>=d && a[j-d]>temp)
    { a[j] = a[j-d];
    j -= d;
    a[j] = temp;
    d /= 3; // step 6

  • What's wrong with the Algorithm? Please resond ASAP!!!

    I've been tinkering with this for hours! How do you reverse the order of the elements in an array!
    Here's my code:
    import java.io.*;
    public class Main {
         public static void main(String[] args) {
              char tp = 'o';
              char temp;
              char[] array = new char[5];
              RadReader reader = new RadReader();
              System.out.println("Welcome to the RadReader demo!");
              System.out.println();
              System.out.print("Type in a phrase: ");
             array = reader.readCharArray(array.length);
              for(int i = 0; i < array.length; i++) {
                   temp = array;
                   array[i] = array[array.length - 1 - i];
                   array[array.length - 1 - i] = temp;
              System.out.print("Your phrase typed backwards is: ");
              System.out.print(array);
              System.out.println();     
    What did I do wrong?

    This seems to do it:
    public class StringReverser
        public static void main(String[] args)
            for (int j = 0; j < args.length; ++j)
                char [] origChars = new char[args[j].length()];
                args[j].getChars(0, args[j].length(), origChars, 0);
                int l = origChars.length;
                for (int k = 0; k < l/2; ++k)
                    char temp            = origChars[k];
                    origChars[k]         = origChars[l - 1 - k];
                    origChars[l - 1 - k] = temp;
                System.out.println("original: " + args[j]);
                System.out.println("reverse : " + new String(origChars));

  • Tablet Zip the file through the algorithm

    My requirment is that I am to zip the file in xi and send to receiver using Soap Adapter. From Receiver again response will go to sender via XI. At the sender side again I want zipped file. Is it possible...
    Do i need to unzip the file at receiver end to make a request.

    Hi Jaideep,
    Ya its possible. You can use the PayloadZipBean for the same. You can both zip and unzip the file using this bean. Use this blog for the same:
    Working with the PayloadZipBean module of the XI Adapter Framework
    And ya you will have to unzip the content of the file if you are to get back a response from the rceiver.
    Regards,
    Sanjeev.

  • Break the algorithm through sql query

    Hi,
    My table 'x' contains data as follows:
    Row_id
    Person
    Effective_date
    Status
    Code
    1
    12345
    8-Apr-04
    POS
    A
    2
    12345
    13-Jun-04
    PLA
    P
    3
    12345
    20-Oct-04
    POS
    P
    4
    12345
    1-Apr-05
    PAY
    P
    5
    12345
    8-Aug-05
    RFL
    A
    6
    12345
    8-Aug-05
    XFR
    A
    7
    12345
    1-Apr-05
    PAY
    P
    Need this row as output
    8
    12345
    14-Jul-06
    LOA
    L
    9
    12345
    1-Oct-06
    PAY
    P
    10
    12345
    16-Jul-07
    LOA
    L
    11
    12345
    17-Jul-07
    RFL
    A
    Logic that should be used:
    1. Get the most recent row based on effective date and code in L or P-> In this case row 10 since this row has L and is latest one
    2. Then go back in time until the code is not in L or P -> so based on above data row 6 since the code is 'A'
    3. Then come forward from that record 6 until you get status LOA or PLA -> you will come and stand on row '8'
    4. finally i need the row_id = 8 as output based on the above steps
    Pls help me in framing a query for this

    Your effective dates are not unique, therefore it is impossible to decide which row with same effective date goes first. It is not possible to provide a deterministic solution until you define rules how to order rows with same effective date. Solution below is non-deterministic. Because you have rows with same effective date it can produce different results next time you run it. When you define ordering rules add them to ORDER BY clause of ROW_NUMBER function in below code. This will make it deterministic:
    with t1 as (
                select  e.*,
                        row_number() over(partition by emplid order by effective_start_date) rn
                  from  employee e
         t2 as (
                select  t1.*,
                        max(
                            case
                              when code in ('L','P') then rn
                            end
                          over(partition by emplid) last_l_p_rn,
                        last_value(
                                   case
                                      when code not in ('L','P') then rn
                                   end
                                   ignore nulls
                          over(partition by emplid order by rn) last_non_l_p_rn,
                        first_value(
                                    case
                                       when status in ('LOA','PLA') then rn
                                   end
                                   ignore nulls
                          over(
                               partition by emplid
                               order by rn
                               rows between current row and unbounded following
                             ) first_loa_pla_rn
                  from  t1
    select  emplid,
            effective_start_date,
            status,
            code
      from  t2
      where level = 3
      start with rn = last_l_p_rn
      connect by (emplid = prior emplid and rn = prior last_non_l_p_rn and level = 2)
              or (emplid = prior emplid and rn = prior first_loa_pla_rn and level = 3)
    EMPLID     EFFECTIVE STA C
    12345      14-JUL-06 LOA L
    SQL>
    SY.

  • I found Error in Statistics Express about the algorithm for mode

    LabVIEW 7.1 was used. today I acquired a lot of data and analyzed using Statistics Express in LabVIEW 7.1, whereas the results of mode were not correct because I analyzed the data using both Excel and SPSS. so I think there must be something wrong with Statistics Express in LabVIEW 7.1. Attached is the data which mode is 57.24 by SPSS, but the result of Statistics Express showed the result of 32.608.
    will someone please help me?
    thanks
    Attachments:
    data.xls ‏29 KB

    Hi,
    I agree the 2 places of decimals is a cosmetic property and I have no issue with that....
    I have my vi setup such that at one call it gets the mode of distances between points on lines. The second time I call the mode it is to get the mode of distances between another set of points. Two separate arrays in a fairly large program. I've attached a shortened sample hopefully the error still appears. Also I was wrong about wiring the intervals wire, this did not change anything.
    If I run the 2nd mode operation on it's own without the previous call it works fine, only when there is a previous mode operation does it fail to "re-initialise" and returns the result of the first mode operation.
    The only thing I can think of is that the first set of data has many different distances and gives a clear mode, whereas the second set has values approximately the same, with the odd multiple (ie 20,22,19,41,62,20,21,23). However, going against this is the Express Statistics vi which calculates the correct values in the Express Window (double clicking on it and selecting the statistics) but when wiring these to an indicator the result from the first mode operation is returned.
    Any suggestions welcomed.
    Kind regards,
    Leeser
    Attachments:
    mode_error_example.vi ‏143 KB

Maybe you are looking for

  • RAID for Consumer PCs

    If you have an interest in using RAID, then the MS Word document attached to this post may be useful information.  Scroll all the way to the bottom for the attachment. RAID for Consumer PCs Table of Contents RAID RAID 0 RAID 1 RAID 5 RAID 10 (0+1) IN

  • SFWordProcessing Plugin Error - Just started after Mac Updates

    Here is the error I am receiving after applying Apple updates to my system. Process: Pages [199] Path: /Applications/iWork '09/Pages.app/Contents/MacOS/Pages Identifier: com.apple.iWork.Pages Version: 4.0.3 (766) Build Info: Pages-7660000~2 Code Type

  • How manuplate data on multiple tables in the oracle resource adapter

    Hi all, I have a requirement to write an resource adapter for oracle. But the key point is that, the user creation has to add entries in several tables and same goes with updation and getting the results. Please help me with the code snippet, if any

  • Thumbnails and Previews have a green tinge

    The thumbnails and previews in my library have suddenly developed a green tinge. I have tried Update Previews, Generate Thumbnails, and Generate Previews with no success. I have also used Repair database and Rebuild database, again with no positive r

  • Table where picking quantity is

    Hi, Im looking for the table where the picking quantity of a delivery is saved. I thought it was lips but its not. Could you tell me, please? Thank you, Manel