由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 面试题:如何设计一个停车场。
相关主题
请问有谁能给个全面点的答案:设计一个泊车的系统.请问设计一个虚拟的动物园,用什么设计模式好啊?
Careercup 设计题Parking Lot讨论one C/C++ question
cc150 - design OOP parking lot problemC++ Q47: protected constructor (C39)
我的找工历程:CS MS(2)C++ Q:
CS面试总结C++ Q52: (C6)
Bloomberg London onsite面经ooyala,apple,ebay面经
大家帮我看看这个工作的JDC++ protected base class
amazon电面 + facebook 电面发一个MathWorks的电面
相关话题的讨论汇总
话题: parker话题: parkinglot话题: subclass话题: entrance
进入JobHunting版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
如何设计一个停车场。问该用什么数据结构。我想了一下,我觉得要是用vector话,找
一个空位就成了线性的。要是用stack或者 queue,那就只能从一个具体的位置停车,
一般的停车场根本不是这样子。
最后我说用 linked list,因为linked list可以把空位加在头上。找空位就简单了。
但是如果来了一辆车停在头的位置,不就有难找空位了?还是说停车只能停在特定位置?
m***n
发帖数: 2154
2
一个数组就行了吧。。 这和打游戏一样,系统肯定有整个停车场的信息
每个车位包含
class ParkingLot {
Position pos;
Type type;
Status status;
}
如果是2d的平面,直接一个matrix, 每一个空格存一个状态信息就行了。
g*********e
发帖数: 14401
3
I think an array / multiple dimension array is fine.
c**********e
发帖数: 2007
4
真不知道面试人想问啥。
我说了单向链表,他也没说啥。
m***n
发帖数: 2154
5
这题关键不在数据结构吧,呵呵。。

【在 c**********e 的大作中提到】
: 真不知道面试人想问啥。
: 我说了单向链表,他也没说啥。

c**********e
发帖数: 2007
6
在电话里面的。肯定是数据结构。但不知道那个老美的面试官心里的答案是什么。

【在 m***n 的大作中提到】
: 这题关键不在数据结构吧,呵呵。。
b******t
发帖数: 965
7
heap

【在 c**********e 的大作中提到】
: 在电话里面的。肯定是数据结构。但不知道那个老美的面试官心里的答案是什么。
d**e
发帖数: 6098
8
可能跟你直接问的问题没太大关系,但相关,都是系parking lot..
http://mitbbs.com/article1/JobHunting/31957145_3_0.html

置?

【在 c**********e 的大作中提到】
: 如何设计一个停车场。问该用什么数据结构。我想了一下,我觉得要是用vector话,找
: 一个空位就成了线性的。要是用stack或者 queue,那就只能从一个具体的位置停车,
: 一般的停车场根本不是这样子。
: 最后我说用 linked list,因为linked list可以把空位加在头上。找空位就简单了。
: 但是如果来了一辆车停在头的位置,不就有难找空位了?还是说停车只能停在特定位置?

d******u
发帖数: 397
9
maintain 一个linkedlist只放空车位,来一个车,remove第一个空车位,给这个车
走一个车,把对应的车位放到链表末尾。
s******n
发帖数: 3946
10
A家的题吧。。。考的不是数据结构。
相关主题
Bloomberg London onsite面经请问设计一个虚拟的动物园,用什么设计模式好啊?
大家帮我看看这个工作的JDone C/C++ question
amazon电面 + facebook 电面C++ Q47: protected constructor (C39)
进入JobHunting版参与讨论
e***l
发帖数: 710
11
这是考OO。
n**0
发帖数: 136
12
OO经典题了
ParkingLot is a class.
ParkingSpace is a class.
ParkingSpace has an Entrance.
Entrance has a location or more specifically, distance from Entrance.
ParkingLotSign is a class.
ParkingLot has a ParkingLotSign.
ParkingLot has a finite number of ParkingSpaces.
HandicappedParkingSpace is a subclass of ParkingSpace.
RegularParkingSpace is a subclass of ParkingSpace.
CompactParkingSpace is a subclass of ParkingSpace.
ParkingLot keeps array of ParkingSpaces, and a separate array of vacant
ParkingSpaces in order of distance from its Entrance.
ParkingLotSign can be told to display "full", or "empty", or "blank/normal/
partially occupied" by calling .Full(), .Empty() or .Normal()
Parker is a class.
Parker can Park().
Parker can Unpark().
Valet is a subclass of Parker that can call ParkingLot.
FindVacantSpaceNearestEntrance(), which returns a ParkingSpace.
Parker has a ParkingSpace.
Parker can call ParkingSpace.Take() and ParkingSpace.Vacate().
Parker calls Entrance.Entering() and Entrance.Exiting() and ParkingSpace
notifies ParkingLot when it is taken or vacated so that ParkingLot can
determine if it is full or not. If it is newly full or newly empty or newly
not full or empty, it should change the ParkingLotSign.Full() or
ParkingLotSign.Empty() or ParkingLotSign.Normal().
HandicappedParker could be a subclass of Parker and CompactParker a subclass
of Parker and RegularParker a subclass of Parker. (might be overkill,
actually.)
c****p
发帖数: 6474
13
mark

【在 n**0 的大作中提到】
: OO经典题了
: ParkingLot is a class.
: ParkingSpace is a class.
: ParkingSpace has an Entrance.
: Entrance has a location or more specifically, distance from Entrance.
: ParkingLotSign is a class.
: ParkingLot has a ParkingLotSign.
: ParkingLot has a finite number of ParkingSpaces.
: HandicappedParkingSpace is a subclass of ParkingSpace.
: RegularParkingSpace is a subclass of ParkingSpace.

l***i
发帖数: 1309
14
this is a good link

【在 d**e 的大作中提到】
: 可能跟你直接问的问题没太大关系,但相关,都是系parking lot..
: http://mitbbs.com/article1/JobHunting/31957145_3_0.html
:
: 置?

M*********r
发帖数: 70
15

这个link打不开了,请问还有什么办法可以看到内容?

【在 d**e 的大作中提到】
: 可能跟你直接问的问题没太大关系,但相关,都是系parking lot..
: http://mitbbs.com/article1/JobHunting/31957145_3_0.html
:
: 置?

s*****h
发帖数: 155
16
这题的关键不在使用什么数据结构,而是让你设计多态
p*****2
发帖数: 21240
17

请问能不能ZKSS为什么重点是多态?

【在 s*****h 的大作中提到】
: 这题的关键不在使用什么数据结构,而是让你设计多态
p*****2
发帖数: 21240
18

能不能展开说说为什么这么设计?
ParkingSpace has an Entrance.
Entrance has a location or more specifically, distance from Entrance.
ParkingLotSign is a class.
ParkingLot has a ParkingLotSign.
HandicappedParkingSpace is a subclass of ParkingSpace.
RegularParkingSpace is a subclass of ParkingSpace.
CompactParkingSpace is a subclass of ParkingSpace.
ParkingLot keeps array of ParkingSpaces, and a separate array of vacant
ParkingSpaces in order of distance from its Entrance.

【在 n**0 的大作中提到】
: OO经典题了
: ParkingLot is a class.
: ParkingSpace is a class.
: ParkingSpace has an Entrance.
: Entrance has a location or more specifically, distance from Entrance.
: ParkingLotSign is a class.
: ParkingLot has a ParkingLotSign.
: ParkingLot has a finite number of ParkingSpaces.
: HandicappedParkingSpace is a subclass of ParkingSpace.
: RegularParkingSpace is a subclass of ParkingSpace.

s*****h
发帖数: 155
19
这是A家的老题了啊..
关键在于处理不同车辆,比如卡车,小轿车,三轮车等等..所以只要答出多态设计就可
以了。
还请大牛多多指点!

【在 p*****2 的大作中提到】
:
: 能不能展开说说为什么这么设计?
: ParkingSpace has an Entrance.
: Entrance has a location or more specifically, distance from Entrance.
: ParkingLotSign is a class.
: ParkingLot has a ParkingLotSign.
: HandicappedParkingSpace is a subclass of ParkingSpace.
: RegularParkingSpace is a subclass of ParkingSpace.
: CompactParkingSpace is a subclass of ParkingSpace.
: ParkingLot keeps array of ParkingSpaces, and a separate array of vacant

p*****2
发帖数: 21240
20

处理这些为什么要用多态呢?

【在 s*****h 的大作中提到】
: 这是A家的老题了啊..
: 关键在于处理不同车辆,比如卡车,小轿车,三轮车等等..所以只要答出多态设计就可
: 以了。
: 还请大牛多多指点!

相关主题
C++ Q:C++ protected base class
C++ Q52: (C6)发一个MathWorks的电面
ooyala,apple,ebay面经一般电面C++会问到什么专业问题?
进入JobHunting版参与讨论
E****U
发帖数: 59
21
Sorry for my ignorance, but what is "多态"?
i***h
发帖数: 12655
22
polymorphism?
so you can use one interface instead of different ones for different types
of vehicles
So from outside the module, the interface does not need to change even you
may change types of vehicles. Of course, in reality that's more complicated
may not be ideal.

【在 p*****2 的大作中提到】
:
: 处理这些为什么要用多态呢?

p*****2
发帖数: 21240
23

complicated
for different types of vehicles 为什么要用interface?

【在 i***h 的大作中提到】
: polymorphism?
: so you can use one interface instead of different ones for different types
: of vehicles
: So from outside the module, the interface does not need to change even you
: may change types of vehicles. Of course, in reality that's more complicated
: may not be ideal.

i******t
发帖数: 22541
24
是不是不同的车型 对应不同的具体的子类
每个车型 收费啊 位置 可能是不同的
用户调用的时候 他直接调用 parking(); 不用担心具体车型?
这么个意思?

【在 p*****2 的大作中提到】
:
: complicated
: for different types of vehicles 为什么要用interface?

i***h
发帖数: 12655
25
yeah

【在 i******t 的大作中提到】
: 是不是不同的车型 对应不同的具体的子类
: 每个车型 收费啊 位置 可能是不同的
: 用户调用的时候 他直接调用 parking(); 不用担心具体车型?
: 这么个意思?

w********p
发帖数: 948
26


【在 n**0 的大作中提到】
: OO经典题了
: ParkingLot is a class.
: ParkingSpace is a class.
: ParkingSpace has an Entrance.
: Entrance has a location or more specifically, distance from Entrance.
: ParkingLotSign is a class.
: ParkingLot has a ParkingLotSign.
: ParkingLot has a finite number of ParkingSpaces.
: HandicappedParkingSpace is a subclass of ParkingSpace.
: RegularParkingSpace is a subclass of ParkingSpace.

p*****2
发帖数: 21240
27

你能定义一个看看吗?

【在 i******t 的大作中提到】
: 是不是不同的车型 对应不同的具体的子类
: 每个车型 收费啊 位置 可能是不同的
: 用户调用的时候 他直接调用 parking(); 不用担心具体车型?
: 这么个意思?

i***h
发帖数: 12655
28
any C++/Java textbook

【在 p*****2 的大作中提到】
:
: 你能定义一个看看吗?

p*****2
发帖数: 21240
29

我想看看为什么要多态。

【在 i***h 的大作中提到】
: any C++/Java textbook
i******t
发帖数: 22541
30
我也不会。。。。
估计大体意思就是 你写个类 别人去吊
调用的时候 pBase->park();
pbase 具体执行 看怎么create的
比如可以 pbase = new CSUV(); 那么 pBase->park();就是调的suv的 park了
interface 就是park()
靠 这是不是基本的c++虚函数啊?
那位大侠指点一下

【在 p*****2 的大作中提到】
:
: 我想看看为什么要多态。

相关主题
去很冷的地方interview,穿什么?Careercup 设计题Parking Lot讨论
c模拟c++的继承和多态cc150 - design OOP parking lot problem
请问有谁能给个全面点的答案:设计一个泊车的系统.我的找工历程:CS MS(2)
进入JobHunting版参与讨论
p*****2
发帖数: 21240
31

我想知道的是你park里边的代码是长什么样的。

【在 i******t 的大作中提到】
: 我也不会。。。。
: 估计大体意思就是 你写个类 别人去吊
: 调用的时候 pBase->park();
: pbase 具体执行 看怎么create的
: 比如可以 pbase = new CSUV(); 那么 pBase->park();就是调的suv的 park了
: interface 就是park()
: 靠 这是不是基本的c++虚函数啊?
: 那位大侠指点一下

1 (共1页)
进入JobHunting版参与讨论
相关主题
发一个MathWorks的电面CS面试总结
一般电面C++会问到什么专业问题?Bloomberg London onsite面经
去很冷的地方interview,穿什么?大家帮我看看这个工作的JD
c模拟c++的继承和多态amazon电面 + facebook 电面
请问有谁能给个全面点的答案:设计一个泊车的系统.请问设计一个虚拟的动物园,用什么设计模式好啊?
Careercup 设计题Parking Lot讨论one C/C++ question
cc150 - design OOP parking lot problemC++ Q47: protected constructor (C39)
我的找工历程:CS MS(2)C++ Q:
相关话题的讨论汇总
话题: parker话题: parkinglot话题: subclass话题: entrance