shortest distance of convex polygon with start and exit problem










0















I've been asked the following question:
You have N points, where two of them are the "start" and "exit"
You want to start at "start", go through every other node, and end up at "exit". What is the shortest path (using Euclidean distance) if the polygon formed by the N nodes is convex? Is there a better algorithm than brute force here?



edit1:



It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution



edit2:



One interesting case is this one:
Consider a very long and narrow rectangle, where the points are on the long sides of the rectangle, one in front of the other.
The start and exit points are on the opposite ends of this "tunnel"
doing a clockwise or counterclockwise turn you would end up travelling 2*L where L is the size of the long side of the rectangle.
Doing a zig-zag from start to end would be optimal here, since you only need to go through L once, and then some small steps from one side to the other.










share|improve this question
























  • If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

    – Turnsole
    Nov 13 '18 at 22:58











  • @Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

    – serianox
    Nov 13 '18 at 23:32











  • Then you should edit your question description so that it does not seem that the question is a homework.

    – Shudipta Sharma
    Nov 14 '18 at 3:58















0















I've been asked the following question:
You have N points, where two of them are the "start" and "exit"
You want to start at "start", go through every other node, and end up at "exit". What is the shortest path (using Euclidean distance) if the polygon formed by the N nodes is convex? Is there a better algorithm than brute force here?



edit1:



It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution



edit2:



One interesting case is this one:
Consider a very long and narrow rectangle, where the points are on the long sides of the rectangle, one in front of the other.
The start and exit points are on the opposite ends of this "tunnel"
doing a clockwise or counterclockwise turn you would end up travelling 2*L where L is the size of the long side of the rectangle.
Doing a zig-zag from start to end would be optimal here, since you only need to go through L once, and then some small steps from one side to the other.










share|improve this question
























  • If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

    – Turnsole
    Nov 13 '18 at 22:58











  • @Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

    – serianox
    Nov 13 '18 at 23:32











  • Then you should edit your question description so that it does not seem that the question is a homework.

    – Shudipta Sharma
    Nov 14 '18 at 3:58













0












0








0








I've been asked the following question:
You have N points, where two of them are the "start" and "exit"
You want to start at "start", go through every other node, and end up at "exit". What is the shortest path (using Euclidean distance) if the polygon formed by the N nodes is convex? Is there a better algorithm than brute force here?



edit1:



It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution



edit2:



One interesting case is this one:
Consider a very long and narrow rectangle, where the points are on the long sides of the rectangle, one in front of the other.
The start and exit points are on the opposite ends of this "tunnel"
doing a clockwise or counterclockwise turn you would end up travelling 2*L where L is the size of the long side of the rectangle.
Doing a zig-zag from start to end would be optimal here, since you only need to go through L once, and then some small steps from one side to the other.










share|improve this question
















I've been asked the following question:
You have N points, where two of them are the "start" and "exit"
You want to start at "start", go through every other node, and end up at "exit". What is the shortest path (using Euclidean distance) if the polygon formed by the N nodes is convex? Is there a better algorithm than brute force here?



edit1:



It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution



edit2:



One interesting case is this one:
Consider a very long and narrow rectangle, where the points are on the long sides of the rectangle, one in front of the other.
The start and exit points are on the opposite ends of this "tunnel"
doing a clockwise or counterclockwise turn you would end up travelling 2*L where L is the size of the long side of the rectangle.
Doing a zig-zag from start to end would be optimal here, since you only need to go through L once, and then some small steps from one side to the other.







algorithm data-structures graph-algorithm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 12:26







serianox

















asked Nov 13 '18 at 22:14









serianoxserianox

144




144












  • If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

    – Turnsole
    Nov 13 '18 at 22:58











  • @Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

    – serianox
    Nov 13 '18 at 23:32











  • Then you should edit your question description so that it does not seem that the question is a homework.

    – Shudipta Sharma
    Nov 14 '18 at 3:58

















  • If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

    – Turnsole
    Nov 13 '18 at 22:58











  • @Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

    – serianox
    Nov 13 '18 at 23:32











  • Then you should edit your question description so that it does not seem that the question is a homework.

    – Shudipta Sharma
    Nov 14 '18 at 3:58
















If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

– Turnsole
Nov 13 '18 at 22:58





If you want help with a homework question, you need to show some effort here. Do you suspect there is a better algorithm than brute force? What would it be like?

– Turnsole
Nov 13 '18 at 22:58













@Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

– serianox
Nov 13 '18 at 23:32





@Turnsole Not a homework question. It was a problem asked in TAP in 2016 (Argentinian Programming Competition) and it was mentioned to me today. I suspect there must be a better than bruteforce algorithm here using the convexity property otherwise they woudn't ask it on a competition. Also the constraints for N were N < 400 so it wound't be solvable with a O(n!) solution

– serianox
Nov 13 '18 at 23:32













Then you should edit your question description so that it does not seem that the question is a homework.

– Shudipta Sharma
Nov 14 '18 at 3:58





Then you should edit your question description so that it does not seem that the question is a homework.

– Shudipta Sharma
Nov 14 '18 at 3:58












1 Answer
1






active

oldest

votes


















0














Is there a better algorithm than brute force here?



If you think this problem with dynamic programming you can get a solution O(n^2) that is possible to solve constraint for the constraint n < 400.



This link has a good explication, see problem B: https://caloventorendos.blogspot.com/2016/09/solucionario-tap-2016.html






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290319%2fshortest-distance-of-convex-polygon-with-start-and-exit-problem%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Is there a better algorithm than brute force here?



    If you think this problem with dynamic programming you can get a solution O(n^2) that is possible to solve constraint for the constraint n < 400.



    This link has a good explication, see problem B: https://caloventorendos.blogspot.com/2016/09/solucionario-tap-2016.html






    share|improve this answer



























      0














      Is there a better algorithm than brute force here?



      If you think this problem with dynamic programming you can get a solution O(n^2) that is possible to solve constraint for the constraint n < 400.



      This link has a good explication, see problem B: https://caloventorendos.blogspot.com/2016/09/solucionario-tap-2016.html






      share|improve this answer

























        0












        0








        0







        Is there a better algorithm than brute force here?



        If you think this problem with dynamic programming you can get a solution O(n^2) that is possible to solve constraint for the constraint n < 400.



        This link has a good explication, see problem B: https://caloventorendos.blogspot.com/2016/09/solucionario-tap-2016.html






        share|improve this answer













        Is there a better algorithm than brute force here?



        If you think this problem with dynamic programming you can get a solution O(n^2) that is possible to solve constraint for the constraint n < 400.



        This link has a good explication, see problem B: https://caloventorendos.blogspot.com/2016/09/solucionario-tap-2016.html







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 '18 at 3:47









        ivangalbanivangalban

        5116




        5116



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290319%2fshortest-distance-of-convex-polygon-with-start-and-exit-problem%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3