I come, I see, I conquer

                    —Gaius Julius Caesar

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

Sybase笔试题

 

1.  检测链表中是否有环
2.  库函数调用和系统调用区别何在
3.  输出一个字符串中字符的所有组合
4.  从一个文件中随机读出一个字符串
5.  File Descriptor 和 File Pointer的区别
6.  如何判断一个变量是有符号数还是无符号数
7.  x=x + 1;   x++;  ++x;   x = x + 1; 的区别

(答案请参考《Expert C Programming》附录A)

 

 

上海纳拓软件

 

Problem 1 : Fast one-hot checker
A bit vector is one-hot if and only if there is at most one 1 in the vector. For example, 0000 and 00100 are one-hot and 00110 is not one-hot. Please find the fastest way to check whether a bit vector is one-hot or not.

Problem 2 : 3-Inverter
Assume that a logical blackbox has three Boolean inputs x, y, z and three Boolean outputs X, Y, Z where the outputs are defined as

X = ~x 
Y = ~y 
Z = ~z 

Note that ~ stands for a NOT gate. Please realize this blackbox using only two NOT gates, and as many as possible AND and OR gates.

Problem 3 : Is it a loop ?
Assume that we have a head pointer to a link-list. Also assume that we know the list is single-linked. Can you come up an algorithm to check whether this link list includes a loop by using O(n) time and O(1) space where n is the length of the list? Furthermore, can you do so with O(n) time and only one register?

Problem 4 : Detect same sequence
Assume that we have a m*n matrix A where both m >= 1K and n >= 100K. X_i is a row vector of A where 1 <= i <= m. In other words, A = {X_1, X_2, ..., X_m}.
Please find a fastest algorithm to detect all pairs (X_i, X_j), where X_i == X_j.

posted on 2008-10-04 22:54  jcsu  阅读(3685)  评论(0编辑  收藏  举报