Wednesday, 24 May 2017

interview questions and answers

1. 请简单介绍一下自己?
A: 我的经历比较多。我挑重点的说说吧。
 我大学读的是机械专业。但是我对计算机很有兴趣。我自学了很多计算机专业的课程。比如,C语言,数据结构,计算机原理等等。
 毕业之后,我做了一名机电工程师。两年半之后,我转入了软件行业。转行之后第一个工作是网站开发兼网络管理工程师。就是维护公司内外部网络,计算机病毒防护,计算机硬件维护,公司内外部网站的维护和开发。在这段时间,我学会了HTML,CSS,ASP,MSSQL 等基本的网站开发的技巧和常用工具的使用,比如FTP,SQLSERVER等等。
 然后就是在OSA TECHNOLOGY--AVOCENT的6年。那个公司原来叫OSA TECHNOLOGY, 是一家美国公司,后来被另一家美国公司AVOCENT收购了。可以是两个公司,但其实只是公司LOGO变了,其他都一样。在这家公司,我掌握了在现在看来都不落伍的开发软件的技术。了解了商业软件开发的过程,团队的配合,管理方法和很多人生道理。可以说,经过这5年多的锻炼,我不惧怕软件公司的从程序员到技术总监的任何一个工作岗位。除了开发能力意外,我更加领悟,作为一个优秀的程序员,以下一些能力和习惯也非常重要。1,当程序出现bug,不要乱猜,首先要把问题重现,然后通过线索找到bug真正的原因,这样才能改掉bug。其实改bug不难,难的是发现bug。2,代码要写得尽量规范,做好注释和文档说明。这样的代码,不仅利于自己日后维护,更利于别人阅读和接手。3, 在一个团队里,和别人交流,配合也是相当重要的。4, 工作积极努力,多听取大家的意见,又能做出恰当的决定。
 然后说说我在英国的这几年。在英国主要是学习和自己创业。更多的时候是自己在工作,但是这也锻炼了我自己发现问题,解决问题的能力。使我变得完全独立。在遇到问题的时候,由于英语的提高,我可以和全世界的工程师一起讨论问题。这是一个很大的进步。

 1. Briefly introduce yourself?
A: My Bachelor's degree is mechanical engineering. But I am very interested in computer. I taught myself a few courses like C language, data structure, computer theory and so on.

 After graduation, I became a mechanical and electrical engineer. Two and half years later, I moved into the software industry. My first job is website development and network management engineers. Job duty is to maintain the company's internal and external networks, computer virus protection, computer hardware maintenance, company's internal and external website maintenance and development. During this period, I learned the basic web development techniques such as HTML, CSS, ASP, MSSQL and common tools such as FTP, SQLSERVER and so on.

And then is the 6 years in OSA TECHNOLOGY - AVOCENT. The company was originally called OSA TECHNOLOGY and was later acquired by another US company, AVOCENT. It can be two companies, but in fact nothing changed except the company's LOGO. In this company, I have mastered the whole software development skills which is still not old fashion today. Understand the process of commercial software development, team work, management methods and a lot of life philosophy. With this six years experience, I am not afraid of any job from programmer to the technical director. In addition to the development skills,  I noticed,  to be a good programmer, the following skills and habits are also very important. 1, when the program has bug, do not guess, first of all to reproduce the problem, and then through the clues to find where exactly the bug is , and then can get rid of it. In fact, fix a bug is not difficult, but find the bug. 2, Codes should be written in a formal standard as possible as you can, make notes and documentation. As a result, it can be easy to read, maintenance and take over. 3, Communicate and share in a team is also very important. 4, Work hard, listening to everyone's views, but also make the appropriate decision.

 And then talk about these years in the UK. It can be divided into in the university and creating my own business. Most of the time, I was working alone. But it also forced me work independently. Find the problem, solve the problem all by myself. Due to the improvement of English, I can discuss problems and share my opinion with the engineers world wide.This is a big improvement. By the way, I found, create a company or business is very difficult than writing codes. So, that's reason I am coming back to the development job.


2. 你最大的优点(特点)是什么?
A:  刻苦,勤奋,细心,不轻易认输,谨慎,热爱编程,热爱学习。一个月如果不学点什么,就感觉有什么事没做。喜欢解决问题之后的成就感。喜欢review自己的代码,使代码简洁,简化,易于阅读。重视注释,重视规范化,可移植化。不满足仅仅理解别人的解决方案,更重视理解之后,自己写出解决方案,并把自己的方案和别人的对比。喜欢与人交流,相互学习,在团队中积极贡献自己的方案,但是不固执己见,服从领导和团队的决定。

 2. What is your greatest strength?
Hard working, carefulness, cautiousness , never give up easily , love programming, love learning. If I didn't learn or try something for a while, I feel something not right. Enjoy coding, enjoy problem solving, especially when problems solved. Like review my own code, making the code simplified , easy to read, maintain and extend. Attention to details, standardization and portability. Do not only satisfied understanding others' solutions, pay more attention to write my own solutions, and compare with others'. Enjoy communication each other, learning from each other, contribute my opinion in the team, but adopt the final decision after discussion.

For example, there  was one time, my line manager told me that there had a new requirement and they need to add in my code. And he suggested that I can copy another colleague's code because it is urgent. And I said, I can copy that code and make sure the QA team can test tomorrow. But I would spend a few hours to understand and test the code, make sure there had no mistakes and exceptions. Alternatively, they may ask the colleague to make a library since these code were used by different modules. 

3. 你最大的缺点(弱点)是什么?
A: 不是太聪明,反应不是太快。语言,英语。

3. What is your greatest weakness?  
A:  I am not very smart.  Well, depends on compare with who. I am not very fast response. But, sometimes, I find, it may be a good personality. Suppose, someone blamed you, when you understood, they had gone.
Well, I think my biggest weakness is still language. Yes, English. But I am always improving my English in many different ways. Prepare this interview is a good way.

4. 给我一个/些雇佣你的理由?










很简单,我的经验和能力决定了我能做这个工作。我可以被公司利用。同时,我也需要这个工作。我爱这个工作。




4. Why should we hire you?
A: Easy question. My experiences and skills make me suit for this job. I can be used by the company. And, I need this job, I love this job. I love coding.

5. What are your salary expectations?
A: The job salary range is from XXX to XXX. I am happy with this because my last job is lower than this range.

6.


Monday, 22 May 2017

merge sort algorithm

package Algorithm;

public class MergeSort2 {
    //    merge sorted array a and b into c 
    static void mergeArray(int a[], int n, int b[], int m, int c[]) 
    { 
        int i, j, k; 
        i = j = k = 0; 
        while (i < n && j < m){
            c[k++]= a[i]<b[j]?a[i++]:b[j++];
        }
        while (i < n) 
            c[k++] = a[i++]; 
        while (j < m) 
            c[k++] = b[j++]; 
    } 
   
    static void sortArray(int a[],int n,int sorted[]){
        System.out.println("n="+n);
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println("++++++");
        int mid = n/2;
        if(n==1){
            sorted[0] = a[0];
            return;
        }
          if(n>1){
            int[] left = new int[mid];
            int[] right = new int[n-mid];
            int j = 0;    //    the point of a array
            for(int i=0;i<left.length;i++){
                left[i] = a[j++];
            }
            for(int i=0;i<right.length;i++){
                right[i] = a[j++];
            }
            int []leftSorted = new int[left.length];
            sortArray(left,left.length,leftSorted);
            int []rightSorted = new int[right.length];
            sortArray(right,right.length,rightSorted);
            mergeArray(left, left.length, right, right.length,sorted); 
        }
          System.out.println("after sort");
          for(int i=0;i<n;i++){
              System.out.print(sorted[i]+" ");
          }
    }
   
    public static void main(String[] args) {
        int[] a = new int[]{4,7,10,13,18,3,5,9,11,19,21};
    //    int[] a = new int[]{4};
        int[] sorted = new int[a.length];
        sortArray(a,a.length,sorted);
        for (int i = 0; i < sorted.length; ++i) {
            System.out.print(sorted[i] + " ");
        }
    }

}

Result:

n=11
4 7 10 13 18 3 5 9 11 19 21 ++++++
n=5
4 7 10 13 18 ++++++
n=2
4 7 ++++++
n=1
4 ++++++
n=1
7 ++++++
after sort
4 7 n=3
10 13 18 ++++++
n=1
10 ++++++
n=2
13 18 ++++++
n=1
13 ++++++
n=1
18 ++++++
after sort
13 18 after sort
10 13 18 after sort
4 7 10 13 18 n=6
3 5 9 11 19 21 ++++++
n=3
3 5 9 ++++++
n=1
3 ++++++
n=2
5 9 ++++++
n=1
5 ++++++
n=1
9 ++++++
after sort
5 9 after sort
3 5 9 n=3
11 19 21 ++++++
n=1
11 ++++++
n=2
19 21 ++++++
n=1
19 ++++++
n=1
21 ++++++
after sort
19 21 after sort
11 19 21 after sort
3 5 9 11 19 21 after sort
3 4 5 7 9 10 11 13 18 19 21 3 4 5 7 9 10 11 13 18 19 21 

Monday, 15 May 2017

一个40岁老程序员的感想

不知不觉的,已经过了40岁。准确的说,是41周岁107天。这个年纪,如果在一般公司里还没有做到中层经理的,按照大众的想法可能今后也不会有什么机会高升了,能保住饭碗就不错了。如果在体力上拼不过年轻人,估计要想想是不是学个厨艺,将来失业了,还可以开个小饭店,免得到时候措手不及。然而,我并不这么想,也不这么认为。我准备在这个年纪,重返开发一线。嗯,可能很多人会有一些问题,下面我就一一回答一下吧。

1. 你是什么时候入行的?
答:2001年年初。98年7月大学毕业。

2. 大学本科学的什么专业?
答:机械制造工艺与设备(机电一体化方向)。

3. 哪一年本科毕业,毕业后第一份工作做了什么?
答:98年7月本科毕业。第一份工作是广船国际的机电设计工程师。

4. 为什么改行做软件?是觉得第一份工作不适合自己吗?
答:第一份工作做得很好,工作一年后就得到领导赏识成为业务骨干。工作一年半,就得到广船国际的培训并成为一名中层管理人员。这在广船国际是不多见的。从上高中起,就对程序开发有着浓厚的兴趣,大学期间,自学好几门编程语言,并自学计算机专业的专业课,比如,数据结构,计算机原理等等。但这不是最主要的原因。最主要的原因是,广船国际虽然好,可以说,除了收入不满意,其他各方面都非常好。同龄的同事们,除了结婚,分了单位的房,和单位签了长期合同的,基本都离职去了外企或者是民企。离职后,工资都能翻倍甚至更高。
所以说,改行的原因有三点:
  • 兴趣还好
  • 收入
  • 家庭因素(因为家里人希望我去上海发展,离老家近。老家江苏)

5. 如何入得行,入行后第一份工作是什么?
答:虽然我不是计算机专业毕业的,入行前也没有正规的编程工作经验,但是当年软件人才非常缺。大部分软件从业人员都是理工科毕业后改的。比较多的是数学,物理,电子,机械等等专业。也听说有农林文医等专业的。可能是相当有兴趣,有毅力吧。我先是到上海交大培训了两个月,然后,经人介绍,去了一家软件公司做了一个月的实习。然后就在那家公司做了一名初级程序员兼网络管理。其实就是打杂。那段时间相当辛苦,不管谁的电脑有问题,上不了网,都要我解决。那段时间还经常爆发病毒。一旦爆发病毒,就要给公司服务器打补丁,那时操作系统还没有自动升级。程序员的电脑还好办,他们自己都会管理,保养。最头疼是那帮销售和办公室工作人员的电脑,经常出问题,蓝屏。公司也抠门,电脑舍不得换新的,总是能修则修,能升级硬件就升级硬件。软件能用盗版用盗版。相比之下,人工工资低。我那时4个月的工资才能买一台电脑。如果网络和同事电脑不出问题,我就抓紧时间学习软件知识。程序员们开会学习的时候,我也去听。那时,我负责维护公司内部和外部的网站系统。就看以前程序员的代码,也帮其他程序员写点小程序,小工具什么的。慢慢的,熟悉了HTML,CSS,JAVASCRIPT,ASP,MSSQL等等。

6. 哪段工作经历对你最重要?
答:01年底到07年5月在AVOCENT的这段工作经历到目前为止是我人生中最重要的一段工作经历。在这5年多的时间里,我掌握了在现在看来都不落伍的开发软件的技术。了解了商业软件开发的过程,团队的配合,管理方法和很多人生道理。可以说,经过这5年多的锻炼,我不惧怕软件公司的从程序员到技术总监的任何一个工作岗位。当然,前提是在熟悉的领域。在这段时间,我有幸认识了4位很有能力的领导,一位经常告诉我们,程序有bug很正常,不要乱猜,首先要把问题重现,然后通过线索找到bug真正的原因,这样才能改掉bug。其实改bug不难,难的是发现bug。一位领导的代码写得很规范,这样的代码,不仅利于自己日后维护,更利于别人阅读和接手。事实证明,大部分程序员都不愿意接手维护或使用别人的代码。但是如果人人都能写规范的代码,做好注释和文档说明,就会减少这个问题。一位用行动告诉我们,在一个团队里,和别人交流,配合也是相当重要的。最后一位,他工作很努力,既能听取大家的意见,又能做出恰当的决定。

7. 在AVOCENT工作5年多以后,你已经成为一名资深的程序员,为什么又要出国呢?
答:这是一个好问题。这些年,我也一直问自己,当初为什么要出国?出国这件事,既是蓄谋已久,也是一时冲动。既有本人的内在因素,也有外力的一些推动和触动。先说本人的吧。从小,我就有出国的愿望。但又觉得很遥远,甚至是不可能完成的任务。小时候,我觉得,只有两种人才能出国,一种是成绩特别好,可以获得国外大学,机构或中国政府的全额奖学金。还有一种就是家里特别有钱,能够自费出国的。很显然,直到2006年,这两种人,我都不是。转机发生在2006年。2003年,我买了一套二手房,当时价值24万。等到2006年的时候,我无意中发现,这套房涨到了接近40万。当时我就想,这多出来的14万,可以作为我出国一年的学费。然后凭积蓄和打工,生活费应该也问题不大。07年2月考了一次雅思。虽说是为了出国做准备,但是当时还没有真正下定决心出国。
06年的时候,我在AVOCENT已经做的非常顺利了。这时就萌生了进一步的想法。自从04年公司被AVOCENT收购之后,每年都有去美国出差,开会,学习的机会,但是都没有我。我猜想可能是因为我英语不好,学历不高,不是计算机专业等因素造成的。自从04年以后,公司新招的员工基本都是名牌大学,计算机专业,硕士毕业,或者至少有一条满足吧。然而我一条都不满足。这也造成了我的危机感。也是促使我出国留学的重要因素之一。
07年初,我考了一次雅思。本来想,即使达不到留学要求,学好英语,也可以提高自身能力,以后出国出差,升职加薪也有了资本。考完后,成绩并不理想。然而,一个贵人的出现,彻底改变了我的命运。这个人帮我分析了我的优势和劣势,跟我共同讨论申请了三所学校,一所尽量尝试,一所全力争取,一所旨在保底。在这个人的孜孜不倦的努力下,热情洋溢的鼓励下,我又考了一次雅思,并参加了一所学校的内部英语测试。最终得到两所学校的录取通知书。这个人是一个留学中介。
所以,我出国是因为
  • 本人有想法,有努力,有压力。
  • 条件成熟。
  • 有外力推动。

8.09年第一个硕士毕业之后,为什么不留在英国找一份行业相关的开发工作呢?
答:当时是想留在英国找一份工作,工作一段时间之后再回国的。可是08年全球金融危机,几乎所有的英国公司都冻结了招人计划。那时候一天投十来份简历,只能零零星星接到一些中介的电话。到09年下半年,连中介的电话都接不到了。后来就决定回国。因为当时国内的情况要比英国好一些。后来才了解到,留在英国的那些硕士同学,有一个印度人,09年下半年找到工作,一个英国人,10年上半年找到工作,一个印度人,10年下半年找到工作,一个英国女生,11年读了博士。这都是坚持下来的人。我想,如果我坚持找工作的话,说不定我也能像他们一样。然而,历史不能假设。

9.09年底回国工作,为什么仅仅一年,又归海英国了呢?
答:09年底回国,我就积极开始了找工作。不过可能各大公司都临近圣诞,新年和春节,各种繁忙,所以反响不是很强烈。春节过后,回应逐渐强烈,并最终在4月1号,愚人节这天入职。不过这也可能是一个玩笑。工作了7个月之后,HR突然找我谈心,说公司膨胀太快,又资金链断裂,只能裁员,缩减规模,以应对危机。当时是每个组必须要裁掉一个人。连HR部门都要裁人。其实,当时是扩张太快,每个组都在一两个月内,新招了2-3人。我们组也新招了3人,连我在内。按说,并不应该轮到我。但是,一个新人因为不能胜任工作,自己走了。另一个新人,说是以前一个同事开公司,拉他入伙,也走了。组长不愿意裁老人,只好牺牲我了。这也是我第一次被公司炒鱿鱼。

10. 回到英国之后,为什么不找工作,却又读了一个计算机硕士呢?
答:因为当时的签证快到期了,为了继续留在英国,还有当时这个硕士宣传说是有实习的机会。觉得,如果有英国本地公司的工作经验,对找工作应该是有很大帮助。然而,上了学才知道,实习机会并不是人人都有,要看有多少公司来要人。整个计算机学院,本科,硕士,博士共大几百人,机会是可想而知了。加之我又是外国人,找工作需要雇主担保签证。在10年之后,英国就连续收紧发给外国人工作的签证。不过,后来,不知道是为了安慰我们,还是什么别的原因,给了我们硕士班的学生一个和印度某大学合作做了一个会议管理软件项目的机会。当然,也是要筛选才能进入的。

11. 第二个硕士读完之后干什么了?
答:同样的,第二个硕士毕业之后,签证也到期了。为了留在英国,当时有两个选择。一个是都博士,还有一个是创业。当时觉得读书太辛苦了,还要花很多钱,也没有时间打工挣生活费。后来选择了创业。事后才明白,当老板是另一种辛苦。中间还经历了移民局的拒签,打官司,官司赢了之后,移民局居然忘了我的case。一直到我找到议员去询问,才给了我签证。所以从12年9月到14年4月,我一直是焦急,忐忑的等待签证的状态。

12. 说说你创业的情况?
答:从12年9月递交企业家移民签证之后,我就开始了创业之旅。但是我把创业分成两段,一段是准备创业,或者说是收集idea阶段。然后才是真正创业阶段。开始是做传统旅游业,就是组织旅游团,从招人组团,定机票,酒店,安排旅游路线,租车,吃饭等等全包的形式。后来发现这样精力太过分散,需要投入巨大的人力财力。小公司显然不具备这样的实力。同时发现,招人组团是旅游链上最费心,吃力的环节。因为我们在国内没有办事处,所以一开始招人是委托国内的知名旅游机构代招,比如中国旅行社。我们就做好英国的地陪工作。但是这样也有弊端,因为钱和人都掌握在别人手上,我们就只能被动的接受别人提出的条件。说白了就是压价。
 传统旅游业有一个很明显的特点。就是淡旺季差别非常大。旺季的时候,大家都忙的焦头烂额,朋友或者其他公司转交的业务根本无暇顾及。自己公司有的业务也接不了,如果找不到朋友或其他公司做就只好放弃了。但是淡季的时候,大家都闲着。偶尔有个小业务,大家还竞相比价。
 也曾经想过在淡季的时候做其他业务补充,比如网上零售。初步设想是做大部件,比如家庭体育健身器材和户外旅游用品。从进货渠道调查,海上运输,进关关税,仓库租用,英国市场调查之后发现,在英国从仓库发到客户手中的快递费用特别昂贵,除非是有一定的量,比如每周发多少快递。这显然是一个初创企业不能保证的。这样一来,如果英国境内快递费用不能控制,那就是卖一件,亏一件。除非资金非常雄厚,打一段时间价格战,价格比其他对手低很多,把客流都吸引过来,把量搞上去,这样,快递费用能降低。每周的销售稳定之后,再把价格逐步回调到正常的市场价。




Friday, 12 May 2017

Differences between Stack and Heap

Stack and a Heap ? Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM . Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled. When a function or a method calls another function which in turns calls another function etc., the execution of all those functions remains suspended until the very last function returns its value. The stack is always reserved in a LIFO order, the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack, freeing a block from the stack is nothing more than adjusting one pointer. Variables allocated on the heap have their memory allocated at run time and accessing this memory is a bit slower, but the heap size is only limited by the size of virtual memory . Element of the heap have no dependencies with each other and can always be accessed randomly at any time. You can allocate a block at any time and free it at any time. This makes it much more complex to keep track of which parts of the heap are allocated or free at any given time. stack-heap You can use the stack if you know exactly how much data you need to allocate before compile time and it is not too big. You can use heap if you don't know exactly how much data you will need at runtime or if you need to allocate a lot of data. In a multi-threaded situation each thread will have its own completely independent stack but they will share the heap. Stack is thread specific and Heap is application specific. The stack is important to consider in exception handling and thread executions.