新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> We choose to study algorithmic problems,  not because they are easy,  but because they are hard.
    [返回] 计算机科学论坛计算机理论与工程『 算法理论与分析 』 → 两个算法题 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 5670 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 两个算法题 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     kof02guy 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:8
      积分:82
      门派:XML.ORG.CN
      注册:2008/4/9

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给kof02guy发送一个短消息 把kof02guy加入好友 查看kof02guy的个人资料 搜索kof02guy在『 算法理论与分析 』的所有贴子 引用回复这个贴子 回复这个贴子 查看kof02guy的博客楼主
    发贴心情 两个算法题

    2 Given a directed weighted acyclic graph G = (V, E, W) and a vertex s, design an O(n+m) algorithm to find a longest path that starts from s, where n = |V|, m=|E|.  (Hint: Do topological sorting from s. (Only call DFS once.) Let v1 (= s), v2, v3, ...., vk, be the sorted sequence, k £ n. Define d(vi) to be the longest distance from s to vi. Initially, d(vi) = - ¥. Set d(v1) = 0.  If d(v1), d(v2), …, d(vi) have been computed, how to compute d(vi+1) ?)

    3 There are n terminals on each side of a circuit board indexed with 1, 2, …, n from left to right, as shown in the following figure. We need to connect terminal i (1 ≤ i ≤ n) on the top side with a unique terminal π(i) on the bottom side. In other words, we need n lines (i, π(i)) (1 ≤ i ≤ n) to connect n pairs of terminals. The following figure shows an example.


    Two lines (i, π(i)) and (j, π(j)) ( i &sup1; j) will cross each other if i < j but π(i) > π(j), or vice versa. Two lines are called compatible if they do not cross each other. We wish to find the largest set of mutually compatible lines so that they can be layout on the same layer of circuit without crossing each other.

    Please model this problem as a graph problem first and then design an O(n2) algorithm to solve it.


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2009/7/23 23:19:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 算法理论与分析 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/11/30 10:13:47

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    46.875ms