📣 Back to School开学季 - VIP通行证5折优惠!蓝莓、Offer多多同步优惠
查看: 3077| 回复: 3
跳转到指定楼层
上一主题 下一主题
收起左侧

[Udacity CS 215] Algorithms (Final Exam)

全局:
公开课
学校名称: Rutgers University
Unit号: 7
开课时间: 2012-05-28
课程全名: CS215 Algorithms
平台: Udacity

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

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

x
  
previously:
第六个unit  http://www.1point3acres.com/bbs/thread-37918-1-1.html
第五个unit  http://www.1point3acres.com/bbs/thread-37701-1-1.html
第四个unit  http://www.1point3acres.com/bbs/thread-37651-1-1.html
第三个unit  http://www.1point3acres.com/bbs/thread-37565-1-1.html
第二个unit  http://www.1point3acres.com/bbs/thread-37403-1-1.html
第一个unit  http://www.1point3acres.com/bbs/thread-37390-1-1.html

期末考试

第一题
# Write a function, `bipartite` that
# takes as input a graph, `G` and tries
# to divide G into two sets where
# there are no edges between elements of the
# the same set - only between elements in
# different sets.

官方提示(下同):用图遍历算法生成两个列表A和B; 如果把一个节点标记为A那它的邻居就标记为B,任何相邻的节点都不能同号。


第二题
# Take a weighted graph representing a social network where the weight
# between two nodes is the "love" between them.  In this "feel the
# love of a path" problem, we want to find the best path from node `i`
# and node `j` where the score for a path is the maximum love of an
# edge on this path. The returned path doesn't need to be simple, ie it can
# contain cycles or repeated vertices.

用BFS先算出从出发点到每个点的最大距离和路径。


第三题
# In lecture, we took the bipartite "Marvel" graph,
# where edges went between characters and the comics
# books they appeared in, and created a weighted graph
# with edges between characters where the weight was the
# number of comic books in which they both appeared.
#
# In this assignment, determine the weights between
# comic book characters by giving the probability
# that a randomly chosen comic book containing one of
# the characters will also contain the other


根据公式W(a, b) = W(b, a) = P(contains A and contains B | contains A or contains B) 依次计算所有character顶点对


第四题
# We want you to take the list of flights, and create a
# graph.  Then, write a modified Dijkstra's algorithm to find the best
# combination of flights to get between two cities, where flights `x`
# is better than flights `y` if `x` has lower cost *or* if they are
# tied in cost, `x` has shorter total flight time.

把做Dijkstra时用的heap加一维"总飞行时间"。


第五题
# Design and implement an algorithm that can preprocess a
# graph and then answer the question "is x connected to y in the
# graph" for any x and y in constant time Theta(1).

BFS一次,标号。不同的连通分量的顶点属于不同号。


第六题
# In the shortest-path oracle described in Andrew Goldberg's
# interview, each node has a label, which is a list of some other
# nodes in the network and their distance to these nodes.  These lists
# have the property that
#
#  (1) for any pair of nodes (x,y) in the network, their lists will
#  have at least one node z in common
#
#  (2) the shortest path from x to y will go through z.
#
# Given a graph G that is a balanced binary tree, preprocess the graph to
# create such labels for each node.  Note that the size of the list in
# each label should not be larger than log n for a graph of size n.

从根节点开始,每次为孩子节点建label时,利用父节点label和父子节点间的边距离。


第七题
# This is the same problem as "Distance Oracle I" except that instead of
# only having to deal with binary trees, the assignment asks you to
# create labels for all tree graphs.

找出当前图的"中心节点",更新所有相连的节点的label,删除该"中心节点",重复该过程。找中心节点的做法是在树中找出一条最长路径(对于图来说是NPC问题,但是对于树是P问题),然后在把路径的中间作为中心节点。
参考 http://stackoverflow.com/questions/3124566/binary-tree-longest-path-between-2-nodes


第八题
# Each edge (u,v) in a social network has a weight p(u,v) that
# represents the probability that u would do a favor for v if asked.
# Note that p(v,u) != p(u,v), in general. 呵呵 男女不平等呀~
#
# Write a function that finds the right sequence of friends to maximize
# the probability that v1 will do a favor for v2.
#
# We provide two standard versions of dijkstra's algorithm that were
# discussed in class. One uses a list and another uses a heap.

根据边数M和顶点数N的关系决定用heap还是用list的方式做dijkstra。 heap需要O(M*logN)。list需要O(N^2)。 另外,由于图中边的权重都为0到1的小数,可以用log把他们放大再做dijkstra。
  
  
   



上一篇:[Udacity CS 215] Algorithms (Week #6)
下一篇:Coursera的Princeton的Advanced CompArch课程已经开始.欢迎积极讨论
🔗
 楼主| defjex 2012-8-26 13:17:41 | 只看该作者
全局:

评分

参与人数 1学分 +1 收起 理由
Shuang7 + 1

查看全部评分

回复

使用道具 举报

🔗
writecoffee1 2012-9-6 10:12:22 | 只看该作者
全局:
Finally finish all the final exam questions with HIGHEST DISTINCTION. Cheers!!

Is there any way to get credits from 1p3 forum?

点评

yeah. please put your screen-shot here. and 1学分 will be granted.  发表于 2012-9-7 12:01
回复

使用道具 举报

🔗
zzwcsong 2013-11-14 14:26:25 | 只看该作者
全局:
Only finish the first 3 questions...Feel so frustrated when I try to solve the problem 4-8

certificate_cs215.jpg (85.5 KB, 下载次数: 1)

certificate_cs215.jpg

评分

参与人数 1学分 +1 收起 理由
Shuang7 + 1

查看全部评分

回复

使用道具 举报

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

本版积分规则

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