时间过去一天,整理下思绪,总结下这次电面经历。
大约一周前接到HR的电话,约好下周三(4.22)下午2点半的面试。
下午差不多时间接到电话,过程全英文。开始HR让自我介绍下,包括项目经历。准备得不是很充分,介绍断断续续的,也没有什么条理,应该给HR印象不好。
接下来就是一些技术问答。
Q:What’s your main programming language?
A: C language.
Q: What’s the difference between stack and queue?
A: Stack is first in last out, queue is first in first out.
Q: Can you give me some examples where the stack is used?
A: The compiler uses stack to store data, when a function is called, it’s parameters are put into a stack, when the compiler needs data, the stack will pop up.
Q: What is inline?
A: Inline is a mechanism that the compiler used to compile a function. When a function is defined as inline, the compiler will not compile it as a function, but extract the code in position.
Q: What is the benefit of inline?
A: Function calls costs a certain CPU and memory, when a function is complied as inline, it will save that part of the cost. But it stills looks like a function when writing the code. It’s still convenient to write and read the code.
Q: Can a recursive function be compiled as inline?
A: No, if a recursive function is compiled as inline, as it extract the code, it will be too complex for a function to be compiled as inline.
Q: How does cache work?
A: When the CPU needs to read data, it will visit the cache instead of the outside memory, if the hit is a success, then the data will return directly, otherwise it will still visit the outside memory for the data.
Q: Do you known about write back and write through?
A: Yes, I learned sth about them. They are still about the cache. Write through is when the CPU need a data, it will hit the cache, and compare it to the data in outside memory, if the two of them equal, then it will write to the memory. em, I’m sorry, I’m a little confused here.
Q: Do you know about any objective oriented language?
A: Yes, I learned Java.
Q: What do you think about polymorphism?
A: When you define a class, you may need to mind that the application may pass different types of parameters to a method. So you need to define several functions using the same name but has different types of inputs. In that case, the application is more flexible and convenient to write.
Q: What is stack overflow?
A: If you use a new operation to allocate a section of memory, when you’re done with the memory, you didn’t free the memory. It will leave a section of memory that no pointer is pointed to, and can no longer be visited. As the application runs on, more and more memory is occupied, and finally the system will crack down. That’s so-called stack overflow.
Q: How to deal with dirty data?
A: I think there should be a final section to deal with dirty data.
Q: What do you known about hash set?
A: Hash set is that a set of which every data has a unique hash code.
Q: OK, that’s my part of questions. Do you have any question you want to ask?
A: I know that I may not be quite qualified for your position. But I still want to ask you a question. Do you have any projects that can help your new employees to get better in their job?
Q: Yes, we have … and a four month training that helps the new colleagues to learn different programming languages. and…
A: That’s quite fascinating.
Q: Thank you for your time. Byebye.
A: Byebye.
可以看得出来面试过程中自己的技术能力和英文水平都远远不够:
1. 栈的实例给的不好。
2. 递归函数不能inline编译的理由不正确。
3. cache的工作原理以及两种write方式没有回答正确。
4. 栈溢出理解错误,回答的是内存泄露。
5. dirty data是数据库的概念,没有理解。
查阅资料后,针对性的回答,下面可能会更好(暂时以中文回答):
Q: Can you give me some examples where the stack is used?
A: 算术表达式的求值
堆栈在计算机语言的编译过程中用来进行语法检查
键盘顺序输入,逆序输出
Q: Can a recursive function be compiled as inline?
A: 递归函数的结束条件只能在运行时得到满足,编译阶段无法确定,因此若使用inline编译递归函数,编译器根本不可能知道展开该在何时结束
Q: What is stack overflow?
A: 如果向缓冲区中写入超过其本身长度的数据,以致于缓冲区无法容纳,就会造成缓冲区以外的存储单元被改写,这种现象就称为缓冲区溢出。
Q: How does cache work?
A:缓存的工作原理是当CPU要读取一个数据时,首先从CPU缓存中查找,找到就立即读取并送给CPU处理;没有找到,就从速率相对较慢的内存中读取并送给CPU处理,同时把这个数据所在的数据块调入缓存中,可以使得以后对整块数据的读取都从缓存中进行,不必再调用内存。
Q: Do you known about write back and write through?
A:
Write-through- Write is done synchronously both to the cache and to the backing store.
Write-back (or Write-behind) – Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.
Write-through(直写模式)在数据更新时,同时写入缓存Cache和后端存储。此模式的优点是操作简单;缺点是因为数据修改需要同时写入存储,数据写入速度较慢。
Write-back(回写模式)在数据更新时只写入缓存Cache。只在数据被替换出缓存时,被修改的缓存数据才会被写到后端存储。此模式的优点是数据写入速度快,因为不需要写存储;缺点是一旦更新后的数据未被写入存储时出现系统掉电的情况,数据将无法找回。
Write-misses写缺失的处理方式
对于写操作,存在写入缓存缺失数据的情况,这时有两种处理方式:
Write allocate (aka Fetch on write) – Datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read-misses.
No-write allocate (aka Write-no-allocate, Write around) – Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, actually only system reads are being cached.
Write allocate方式将写入位置读入缓存,然后采用write-hit(缓存命中写入)操作。写缺失操作与读缺失操作类似。
No-write allocate方式并不将写入位置读入缓存,而是直接将数据写入存储。这种方式下,只有读操作会被缓存。
无论是Write-through还是Write-back都可以使用写缺失的两种方式之一。只是通常Write-back采用Write allocate方式,而Write-through采用No-write allocate方式;因为多次写入同一缓存时,Write allocate配合Write-back可以提升性能;而对于Write-through则没有帮助。
Write-through模式处理流程
A Write-Through cache with No-Write Allocation
Write-back模式处理流程
A Write-Back cache with Write Allocation
Q: How to deal with dirty data?
A: This is data that contain errors. Unclean data can contain such mistakes as spelling or punctuation errors, incorrect data associated with a field, incomplete or outdated data, or even data that has been duplicated in the database.
从数据库到数据仓库,脏数据概括起来就是
1、不完整的数据(比如如供应商的名称、分公司的名称、客户的区域信息缺失、业务系统中主表与明细表不能匹配等)
解决方法:补全
2、错误的数据(比如数值数据输成全角数字字符、字符串数据后面有一个回车操作、日期格式不正确、日期越界等)
解决方法:对错误进行分类,然后写SQL语句挑出来,再提交给业务部门修正,最后再重新抽取
3、重复的数据
解决方法:将重复数据记录的所有字段导出来,让客户确认并整理。
Q: What do you known about hash set?
To be contiued…
以上可见,摩根电面虽然考察的是基础知识,但范围很广。不过大多问题是经典问题,不生僻不刁难人,但很能考察出面试者的实力,相对来说针对性的准备比较容易。