由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Weighted Graph Challenge 一道面试题
相关主题
An interview question存储 n 个directed weighted graph进数据库
C++如何实现graph?最新的MS面试题 (转载)
为什么无论Java还是Ruby,转成Node代码量都是几十倍的减少呢?good GUI for graph layout and flow?
听说有些公司用haskell代替nodeA Problem on MST
这个问题有什么好的解法(或现成code)吗?counting signed triad in a large-scale graph?
面题:copy directed graph说一道关于unbalanced树的面试题
问个关于数组的问题有难度的面试题
请教一个graph问题Re: 请教一道题目
相关话题的讨论汇总
话题: node话题: edges话题: go话题: outgoing话题: edge
进入Programming版参与讨论
1 (共1页)
s*****e
发帖数: 115
1
This is a simplified version of a real problem we encountered.
Your solutions will preferably be implemented in Go. We'll also consider
solutions implemented in Python (or other languages on request), but since
Go can be learned in approximately a day, we really do prefer a solution
written in Go.
We're building a directed graph.
The graph consists of Nodes connected by Edges.
Each Node has an ID (int64).
Each Node keeps track of its outgoing Edges (list of ids).
There might be thousands of outgoing Edges.
Each outgoing Edge also has an edge weight (float64).
The Node needs to maintain a sorted list of its outgoing Edges.
Operations are triggered on Nodes that might change edge weights.
Some Operations might update one edge weight, others many.
For the purposes of this exercise, the operation is a function that (
randomly) changes a few edge weights.
The sorted list needs to efficiently stay sorted even as many weights are
changed.
For the purposes of this exercise it's initially enough to focus on one Node
and its outgoing Edges (to Node IDs that don't need an instantiated Node)
Multiple edges can have the same weight.
We recommend to build on top of https://github.com/google/btree/ but are
interested to hear if you have a different take.
目前发现有另外一个解法,比如做双向链表,好像跟btree一样可以做到log(n),不想误导
大家,过几天更新和大家探讨
这个问题应该是可以partition然后计算的,甚至可以request来了以后,直接随机发到任
意server上然后用chord做peer-to-peer通讯最后到达request应该被送到的server上,
跳过master-slave这个model的
Go其实最适合拿来怎么用呢?有什么具体例子么?哪里会容易找这样的工作?
w***g
发帖数: 5958
2
btree是磁盘数据结构,如果是内存操作,就是overengineer了,不如红黑树。数据结
构问题貌似和服务器架构没啥关系。

solution

【在 s*****e 的大作中提到】
: This is a simplified version of a real problem we encountered.
: Your solutions will preferably be implemented in Go. We'll also consider
: solutions implemented in Python (or other languages on request), but since
: Go can be learned in approximately a day, we really do prefer a solution
: written in Go.
: We're building a directed graph.
: The graph consists of Nodes connected by Edges.
: Each Node has an ID (int64).
: Each Node keeps track of its outgoing Edges (list of ids).
: There might be thousands of outgoing Edges.

s*****e
发帖数: 115
3
可能这个题目的作者也没有想清楚,好像只要选一个BST就可以了?
doubly linked list能做到 initialize是nlogn(排序),剩下CRUD都是log n因为doubly
linked list可以binary search
关于架构,这个只是考虑到如果是maintain多个node(原题说只考虑一个node,one-to-
many),因为node之间的out-going edges是独立的,所以可以每个node都独立maintain一
个红黑树或者doubly linked list,只有删除node的时候需要互相通讯一下.

【在 w***g 的大作中提到】
: btree是磁盘数据结构,如果是内存操作,就是overengineer了,不如红黑树。数据结
: 构问题貌似和服务器架构没啥关系。
:
: solution

1 (共1页)
进入Programming版参与讨论
相关主题
Re: 请教一道题目这个问题有什么好的解法(或现成code)吗?
请问这道题怎么解决?面题:copy directed graph
HW Question: Bipartite Graphs问个关于数组的问题
[合集] 一个链表倒转的问题请教一个graph问题
An interview question存储 n 个directed weighted graph进数据库
C++如何实现graph?最新的MS面试题 (转载)
为什么无论Java还是Ruby,转成Node代码量都是几十倍的减少呢?good GUI for graph layout and flow?
听说有些公司用haskell代替nodeA Problem on MST
相关话题的讨论汇总
话题: node话题: edges话题: go话题: outgoing话题: edge