系统设计和OOD题总结

Object Oriented Design
Design a Parking Lot. (Amazon)
Design a Car Dealership. Test Battery, Test Moonroof… (Amazon)
Design a car renting system, including reserving a car, checking in and checking out. consider all the following cases: reserve a car, then check out the car successfully; reserve a car, but the car is sold out before you check out… (Amazon)
Design an Elevator system. (Amazon)
Design a Vending Machine. (Amazon)
Design a Card Deck and Card Game. (Amazon)
Design a Chess Game
Design a Jigsaw Puzzle Game.
Design a Zoo system.
Design a Multimedia Cookbook (MS)
OOD of a general messaging system aka publish-subscribe (observer pattern) (Amazon) Design the classes and object for a file system. (Amazon)
How do you represent the following expression in “class design”: (5*3)+(4/2) ? How would an algorithm that computes the value of this expression work? (Amazon)
How would you design the software that runs on an ATM machine? The software should support operations such as checking balance, transfer funds from one account to another, deposits and withdrawals. (Amazon)
Design: How would you implement scoreboards for different games played on Xbox Live? DB, API, … (MS)
Design a library for writing card games. (Google)

System and Software Design
Design an online reader system. (Amazon) Design an online chat room.
Design an online poker room. (Amazon) Design an online messenger.
Design an online reservation system (air ticket, restaurant/hotel reservation etc) (Amazon) Design a Hotel reservation system
which will support the following functions.
Design a voice conferencing system (Amazon)
a) User will get a list of all different types of rooms.
b) User selects a room type & check the room availabilty between the specified dates.
c) User Makes Reservation.
[Discussed about “locking” the room availbilty or not in case if user wants to proceed with reservation]
(Amazon)
Design a software for a restaurant (Amazon)
info regarding the film: director, actress, rating. There are different genres possible. Action, drama etc.
Movies are placed under its shelf marked with genre. Movies of same genre are of the same cost. New movie stays as a different genre called “New Release” and placed in a different location and priced differently. It stays that way for x number of days and after that it goes back to its corresponding genre. Each customer can take out any number of movies at a time. We need to store the due date for all those movies.Design a software with class diagrams for this. (Amazon first round phone)
Utilizing two common Object-Oriented design patterns, write a set of classes, which can be used to log a given message.
The message should be logged to either a MySQL database or a file, depending on a configuration setting. There should be only one connection opened to the database (or the log file should only be opened once) throughout the use of the application. ). My Answer:
create a buffer to generate a log and then copy entire buffer to your designated file
but downsize of this method is … you will loose all data if system fail to commite or fail to log…//power shutdown (Amazon)
Suppose the email system of the world crashes, you have the job to design a new system from ground up. How would you do that? (MS)
How do you design cache server for a simple web application. How do you make sure of the data consistancy.
How do update your data/cache. (Google)
Design a web server logging system with 6 remote sites and a main site. (Amazon)
Design a graph class. Write the C++ interface for it. (Amazon) 一个硬盘上有很多图像文件分散在很多目录下。不同的文件名有可能保存的是同一个 图像。设计一个软件系统,找出重复的图像并删除。
有一个int的stream(不是那种online stream, 已知stream size),要排序,但steam太大了,一 台机器放不下,如何处理。 我说一个机器做master, distribute the workload to other machines, 各个机器分别各自排序,然 后master提供merge, 我用message passing的方式进行通讯,写code. 用priority queue 存各 个机器的 queue的front(queue已经被排序),取出最小值,然后向那个机器问下一个次 小值。我的方法可能不是最优,但短时间我只能想到如此了。(Google)
有个像amazon的网站,又好多机器,每个货物有id和order time, 要求按 order time处 理。我说这个和上面问题类似,进行merge, 他又改题说货物priority不一样怎么办?我 说用多个queue, 不同priority, 为防止low priority starving, 隔一段时间就把部分low priority 移到higher priority queue 上去。 他又变了好多要求,想不起来了,总之 突出design, 题目很open, 没有标准答案,完全看他们的要求了。(Google)
如何实现web crawler (Google) Wiki
Product kindle. User registers with and a corresponding email address is generated. How would you design a system to generate this email (unique for every user) (Amazon)

Trouble Shooting & Improve Performance
the “logging in” feature of amazon.com has a problem. isolate the problem. (Amazon)
Say you have a system. The design is good. But performance is not good. How would you find where the problem is? went on for about half an hour about it. (Amazon) last time they ask me some system redundancy questions… such as a system always fails
unex (Google)
How to increase web browsing speed. You are allowed to do anything at client/server
(Google)
Other
You have 50,000 html files, some of which contain phone numbers. How would you create a list of all the files which contain phone numbers? (Amazon)
How would you design a stapler for a blind person? (Google)

系统设计
Design a social networking site for mobile phones. What are the 5 key features? (MS)
You are given a the source to a application which is crashing when run. After running it 10 times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you test each one? (Google)
Design and describe a system/application that will most efficiently produce a report of the top 1 million Google search requests. You are given:
a. You are given 12 servers to work with. They are all dual-processor machines with 4Gb of RAM, 4x400GB hard drives and networked together.(Basically, nothing more than high- end PC’s)
b. The log data has already been cleaned for you. It consists of 100 Billion log lines, broken down into 12 320 GB files of 40-byte search terms per line.
c. You can use only custom written applications or available free open-source software.
(Google)

  1. 某建筑有五十层高,打算装俩电梯,设计该电梯系统
  2. Designed the parking lot. Asked a number of questions. Design thoughts on Aggregation, Composition, etc. Designed Classes.
    Had a lot of discussion on the flow. How to validate or invalidate Slot, Parking Lot and Vehicles. Wanted to make Park() method O(1) instead of O(N). I suggested that we use a Stack to store the empty slots. O(1) was for UnPark(). I was not completely satisfied with the design - we were passing the variables in/out of the methods… The interviewer was happy anyways.
  3. 设计一个客户/服务器,或者基于网络的音乐会订票系统
  4. Design a Hotel reservation system which will support the following functions. a) User will get a list of all different types of rooms. b) User selects a room type & check the room availability between the specified dates. c) User Makes Reservation.
  5. Design a car renting system, including reserving a car, checking in and checking out. consider all the cases: reserve a car, then check out successfully; reserve a car, but the car is sold out before you check out… Add the test cases.
  6. Design problem of train reservation system
  7. Design software for a restaurant
  8. 实现一个text editor, 选用合适的数据结构,和解释各种功能怎样实现,占用的内存空间.
  9. design chess game
  10. Design a deck of cards, players class also;
  11. Design class structure for zoo.
  12. Design the Game of Othello
  13. Design the game of Tic tac toe.
  14. Design an on line poker room
  15. Design the data structures for an online book reader system.
  16. How would you design a file system using class diagrams and what data structure would you use?
  17. Describe the data structures you will use for implementing snake & ladder game
  18. How would you design the software that runs on an ATM machine? The software should support operations such as checking balance, transfer funds from one account to another, deposits and withdrawals.
  19. Create an object-oriented design for software that allows people to play the card game “War” over the internet. Include the classes, methods, and important variables and data structures in your description.
  20. This one is interesting: How to store passwords in database? How to use them? How to store SSN in database? Is there difference? Hint: Do you really want to see the actual password when they are retrieved? Do you want to see SSN when they are retrieved?
  21. Suppose you have N books. Each book may have soft copy, hard copy, CD, DVD format. Design the data structure to hold the N books & its different formats in memory. This data structure should support the functionality that [any] 1 format of the book, will be displayed as its primary format in GUI & the remaining formats should be displayed as secondary format.
    If the popularity of some format for a particular book is more than other formats how will organize/choose the data structure.
  22. Design a vendor machine; How to test a vendor machine, give me some test cases;
  23. How do you represent the following expression in “class design”: (5*3)+(4/2) ? How would an algorithm that computes the value of this expression work?
  24. The interviewer explained me the real world scenario of the blockbuster…
    A location receives hundreds of copies of each film. They can be of multiple formats ( DVD, CD, Blue ray). We need to store the following information regarding the film: director, actress, rating. There are different genres possible. Action, drama etc.
    All the copies of a movie are placed under its shelf marked with its corresponding genre. All the movies of same genre are of the same cost. But the first time the movie arrives it stays as a different genre called “New RELEASE” and it is placed in a different location and priced differently. It stays that way for x number of days and after that it goes back to its corresponding genre. Each customer can take out any number of movies at a time. We need to store the due date for all
    those movies. Design a software with class diagrams for this. This was asked in the first round telephonic interview.
  25. Design spam filter
  26. Say you have to design a Online role playing game. People can buy demons and weapons online. There are N demons and M weapons. Each weapon of class W inflicts some damage X on a Demon of class D (i.e. decrease health of Demon by X). The question was to design a OOP system to accommodate this - make the program data-driven if possible - i.e. to add a new demon/weapon, the user has to make as minimum number of compilations as possible. Used a Singleton for storing the Damage of Demon-Weapon combo. Coded in C++. About loading, said we use DB. He suggested config files - I protested that cannot be done because the file can be tampered - no single source of truth.
  27. Design a web server logging system with 6 remote sites and a main site.
  28. Object oriented design of a general messaging system aka publish-subscribe.
  29. Design a voice conference system.
4 Likes

多谢分享!!!!