由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个OO题 (转载)
相关主题
share 面试题M$ screening coding题2道
求救: 打印binary tree问个题:get max value from Queue, with O(1)?
昨天被面试的问题A家来两道电面题
一道面试题贡献一道G家电面题
请教一个系统设计问题 (转载)CLRS算法书中BFS的疑问
如何实现binary tree的从下到上的分层打印?面试题
这个用stack实现queue一道很难的面试题
如何用JAVA中的circular array of queue 解决Josephus problem? (转载)A第一轮电面,求建议,面完必update
相关话题的讨论汇总
话题: ac话题: dequeue话题: aircraft话题: system
进入JobHunting版参与讨论
1 (共1页)
v*******a
发帖数: 14
1
【 以下文字转载自 Programming 讨论区 】
发信人: violetmma (苏苏), 信区: Programming
标 题: 问个OO题
发信站: BBS 未名空间站 (Sun Jul 1 17:08:17 2012, 美东)
A software subsystem of an air-traffic control system is defined to manage a
queue of aircraft (AC) in an airport. The aircraft queue is managed by a
process which responds to three types of requests:
system boot used to start the system.
enqueue aircraft used to insert a new AC into the system.
dequeue aircraft used to remove an AC from the system.
AC’s have at least (but are not limited to having) the following properties:
AC type: Passenger or Cargo
AC size: Small or Large
The process which manages the queue of AC’s satisfies the following:
There is no limit on the number of AC’s it can manage
Dequeue aircraft requests result in selection of one AC for removal such
that:
Passenger AC’s have removal precedence over Cargo AC’s
Large AC’s of a given type have removal precedence over Small AC’s of the
same type.
Earlier enqueued AC’s of a given type and size have precedence over later
enqueued AC’s of the same type and size.
v*******a
发帖数: 14
2
用priority queue可行吗?key取4个值?
system boot used to start the system 是指ctor或initializeQueue
这样的函数吗?
要是用heap实现priority queue, 就要使用数组,那怎么满足
There is no limit on the number of AC’s it can manage
的要求呀?
谢谢!

a
properties:

【在 v*******a 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 发信人: violetmma (苏苏), 信区: Programming
: 标 题: 问个OO题
: 发信站: BBS 未名空间站 (Sun Jul 1 17:08:17 2012, 美东)
: A software subsystem of an air-traffic control system is defined to manage a
: queue of aircraft (AC) in an airport. The aircraft queue is managed by a
: process which responds to three types of requests:
: system boot used to start the system.
: enqueue aircraft used to insert a new AC into the system.
: dequeue aircraft used to remove an AC from the system.

E*******0
发帖数: 465
3
class AC
{
int typeName;
int ID;
int size;
}
class ACControl
{
private:
MyQueue PassengerQueue;
MyQueue CargoQueue;
Public:
ACControl;//constructor
void Enqueue(AC ac);
AC Dequeue();
}
class MyQueue
{
private:
AC* smallPointer;
AC* top;
AC* last;
public:
void Enqueue(AC ac);
AC Dequeue();
bool IsEmpty();
}
E*******0
发帖数: 465
4
void ACControl::Enqueue(AC ac)
{
if (ac.type==1) //passenger
PassengerQueue.Enqueue(ac);
else
PassengerQueue.Enqueue(ac);
}
AC ACControl::Dequeue()
{
if (!PassengerQueue.IsEmpty())
return PassengerQueue.Dequeue();
else
return PassengerQueue.Dequeue();
}
E*******0
发帖数: 465
5
void MyQueue::Enqueue(AC* ac)
{
if (ac.size==1)//small
last->next=ac;
ac->previous=last;
last=∾
else
ac->previous=smallPointer;
ac->next=smallPointer->next;
smallPointer->next->previous=∾
smallPointer->next=∾
smallPointer=ac;
}
AC* MyQueue::Dequeue()
{
Ac* rst=top;
top=top->next;
return rst;


}
E*******0
发帖数: 465
6
写得有点糙,大家讲究着拍。
1 (共1页)
进入JobHunting版参与讨论
相关主题
A第一轮电面,求建议,面完必update请教一个系统设计问题 (转载)
Two programming questions...如何实现binary tree的从下到上的分层打印?
A家电面这个用stack实现queue
ebay第一轮电话面经如何用JAVA中的circular array of queue 解决Josephus problem? (转载)
share 面试题M$ screening coding题2道
求救: 打印binary tree问个题:get max value from Queue, with O(1)?
昨天被面试的问题A家来两道电面题
一道面试题贡献一道G家电面题
相关话题的讨论汇总
话题: ac话题: dequeue话题: aircraft话题: system