📣 独立日限时特惠: VIP通行证立减$68
查看: 3410| 回复: 15
跳转到指定楼层
上一主题 下一主题
收起左侧

[公开课] [Stanford] Algorithms: Design and Analysis, Part 1 Week # 5

全局:
公开课
学校名称: Stanford
Unit号: 5
开课时间: 2014-04-20
课程全名: Algorithms: Design and Analysis, Part 1
平台: Coursera

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
交作业





上一篇:[Coursera]Software Defined Networking-Week2
下一篇:Berkeley CS 61B Data Structures(in Java) Homework4 加分+讨论帖
推荐
麻倉枼 2014-6-15 13:28:27 | 只看该作者
全局:
chouclee 发表于 2014-6-15 00:17
https://class.coursera.org/algo-005/forum/thread?thread_id=88

Using the assignment dataset but  ...

decrease priority 是这样写吗?
        public void decreasePriority(Heap heap, Node[] vertexList, int index){
               
               
                int left = index *2;
                int right = index * 2+1;
                int smallest = index;
       
                if(left < size && right < size){
                        if(array[left].getDistance() < array[right].getDistance()){
                                smallest = left;
                        }
                        if(array[right].getDistance() < array[left].getDistance()){
                                smallest = right;
                        }
                       
                        if(smallest != index){
                                swap(array, index, smallest, vertexList);
                                decreasePriority(heap, vertexList, smallest);
                        }
                       
                }

bubbleUp是这样写吗?
public void bubbleUp(Heap heap, Node child, Node parent, Node[] vertexList){
               
                if(child.getDistance() < parent.getDistance()){
                        // Format: swap(array, parent index position, child index positin, vertexList);
                        swap(array, child.getIndexPosition() / 2, child.getIndexPosition(), vertexList);
                       
                        parent = array[child.getIndexPosition() / 2];
                       
                        bubbleUp(heap, child, parent, vertexList);
                }
回复

使用道具 举报

推荐
chouclee 2014-6-15 13:17:09 | 只看该作者
全局:
麻倉枼 发表于 2014-6-15 13:11
就差那么一点有谁能给答案我查一下错误?好紧张啊都写出来了找不出bug啊。。test case 都正确

https://class.coursera.org/algo-005/forum/thread?thread_id=88

Using the assignment dataset but with starting node 29 (instead of 1):

1 3540
2 4420
3 4538
4 5445
5 3317
6 4903
7 4048
8 3769
9 4032
10 4206
11 3649
12 3310
13 2784
14 3944
15 2451
16 4361
17 4249
18 1790
19 3154
20 2947
这个是最准的
回复

使用道具 举报

推荐
麻倉枼 2014-6-15 13:23:08 | 只看该作者
全局:
chouclee 发表于 2014-6-15 00:17
https://class.coursera.org/algo-005/forum/thread?thread_id=88

Using the assignment dataset but  ...

我的程序是永远从1开始弄的所以测试不了啊
回复

使用道具 举报

🔗
breezet 2014-6-3 10:52:46 | 只看该作者
全局:
回复

使用道具 举报

🔗
kelvinzhong 2014-6-3 14:43:04 | 只看该作者
本楼:
全局:
作业作业
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
Sin 2014-6-12 09:31:17 | 只看该作者
全局:
assignment for week5~
更多图片 小图 大图
组图打开中,请稍候......
回复

使用道具 举报

🔗
chouclee 2014-6-15 00:49:40 | 只看该作者
全局:

回复

使用道具 举报

🔗
asiawildboar 2014-6-15 06:34:10 | 只看该作者
全局:
deadline是第一生产力。。。
回复

使用道具 举报

🔗
麻倉枼 2014-6-15 13:11:22 | 只看该作者
全局:
就差那么一点有谁能给答案我查一下错误?好紧张啊都写出来了找不出bug啊。。test case 都正确
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表