CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #6
    Join Date
    May 2009
    Posts
    2,413

    Re: Building bridges

    Quote Originally Posted by codedhrj View Post
    Thefore, maximum number of overlapping bridges are 2.
    Thank you, I get it now.

    I think you've come up with a nice solution strategy. First sorting the bridges according to "from" and then finding the longest increasing subsequence among the "to". That would correspond to the largest number of non-intersecting bridges.

    The sorting is O(N*logN) but it looks like you have an O(N^2) algorithm for the subsequence part. According to this link, O(N*logN) is possible for the latter also,

    http://en.wikipedia.org/wiki/Longest...ng_subsequence

    That means a solution with a total complexity of O(N*logN) is possible for this problem.
    Last edited by nuzzle; May 31st, 2013 at 02:37 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured