2014-04-24 00:38

题目:加入你要设计一个服务,供至多1000个client查询每日股票的最高、最低、开盘、收盘价,请描述你要如何设计这个服务。

解法:可以用SQL数据库组织,也可以用K-V数据库来提供更高性能。如果股票数量相对不大,还可以用XML文件组织数据。在百度里搜“BIDU”,或在Google里搜“GOOG”,就能看见例子了。

代码:

 1 // 10.1 Suppose you're to design the backend part of a system, which provides queries of real-time stock prices. How would you do it?
 2 // Answer:
 3 //    Go and search "GOOG" on Google or Baidu, you'll get the real-time stock price of Google. The data transferring is best done with AJAX to the frontend, which can greatly save the amount of data transferred.
 4 //    As for the backend part, you have to use some techniques to store the data:
 5 //        1. SQL database, easy for various kinds of structured queries. You won't expose the direct SQL API to external users because it is not safe. Write a wrapper with the web programming language.
 6 //            Strength: Ability to provide more information than you expected.
 7 //            Weakness: Not so agile, if the data structure changes. Altering a SQL table is always expensive.
 8 //        2. XML files, a good way to store structured data. Good performance when the data scale is small or medium.
 9 //            Strength: Agile, easy to modify the schema. Regenerating the XML file is usually easy with script languages such as python.
10 //            Weakness: Not suitable for large data scale, as you have to parse everything in the XML only to find an item inside.
11 //        3. No-SQL database
12 //            Strength: suitable for large scale, high concurrency, flexible with data schema changes.
13 //            Weakness: Don't know yet, maybe more space usage.
14 int main()
15 {
16     return 0;
17 }

转载于:https://www.cnblogs.com/zhuli19901106/p/3684417.html

《Cracking the Coding Interview》——第10章:可扩展性和存储空间限制——题目1相关推荐

  1. Cracking the coding interview

    转自:http://hawstein.com/posts/ctci-solutions-contents.html Cracking the coding interview--问题与解答 March ...

  2. 经典算法题目:Cracking the coding interview 问题与解答

    Cracking the coding interview--问题与解答 March 14, 2013 作者:Hawstein 出处: http://hawstein.com/posts/ctci-s ...

  3. [Free] Cracking the Coding Interview 6th Download

    [Free] Cracking the Coding Interview 6th Download 推荐给有梯子的童鞋们! https://www.pdfdrive.com/cracking-the- ...

  4. 渣基础:比照Hawstein学Cracking the coding interview(1)

    <C++ Primer 第五版>书实在是太长,太厚了.总是看了十几页就看累了,坚持不了多久,想了想还是别勉强自己,决定把它当工具书查看,或者积累足够的C++经验后再翻阅一遍. 目前的打算是 ...

  5. 《Cracking the Coding Interview》——第18章:难题——题目11

    2014-04-29 04:30 题目:给定一个由'0'或者'1'构成的二维数组,找出一个四条边全部由'1'构成的正方形(矩形中间可以有'0'),使得矩形面积最大. 解法:用动态规划思想,记录二维数组 ...

  6. 《Cracking the Coding Interview》——第6章:智力题——题目5

    2014-03-20 01:08 题目:扔鸡蛋问题.有一个鸡蛋,如果从N楼扔下去恰好会摔碎,低于N楼则不碎,可以继续扔.给你两个这样的鸡蛋,要求你一定得求出N,怎么扔才能减少最坏情况下的扔的次数? 解 ...

  7. 《Cracking the Coding Interview》——第18章:难题——题目3

    2014-04-29 01:02 题目:从m个整数里随机选出n个整数,要求等概率. 解法:和洗牌的算法类似,每次随机抽出一个数,抽n次即可.时间复杂度O(m * n),空间复杂度O(m). 代码: 1 ...

  8. 《Cracking the Coding Interview》——第16章:线程与锁——题目3

    2014-04-27 19:26 题目:哲学家吃饭问题,死锁问题经典模型(专门用来黑哲学家的?). 解法:死锁四条件:1. 资源互斥.2. 请求保持.3. 非抢占.4. 循环等待.所以,某砖家拿起一只 ...

  9. 《Cracking the Coding Interview》——第11章:排序和搜索——题目7

    2014-03-21 22:05 题目:给你N个盒子堆成一座塔,要求下面盒子的长和宽都要严格大于上面的.问最多能堆多少个盒子? 解法1:O(n^2)的动态规划解决.其实是最长递增子序列问题,所以也可以 ...

最新文章

  1. tomcat8 启动项目pom.xml配置
  2. SAP S/4HANA BP功能
  3. Quartz定时任务学习(九)Quartz监听器
  4. mysql的错误号大全
  5. linux每日命令(30):Linux 用户及用户组相关文件、命令详解
  6. No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
  7. 实现Github和Coding仓库等Git服务托管更新
  8. 蓝桥杯 ADV-112 算法提高 c++_ch02_01
  9. ubuntu php命令行模式,在命令行ubuntu 16.04上切换php版本
  10. HandyJSON和SwiftyJSON的应用
  11. CPDA数据分析师:一个完整的数据分析流程
  12. jdk8下载与安装教程
  13. 大津算法 matlab,大津法---OTSU算法
  14. redis 复制功能测试(转阿辉的百度空间)
  15. 数商云跨境电商平台解决方案
  16. 我的TLS1.3之旅
  17. Rhythmbox中mp3中文乱码问题
  18. 爬虫项目实战1——爬取天善课程
  19. 基于词表和N-gram算法的新词识别实验
  20. 批量下载/导出excel文件或音频文件(浏览器)

热门文章

  1. nginx Alphabetical index of variables
  2. TensorFlow COCO
  3. opencv-api matchShapes
  4. linux下声卡的安装
  5. 压测学习总结(5)——如何使用Jmeter 进行简单的并发操作
  6. 代码管理和检查平台汇总
  7. Spring MVC学习总结(12)——Spring MVC集成Swagger时报错{schemaValidationMessages:[
  8. Docker学习总结(12)——非常详细的 Docker 学习笔记
  9. 羽枭android,【答疑】Unreal Engine 4 是怎样发布android的? - 视频教程线上学
  10. 腾跃计算机二级vfp培训,计算机二级:在VFP中实现进度条