Interview examination

本文探讨了一个有趣的游戏策略问题,即Jeff和Diamond玩的一种特殊规则的硬币游戏,并详细解析了如何确保在游戏中获胜的策略。此外,文章还涉及了一系列与软件开发相关的问题,包括UI元素重叠的高效检测算法、文件系统的存储优化、模板编程技巧等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Jeff and Diamond like playing game of coins,One day they
designed a new set of rules:
1)Totally 10 coins
2)One can take away 1,2or 4 coins at one time by turns
3)Who takes the last loses.
Given these rules Whether the winning status is pre-determined or not
2.the UI specialist Dafna found a problem that some of the
Items on the marketing document form overlapped with each other.
because this form was implemented by differnt developers and
they didn''t care the particular appearance of one item.Product manager
Tidav decided to write one small checking tool to generate the overlapped
items on all forms.He called in his guys to discuss about it.
Suppose the input is the integer coordinates (x,y)od the items (all rectangl
es)
on one form.Construct an efficient methed to find out the overlapped items.
Hint:The most direct way to do so is comparing each items with
the others,Given 1000 forms.each with 100-1000items on average.
the O(n2) algorithm is costly.Some guru suggested that one O(n)
method could help only if 6.5 kilobytes extra storage is available.
One elite argued that he could cut down the number to 1%,It''s now your
turn to describe the idea.write out the pseudocodes,vertify his
algorithm and propose more advanced optimization if possible.
3 in a file system ,data need not be sequentially located in physical
blocks,We use a number of tables storing nodes imformation.Suppose
now we use a fixed node size of variable-lenth n,it takes [n/(k-b)]
nodes to store this item.(Here b is a constant, signifying that
b words of each node contain control information,such as a link to the
next node).If the avarage length n of an Item is N,what choise
of k minimizes the average amount of storage space required?
(Assume that the average value of (n/(k-b)) mod 1 is equal to 1/2 ,for any f
ixed k ,
as n varies)

1.Below is usual way we find one element in an array:
const int *find1(const int* array, int n, int x)
{
    const int* p = array;
    for(int i = 0; i < n; i++)
    {
        if(*p == x)
        {
            return p;
        }
        ++p;
    }
    return 0;
}
In this case we have to bear the knowledge of value type "int", the size of
array,
even the existence of an array. Would you re-write it using template to elim
inate all
these dependencies?
2. Assume you have a class like
class erp
{
    HR* m_hr;
    FI* m_fi;
public:
    erp()
    {
        m_hr = new HR();
        m_fi = new FI();
    }
    ~erp()
    {
    }
};
if "new FI()" failed in the constructor, how can you detect this problem and
release the
properly allocated member pointer m_hr?
3. Check the class and variable definition below:
#include
#include
using namespace std;
class Base
{
public:
    Base() { cout<<"Base-ctor"<    ~Base() { cout<<"Base-dtor"<    virtual void f(int) { cout<<"Base::f(int)"<    virtual void f(double) {cout<<"Base::f(double)"<    virtual void g(int i = 10) {cout<<"Base::g()"<};
class Derived: public Base
{
public:
    Derived() { cout<<"Derived-ctor"<    ~Derived() { cout<<"Derived-dtor"<    void f(complex) { cout<<"Derived::f(complex)"<    virtual void g(int i = 20) {cout<<"Derived::g()"<};
Base b;
Derived d;
Base* pb = new Derived;
Select the correct one from the four choices:
Cout<A. 4    B.32    C.20    D.Platform-dependent
Cout<A. 4    B.8 C.36    D.Platform-dependent
pb->f(1.0);
A.Derived::f(complex)   B.Base::f(double)
pb->g();
A.Base::g() 10      B.Base::g() 20
C.Derived::g() 10   D.Derived::g() 20
4.Implement the simplest singleton pattern(initialize if if necessary).
5.Name three sort algorithms you are familiar with. Write out the correct or
der by the
average time complexity.
6.Write code to sort a duplex direction linklist. The node T has overridden
the comparision operators

 

1.Jeff and Diamond like playing game of coins,One day they
designed a new set of rules:
1)Totally 10 coins
2)One can take away 1,2or 4 coins at one time by turns
3)Who takes the last loses.
Given these rules Whether the winning status is pre-determined or not
解答:
1:从后面开始考虑,最后肯定要留1个才能保证自己赢
2:所以要设法让对方留下2,3,5个
3:也就是要自己取后留下1,4,6,7,8,9。。。
4:如果自己取后留下6,对方取2个,与(3)矛盾,所以排除6
5:如果自己取后留下8,对方取4个,与(3)一样情况,所以也排除8
6:同样,9也不行,如果我抽后剩下9,对方抽2个,就反过来成对方抽剩成7个了,也与(
3)矛盾,所以也排除
7:所以很显然,我只能抽剩1,4,7
8:因为只能抽后剩1,4,7才能赢,我先抽得话不可能达到这几个数,很显然,只能让对
方先抽,也即是先抽的人输

 

Prerequisite Notice:
Answers are preferred in English;
Test time is 60 minutes;
Finish more than one question.

1.Give an example of implementing a Stack in the template way(only template
class declaration without detail definition and realization)
2.What''s the difference between String and StringBuffer?
3.Which came the first,chicken or the egg?
4.In C++,there''re four types of Casting Operators,please enumerate and explain
them especially the difference.
5.Let''s say we have a database with 1 one-column table.It contains same record
s. Could you please give at least 1 solution to help us get records
between line 5 and 7. No line number,row id or index etc.
6.What will be the output of the following codes?
  #include
  #define DBL(x) x+x
  int  main()
  {
    int a=3;
    int b=4;
    int c=DBL(a)*DBL(b);
    cout<    return 0;
   }
7.Please write a program to realize the model described in the figure.You
should design your program as generic as possible so that we can enhance the m
odel in the future easily without making too much change in your program.
Process1:X=A+B;
Process2:Y=C+D;
Process3:if E>=0
           Z=E;
Process4:if E<0
         Z=E/B;

 

晚上的笔试,有三部分,这是第二部分,呵呵,冒着险拿出来两张试卷。
智力测试部分共有 5道题目,其中三道比较容易我就不打上去了,把其中比较难的两道,
打出来,如果有时间我会全部打!  
3.Now is the excellent time to invest in the catering business. A survey condu
cted by Weddings magazine found that 70 percent of the magazine''s readers want
a catered wedding reception. An analysis of the catering industry, however, s
hows that the current number of caterers can serve only 55 percent of the wedd
ings likely to occur each year.
Which of the following, if true, would undermine the validity of the investme
nt advice in the paragraph above?
A. The average wedding reception involves between 50 and 100 guests.
B. Approximately a quarter of all weddings take place without a reception.
C. approximately a quarter of all weddings and their associated receptions are
paid for by the couples themselves.
D. Only half of all catered wedding reception include sit-down meals.
E. Only half of those who say they want a catered wedding reception actually h
as one.
5. Which of the following best completes the passage below?
"Government" does exist as an independent entity defining policy. Instead the
re exists a group of democratically elected pragmatists sensitive to the elect
orate, who establish policies that will result in their own reelection. Theref
ore, if public policy is hostile to , day environmental concerns, it is not be
cause of govern-mental perversity but because elected officials believe that__
____.
A. Environmentalists would be extremely difficult to satisfy with any policy,
however environmentally sound.
B. Environmental concerns are being accommodated as well as public funds permi
t.
C. The public is overly anxious about environmental deterioration.
D. The majority of voters vote for certain politicians because of those politi
cian’s idiosyncratic positions on policy issues.
E. The majority of voters do not strongly wish for a different policy.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值