Skip to main content

Posts

Showing posts from August 25, 2013

Mounting an NTFS drive in Debian

As an ex Windows user, I still have quite a collection of music on my old NTFS drive that I don’t want to mess with Fortunately you can mount the drive in Linux and read and write to it as you would have done before Here I get the best of both worlds. Being able to access my old Windows drives was one of the big barriers to my coming over to Linux. Once I had trawled the forums and help pages and found out I can still use ntfs to a degree I was sold. The tools won’t make Linux use ntfs, they just allow you to access them. The process has two dependencies, ntfs-3g and libfuse 2. You will need these two packages installed before you begin the process. Ntfs-3g is a third party package that allows reading and writing to ntfs drives, which is the holy grail for me right now! apt-get install libfuse2 apt-get install ntfs-3g Once you have the two packages installed we can begin. The first step is to ensure your Debian system ‘sees’ the ntfs drive. You’re not going to be

Installing "KDE Desktop" task

Installing "KDE Desktop" task KDE Desktop task is what is installed by Debian-Installer's Desktop "task" (if you typed install desktop=kde at DebianInstaller CD prompt.) To install KDE later, first make sure that tasksel and aptitude are installed: apt-get install aptitude tasksel Then, install the kde-desktop task: aptitude --without-recommends install ~t^standard$ ~t^desktop$ ~t^kde-desktop$

HowTo: Find Out My Linux Distribution Name and Version

H ow do I find out what version of Linux distribution I'm using from the shell (bash) prompt? You can use any one of the following method to find out your Linux distribution and name: a] /etc/*-release file. Tutorial details Difficulty Easy ( rss ) Root privileges No Requirements lsb_release Estimated completion time 2 minute b] lsb_release command.c] /proc/version file. Method #1: /etc/*-release file To find out what version of Linux (distro) you are running, enter the following command at the shell prompt: $ cat /etc/*-release Sample output from my RHEL v5.x server: Red Hat Enterprise Linux Server release 5 (Tikanga) Sample outputs from my Ubuntu Linux v7.10 server: DISTRIB_ID=Ubuntu DISTRIB_RELEASE=7.10 DISTRIB_CODENAME=gutsy DISTRIB_DESCRIPTION="Ubuntu 7.10" Method #2: lsb_release Command The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command: $ lsb_release -a Sa

美国退出QE, 印度陷入经济危机

当全世界等待着中国爆发新兴市场危机时,一件不太有趣的事情发生了。危机反而先在 印度上演了。 传染病往往首先攻击薄弱环节,令隐藏的弱点一览无遗。卢比贬值暴露出印度的问题: 就绝对值而言,它是新兴市场财政赤字和经常账户赤字最糟糕的国家。 出什么问题了?在过去十年内的大部分时间,印度曾被誉为注定将无限期崛起下去的新 兴国家之一。即便是在2008年全球危机后,印度也依然像中国等国一样,通过大举支出 ,并借助来自美国的宽松资金洪流,维持了活跃的增长。但在光环之下,印度的真实情 况却在恶化,裙带资本主义抬头,政府补贴大幅增加,通胀快速上扬。 早在2011年,随着危机后刺激政策的效果消褪,资金开始流出新兴国家。印度经济增长 放缓,经济结构弊端暴露。导火索发生在今年5月,有关美联储(Fed)认真考虑缩减量 化宽松计划的消息,导致美国长期利率骤增,吸引美元流回国内。离开新兴市场的细流 变成了洪流。在空前依赖外国资本的印度,卢比自5月以来已经贬值20%,是新兴市场货 币中贬值最严重的。

冬天:能穿多少穿多少;夏天:能穿多少穿多少。

冬天:能穿多少穿多少;夏天:能穿多少穿多少。 剩女产生的原因有两个:一是谁都看不上,二是谁都看不上。 单身人的来由:原来是喜欢一个人,现在是喜欢一个人。 两种人容易被甩:一种不知道什么叫做爱,一种不知道什么叫做爱。 想和某个人在一起的两种原因:一种是喜欢上人家,另一种是喜欢上人家。 一个男同事和一个女同事上班同时迟到,但女的没被扣工资,男的被扣了,因为男的睡过头了,而女的睡过头了。

"Debian 7 How to Dual boot with Windows" "Debian Wheezy"

几个笑话 -- 东北人现在不打架了

一个东北朋友感慨说:以前老打架,现在不打架了。打不起架了。以前拿棍子打得头破 血流的,人家爬起来就跑了,也没什么纠缠。现在人都糠了。你打他一棍,他又是B超 又是CT,没几千下不来。他叹气说:什么都涨价,真打不起了。 一女的去另一个城市找一男的玩。晚上看完电影女的说:这么晚了,没车了吧。男说: 没事,我开车送你。到家后男的目送女的上楼。女的上楼梯时小声念:活该撸一辈子。 男的看着女的上楼的背影,小声念:就你这样还想骗我上床。 一个姓姬的朋友向我诉说自己的苦闷,“小时候大家都叫我小姬姬,长大后别人喜欢跟 我说你是小姬吧,现在大家都叫我姬兄…”他长叹一口气说,“以后年纪大点,被称作 老姬就好听多了!”,我听了之后理智的提醒他:“说不定大家会尊称你一声姬老呢。” “俺老孙把芭蕉扇借回来了,小事一桩!”“悟空,你又吹牛了吧。”“师父……你, 你都知道了?” 今天听说一个碰瓷的事,一富二代将豪车停在路边一个大妈突然躺在车前不起来了,张 口问二代要一万块,不然就不起来,去医院检查就是不去,富二代拿出电话打电话说: 爸爸,往我卡上打四五十万,我要撞死个人,大妈爬起来就走了 金正恩做了很多男人想做而不敢做的事,枪毙前女友。 女神在QQ群发谣言说去洗澡被刑拘。 有一个顽皮的男生给同班的一位女生取外号叫胖猪,该女生哭着告到老师那里,老师答 应对该男生进行批评教育。第二天上课,老师在班上讲话:我们班里有位同学太没有礼 貌了,随便给别的同学起外号,总不能人家象啥就叫啥吧。 两夫妻为了提高性生活质量,从情趣用品店买了个跳蛋。刚开开关,放入妻子阴部,才 放进去妻子就啊啊的叫着,老公问:这玩意真这么厉害,才放进去就叫了?老婆抽搐的 说:漏。漏。漏电 “爸爸,你和妈妈是怎么相爱的啊?”“那天我下班回家,看到一个漂亮女人被四个混 混拉扯着,于是我挺身而出”“哇,爸爸英雄救美然后妈妈爱上你了!?”“不是,就 在我被那几个混混打得半死时,你妈打跑了混混,然后把半死不活的我拖回家” 前段时间手术,手术半身麻醉,刚打完麻药后,一个实习的麻醉师,就拿了一根针猛戳 我的手臂,还问我疼不疼,妈的,不疼你让我戳看看,这时候老麻醉师悠悠的说了句, 下半身麻醉应该戳腿。。 公交車上,一個爸爸抱著小蘿莉,蘿莉正在背著古詩,只聽她念到:鋤禾日當

Statistics: The Average

How to install R (for Debian Gnu/Linux only)

On my machine, when I say: # apt-cache search '^r-' I get a list of the Debian packages of the R system. If you have disk space to waste, you could just install them all, e.g. by saying: # apt-cache search '^r-' | awk '{print $1}' | xargs apt-get --yes install In practice, I actually use a variant of the above, where I prune out some packages that I don't use : apt-cache search '^r-' \ | egrep -v -i '(biology|genetic|map)' \ | egrep -v -i sql \ | awk '/^r\-/ {print $1}' \ | xargs apt-get install --yes Once this is done, you should be able to say 'R' and get to the prompt -- $ R R : Copyright 2003, The R Foundation for Statistical Computing Version 1.8.1 (2003-11-21), ISBN 3-900051-00-3 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative projec

Default Debian Packages

Please, copy and paste into your /etc/apt/sources.list file. (Make a backup first!) If do you found any error, please send me your feedback. Thanks for using! After that, run #apt-get update deb http://ftp.us.debian.org/debian stable main contrib non-free deb-src http://ftp.us.debian.org/debian stable main contrib non-free deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free deb http://security.debian.org/ wheezy/updates main contrib non-free deb-src http://security.debian.org/ wheezy/updates main contrib non-free

罗永浩2012年6月10号北展剧场演讲——夏季篇(完整版).flv

买朋友的车被坑,信任酿成的悲剧!

买二手车被坑的很多,没想到自己买熟人的车被坑的更惨。 他们是高校老师来访问一年,我们是学生,跟他们住了七个月了,一直觉得他们为人正 直老实。 8月份他们要走,我们七月初提出买他们的车,让他们用车用到走的时候。当时没谈价 格,因为是朋友,也不好意思谈,他们就说按照KBB价格给我们。但谁知道后来他们收 我们4600刀,他们买车的时候花了4700刀,修车花了不到500刀,用了10个月。KBB的报 价excellent是4100刀,我们挺郁闷的,但也没说什么就接受了,想着日本车价格虚高 。车是雅阁2000年,10万miles,3个owner。 更惨的还在后面,因为信任他们,所以也没有查carfax和mechanic check就过户了。过 户一周以后,才发现车子有很多问题,要维修的地方不少,而且更糟糕的是这车里程数 被改过,现在至少跑了20万miles,7个owner。悲催啊~~在这以前我们看车一直都很谨 慎很挑剔,看了几个月都没看到合适的,最后才决定要他们的车,没想到就错在最后一 步。 知道这些问题以后,他们说自己也是不知情的,愿意把车收回去,亏多少都是他们的。 可是第二天,他们就变脸了,说这车已经过户了,他们是没责任的,当初也没逼着我们 要这车,让我们为自己的决定负责。不过他们建议把车卖了,说愿意站在朋友的立场上 帮我们分担一半的亏损。按他们意思,是想按照10万miles的情况去卖,卖多了算我们 的,卖少了平分损失。但我们又不想这样骗人。后来我们觉得亏就亏吧,然后直接提议 卖给dealer,他们可能觉得亏损太大,于是简单说了句过户后买卖关系就结束,一点责 任都不肯负。 在他们临走前一天,我们上他们家再谈这个问题,他们还是坚持不负责,不过当天晚上 ,他们打电话过来说身上就剩下500刀了,要的话就去他家拿。我们直接拒绝了。很气 愤~~ 我们花了4600刀买了一个价值不到2000刀的车,还得倒贴一两千刀去修车,以后这车还 不好卖,真亏大了。我们还是学生,拿国家一份补助,两个人用,每个月生活费也就刚 好,他们是老师,国内还有收入,并且他们之前用车帮餐馆送外卖也赚过好几千刀,车 钱都回来了,但现在责任却都推在我们身上,感觉很不公平。朋友之间的交易,真的要 慎思而为之啊。 现在他们回国了,但我们知道他们哪个学校

几年前,我也很憧憬能以股票为生

但是后来我明白了,如果有别的赚钱的途径为什么不尝试一下呢?狡兔还有三窟呢!现 在回想起来,炒股反而是最容易的,只需要买和卖,坐在电脑前面做一个宅男宅女即可 ,只要能保证稳定的利润也不失为一种轻松快乐的赚钱的途径。但是炒股----尤其是想 以炒股为生做短线或波段-----有一个很大的弊端,那就是会遇到瓶颈,也就是说平均 利润到了一定程度以后想往上很难,在这种情况下只有两种解决办法(至少对我来说目 前只能想到两个):一个是像巴菲特那样做价值投资,利滚利,一个就是在做股票的同 时开始转型,有倾向性的做一些其他的行业,如果能同时盈利就可以大幅度弥补炒股的 瓶颈,我是一个急性子的人,所以选择了后者。原则只有一个:坚决不给人打工,我讨 厌被人管,讨厌看别人脸色,更讨厌固定的上班时间,当然了,如果我给别人规定上班 时间我还是很乐意的,呵呵呵!

怎么摆脱contractor公司的纠缠,他们威胁说要sue我

几个月前楼主被裁了,正好有个contractor公司说提供培训,就跟着去上课了。 上了几节课就被要求签一个很狗血的合同,不平等条约都是说各种违反条约的情况楼主 都得给他们付钱。 其中一条就是说一旦签了这个合同,然后不参加他们的marketing不为他们工作就得付 5000美刀。但楼主后来拿到口头offer说三个月后找不到工作就free。 悲催的楼主只好签下卖身契,偏偏在课程结束之后一周就拿到一个offer(这个是一个 多月前朋友帮忙递的,但一直没消息,lz就以为没戏了)。 楼主想给自己干活,但又不想给那华丽丽的5000刀,于是跟他们说要回国了,并且停了 跟他们联系的电话,也没有收到任何来自他们的邮件。 但现在突然接到他们的电话了(这个号码从来没跟他们说过,但可能在求职网站上还有 存留):说知道我没回国,这种行为违反了合约,要sue我。他们怎么确定我没回国的 呢,就因为这个号码吗?而且我也没接过他们的电话啊,他们怎么确定一定就是我呢? 难道contractor公司可以查移民局的记录吗,知道我到底回国没有? 现在楼主打算付一些钱,把事情结了。但怎么开口跟他们谈了,现在说会不会显得气势 太弱,被狮子大开口? 而且他们本身也不合法,楼主明明entry level小虾米一个,跟着上了几节课,就把我 包装成六七年的senior一名。这个,楼主也不习惯这么瞎搞啊。 大家尽管拍我吧,希望能在拍砖之余给点建议。多谢!

不许笑出声!

不许笑出声! 1.下午上班是在困的不行,于是决定下楼买包烟。一出门看见不远处一同事牵着一条藏 獒,又肥又壮。“呦,张哥,哪买的藏獒呀”同事脸都绿了……走近一看,尼玛,他老 婆穿着貂皮袄蹲那儿系鞋带呢…… 2. 今天师傅来装空调,我一再提醒他小心点,安全第一。他说:“看不出来你年纪不 大还很谨慎嘛,放心,出了事我也决不找你的麻烦!”说完就从窗台上滑下来一屁股坐 在我养了五年的仙人球上。那一刻,一到十五楼的声控灯全亮了! 3. 今天和二货朋友逛街,碰到一汽车品牌宣传,二货不认识标志,我告诉她那是宾利 。二货大喊:我操,原来带翅膀的B就是宾利啊!一群围观者被惊醒有木有! 4. 今儿同事的岳父去世,我们前去吊唁。一迟到的哥们捂着腮帮子进来,愤愤的说: 牙疼,刚从医院出来就打车来这了。上车后我疼得受不了了。就躺在后座上了,然后告 诉司机去火葬场。那缺德司机对我说:兄弟不上别的医院再看看了? 5. 周末骑车回家的路上车链出了问题,骑上几圈就掉,骑上几圈就掉。途中巧遇一个 美女,一路上,我骑到她前边一点,然后下车上链子被她超过,修好后超过她,接着链 子再次崩溃,继续下车修。一半路程时我下车修车,美女骑到我身边停下问“你是想要 我的电话么? 6、小孙女对爷爷说:“爷爷,我长大以后一定会孝顺您的!”爷爷说:“等你长大以 后,爷爷都不知道还在不在。”小孙女说:“爷爷您一定还在,因为妈妈说您是老不死 的。” 7、有一次,语文老师留了一个半开放的作文题:“我最佩服我母亲的——”,作文交 上去。到了点评的时候,老师一脸无奈地说:“我知道,你们觉得写什么最佩服我母亲 的勤劳、艰苦之类的,有点写滥了,想推陈出新,但无论如何,也不能写‘我最佩服我 母亲的儿子’啊!” 8、四年级作文《二十年后的我》:一男孩写道:“今天天气不错,我和老婆带着我们 一对可爱的儿女环游世界,突然,路上冲出一个浑身恶臭、满脸污秽、无家可归的老太 太。天啊!她竟然是我的语文老师!”!”——老师给的评语:这个星期你站着上课。 9、一男子在闹市骑摩托撞昏了一个陌生的老汉!男子惊吓的不知所措!围观群众越来 越多!突然,该男抱住老汉,声泪俱下的喊道:“爹,你等着我,我这就去给你找医生 !”说后,就跑掉了。老汉挣扎着愤怒的喊道:“给老子回来!”众人纷纷感慨:“这 儿子当的真孝

逻辑滚动栏管理器

逻辑滚动栏管理器 ( 英语 : Logical Volume Manager ,缩写为 LVM ),又译为逻辑卷宗管理器、逻辑扇区管理器、逻辑磁盘管理器,是 Linux核心 所提供的 逻辑滚动栏管理 (Logical volume management)功能。它在 硬盘 的 硬盘分区 之上,又创建一个逻辑层,以方便系统管理硬盘分区系统。 最先由IBM开发,在 AIX 系统上实现, OS/2 操作系统与 HP-UX 也支持这个功能。在1998年,Heinz Mauelshagen 根据在 HP-UX 上的逻辑滚动栏管理器,写作出第一个 Linux 版本的逻辑滚动栏管理器。

Describe the process that happens when you click a link in your web browser to fetch another web page.

The URL of the link is given to the browser engine, which opens a TCP/IP connection to the address listed in the URL. Assuming the URL specifies the HTTP protocol, and assuming no port is given in the URL, the connection is made to port 80 of the remote host. Various options may be specified in the HTTP headers which effect the expected behavior between client and host, an important and common option being "Connection: Keep-alive"; if this option is specified, the same connection is used to transfer all resources on the page (images, frames, sounds, flash animations, etc.), thus avoiding the overhead of establishing a separate TCP/IP connection for each resource the page requires to be loaded. Requests are made by issuing an HTTP "GET" command, followed by the resource requested. A single GET command may cause the client to request multiple resources (hence the existence of the keep-alive option). Finally, under normal circumstances, the connection is closed after

What is a "cookie"? How do they work? What are the different types of Cookies?

Cookies are small pieces of data used by web servers to help identify web users. There two types of cookies: Persistent and Non-Persistent. • Persistent: Which remains on the user’s machine even after user leaves the site. When they come back web server queries the cookie and if found identifies the user • Non-Persistent: This cookie is used by web server to track the user information during a session. It expires once you leave the website

What is a "proxy server"? How does it work?

Also called a "proxy" or "application level gateway," it is an application that breaks the connection between sender and receiver. All input is forwarded out a different port, closing a straight path between two networks and preventing a hacker from obtaining internal addresses and details of a private network. Proxy servers are available for common Internet services; for example, an HTTP proxy is used for Web access, and an SMTP proxy is used for e-mail. Proxies generally employ network address translation (NAT), which presents one organization-wide IP address to the Internet. It funnels all user requests to the Internet and fans responses back out to the appropriate users. Proxies may also cache Web pages, so that the next request can be obtained locally. Proxies are only one tool that can be used to build a firewall.

What is XML and what is it good for?

 XML is Extensible Markup Language. XML was designed to describe data and to focus on what data is. It is important to know that XML was designed to store, carry and exchange data. It was not designed to display data. With XML, data can be exchanged between incompatible systems. With XML, plain text files can be used to store and share data.

What is TCP? UDP? How do they differ?

 TCP is a connection oriented protocol. It means that a connection should remain between peer to peer entities in two systems for transfer of information. UDP is a connectionless protocol and sends the information in form of packets. Each packet can take different route.

What is a bridge? A router? A gateway?

A bridge is an intermediate system used to connect two LANs that use similar LAN protocols. The bridge acts as an address filter, picking-up packets from one LAN that are intended for a destination on another LAN and passing those packets on. It operates at layer 2 of the OSI model. A router used to connect two networks that may or may not be similar. Router employs an internet protocol present in each router and each end system of the network. It operates at layer 3 of the OSI model. A gateway performs protocol conversion between different types of networks or applications. For example, a gateway can convert a TCP/IP packet to a NetWare IPX packet and vice versa, or from AppleTalk to DECnet, from SNA to AppleTalk and so on. Gateways function at layer 4 of the OSI model.

How does Ethernet work? How big is an Ethernet address?

Ethernet is normally a shared media LAN. All stations on the segment share the total bandwidth, which is 10 Mbps (Ethernet), 100 Mbps, (Fast Ethernet) or 1000 Mbps (Gigabit Ethernet). With switched Ethernet, each sender and receiver pair has the full bandwidth. Ethernet uses the CSMA/CD technology to broadcast each frame onto the physical medium (wire, fiber etc.). All stations attached to the Ethernet are "listening," and the station with the matching destination address accepts the frame and checks for errors. It is a data link protocol (MAC layer protocol) and functions at layers 1 and 2 of the OSI model. A unique number is assigned to each Ethernet network adapter. It is a 48-bit number maintained by the IEEE.

Explain how ping works.

The Packet Internet Groper (ping) utility on the host machine sends data-grams, or packets, addressed to the Internet Protocol (IP) address of the target host using the Internet Control Message Protocol (ICMP) echo request command. If the specified host is operational, it will respond using the ICMP echo reply. The ping utility will then display statistics about the number of lost packets and the amount of time it takes for the response to return from the target host. This utility only verifies that the bottom two layers, Network Interface Layer and Internet Layer, of the TCP/IP stack on the target machine are operational.

You have two machines, both connected to the internet. One you are told has a web server running on it, the other doesn’t have a web browser of any kind. Using the machine without the browser, how can you tell that the web server is running on the other machine?

The common mistake people make here is they answer "ping the machine". That doesn't check anything other than to see if the machine is visible on the network. It has nothing to do with the web server itself. To find out if the web server is running, just telnet to port 80. If the port 80 is open, it doesn't mean that it is the web server listening to that port yet. To make sure it is the web server, you can type a primitive HTTP request like “GET /” and press "enter" twice. If it is the web server, then you should get the index page HTML code on your screen.

储存程序 (Stored Procedure)

储存程序 (Stored Procedure),又可称预储程序或者存储过程,是一种在数据库中存储复杂程序,以便外部程序调用的一种 数据库对象 ,它可以视为数据库中的一种函数或子程序。 目录 1 优缺点 1.1 优点 1.2 缺点 2 支持预存程序的数据库 3 示例 优缺点 优点 预存程序具有下列的好处: 预存程序可封装,并隐藏复杂的商业逻辑。 预存程序可以回传值,并可以接受参数。 预存程序无法使用 SELECT 指令来运行,因为它是子程序,与 查看表 , 数据表 或 用户定义函数 不同。 预存程序可以用在数据检验,强制实行商业逻辑等。 缺点 预存程序,往往定制化于特定的数据库上,因为支持的编程语言不同。当切换到其他厂商的数据库系统时,需要重写原有的预存程序。 预存程序的性能调校与撰写,受限于各种数据库系统。 支持预存程序的数据库 数据库系统 预存程序使用的编程语言 CUBRID Java DB2 SQL PL or Java Firebird PSQL (Fyracle also supports portions of Oracle's PL/SQL) Informix SPL Microsoft SQL Server Transact-SQL and various .NET Framework languages MySQL own stored procedures, closely adhering to SQL:2003 standard. Oracle PL/SQL or Java PostgreSQL PL/pgSQL , can also use own function languages such as pl/perl or pl/php Sybase ASE Transact-SQL 示例 预存程序是数据库对象之一,必须使用 数据定义语言 来创建,例如: 以下示例,以Microsoft的 SQL Server 所以采用的T-SQL语法表示。 CREATE PROCEDURE usp_AddProduct ( @Barcod

What types of index data structures can you have?

)An index helps to faster search values in tables. The three most commonly used index-types are: B-Tree: builds a tree of possible values with a list of row IDs that have the leaf value. Needs a lot of space and is the default index type for most databases. Bitmap: string of bits for each possible value of the column. Each bit string has one bit for each row. Needs only few space and is very fast.(however, domain of value cannot be large, e.g. SEX(m,f); degree(BS,MS,PHD) Hash: A hashing algorithm is used to assign a set of characters to represent a text string such as a composite of keys or partial keys, and compresses the underlying data. Takes longer to build and is supported by relatively few databases.

State some advantages and disadvantages of indexing database tables.

 Advantages: Faster querying of data Disadvantages: Slower Insert, Slower Updates (if you are also updating the primary key). Apart from the problems mentioned above most indexing structures suffer from the “the dimensionality curse" which is the exponential growth of data volume as a function of dimensionality as a result of which query processing becomes much slower.

What types of join algorithms can you have?

What types of join algorithms can you have? There are three kinds of JOINS in SQL Server, Nested table, Merge and Hash joins. All of the above depend upon the resources available, MERGE and HASH consume lots of memory; so, a system that is low on memory would sparingly resort to the above two join methodologies. Nested table joins are based on the fact that indexes exist on nested tables in a SELECT query, for each row in the outer table, a scan is done for the rows available on the inner tables' rows. If a match is found, that row is retrieved.

What is "normalization"? "Denormalization"? Why do you sometimes want to denormalize?

Normalizing data means eliminating redundant information from a table and organizing the data so that future changes to the table are easier. Denormalization means allowing redundancy in a table. The main benefit of denormalization is improved performance with simplified data retrieval and manipulation. This is done by reduction in the number of joins needed for data processing.

What is a "transaction"? Why are they necessary?

 A transaction is a series of data manipulation operations mostly triggered from the client end that must be committed into the database as one whole operation. This means that a transaction is complete only when all the series of data manipulations involved have been successfully committed into the database. All transactions must follow the ACID rules. • Atomic - All operations execute or No operations execute. • Consistent - After the operations execute, database is in a consistent state as it was before execution. • Isolated - Appropriate locks are placed on shared data in order to isolate the operation on the data. • Durability - Data must be persisted on hard disk, so that if there is a crash the data is durable.

What is the difference between a "where" clause and a "having" clause?

“Where” is a restriction statement. You use where clause to restrict data being accessed from the database. Where clause is used before result is retrieved. But having clause is used after retrieving the data. Having clause is a kind of filtering command. You should always use a WHERE clause in preference to a HAVING clause, if possible.

Write a function to find the depth of a binary tree.

o find the depth of a binary tree, let us assume that each node of the tree is defined as: struct Node { int data; Node * left; Node * right; }; Now, walk through the left and the right node using recursion to find the depth of the tree int depth(Node * N) { if (N == 0) return -1; int DL = depth(N->left); int DR = depth(N->right); return (DL > DR) ? DL+1:DR+1; }

Do a breadth first traversal of a tree.

Use a queue to traverse the tree, dequeueing a node when it is visited, and enqueueing its children. The pseudo code is given below: traverseLevelOrder (Tree t) { Queue q = new Queue() q.enqueue(t) while !q.isEmpty() { Node current=q.dequeue() if (current<>NULL) { q.enqueue(current.left) q.enqueue(current.right) } } }

Give me an algorithm and C code to shuffle a deck of cards, given that the cards are stored in an array of ints. Try to come up with a solution that does not require any extra space.

A sample implementation to shuffle a deck of cards might look like this: void shuffle( int * cards) { int curr, victim, size, temp; curr = 0; size = 52; // assuming it's a regular 52 card deck while(curr < size) { victim = rand() % size; cout << rand() << "\n"; temp = cards[curr]; cards[curr] = cards[victim]; cards[victim] = temp; curr++; } }

You are given one fixed list of numbers (let’s call it the first list) and one other list (second list). How can you efficiently find out if there is any element in the second list that is an element of the first list?

You are given one fixed list of numbers (let’s call it the first list) and one other list (second list). How can you efficiently find out if there is any element in the second list that is an element of the first list? Hash each of the numbers in the fixed list to a hash table using a function that will return a distinct hash value for each of the numbers in this fixed list (size of the hash table itself is irrelevant, as long as it is larger than the number of numbers to be put in it). In the second list, for each value, determine the hash value. Compare this to the number in that location in the hash table. If the number is the same, the element is in both lists. If the number in that location is different or does not exist, then the element in the second list is not in the first list.

The web can be modeled as a directed graph. Come up with a graph traversal algorithm. Make the algorithm non-recursive and breadth-first.

Pseudo code to model the web as a graph may look something like this: URLlist <- br="" for="" queue="" storing="" urls.="">URLlist.push(intial list of URLs) while (!URLlist.empty()) { URL = URL.pop() if (seen(URL)) continue; setseen(URL) fetch URL for all the URL's in the page pop them on the URLlist }

Implement an algorithm to reverse a doubly linked list.

Here is sample code to reverse a doubly linked list: using both, iterative and recursive, method is given below: node* rev_dlist(node* n) { while (n) { node* t = n->next; n->next = n->prev; n->prev = t; if (!t) break; n = t; } return n; } Using recursion, the above can be implemented as: node* rev_dlist(node* n) { if (n) { node* t = n->next; n->next = n->prev; n->prev = t; if (!t) return n; return rev_dlist(t); } return 0; }

How would you find a cycle in a linked list? Try to do it in O(n) time. Try it using a constant amount of memory.

There are quite a few ways to solving this problem. Here are a couple of them: If you have access to the code, add a new field "visited" to the node structure and initialize it with 0. typedef struct { int visited; ...Other fields.. } Now, start traversing through the linked-list checking for the value of this visited field. If the value is set to 0, set it to 1 and go to the next node in the list. If you find a node with its visited value set to 1 before you reach the end of the list, there is a cycle in the linked-list. If not, there is no cycle present in the list. As you can see this takes O (n) time but requires variable amount of memory. To accomplish this task using constant memory is much more challenging at first. If you like simple yet challenging problems, try it yourself before looking at the answer below. bool cycle_finder(Node *head) { Node *p1, *p2; bool hasCycle = false; p1 = p2 = head; while (p2 && p2->next) { p1 = p1->next; p2 = p2->next-&g

Say you have three integers between 0-9. You have the equation: A! +B! +C! = ABC (where ABC is a three digit number, not A*B*C). Find A, B, and C that satisfies this equation.

145 = 1! + 4! + 5! , making it a factorion . The only other numbers that have the property that they are the sum of the factorials of their digits are 1 , 2 and 40585.

Do the class/structure description for a Hash table, and write the source code for the insert function.

A very simplistic and limited implementation of Hash table may look something like this: For a 100 entry hash table of words, put in the arguments from the command line into the hash table: #define MAX 100 char **hashTable; int hashIndex(char *); int main(int argc, char **argv) { if(argc < 2) { printf("invalid input\n"); exit(1); } hashTable = (char **)malloc(argc * sizeof(char *)); for(i=0;i hashTable[i] = NULL; } while(count < argc) { index = hashIndex(argv[count]); if(!hashTable[index]) { hashTable[index] = (char *)malloc(strlen(argv[count]) *sizeof(char)); strcpy(hashTable[index], argv[count]); } else { //resolve collision count++; } } return 0; } int hashIndex(char *wd) { int count, index=0; int len = strlen(wd); while(count < len) { index += atoi(wd[count]); } index = (int) index % MAX; return index; }

indent multiple lines quickly in vi?

Use the > command. To indent 5 lines, 5>> . To mark a block of lines and indent it, Vjj> to indent 3 lines (vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use >% . If you’re copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p . This aligns the pasted block with the surrounding text. Also, the shiftwidth setting allows you to control how many spaces to indent.

Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words in it. (

One way to reverse the order of words is: string word_reverse(char * data) { char c = ' '; string s=data; int len=strlen(data); vector output; int i=0; while(s[i]!='\0') { if(s[i]==c) { output.push_back(s.substr(0,i)); s=s.substr(i+1,len); i=0; continue; } i++; } output.push_back(s); s.erase(0,s.length()); string s1; for(int j=output.size()-1;j>0;j--) { s1+=output[j]; s1+=" "; } s1+=output[0]; return s1; }

Count the total number of set bits in a number without using a loop.

) Sample implementation that counts total number of set bits using recursion is given below could be: unsigned int number_of_ones(unsigned int n) { if(n&1==1) { return 1+number_of_ones(n-1); } else { retrun number_of_ones(n/2); } } Using loops this can be accomplished as below (Note: The solution below doesn’t loop over the whole 32 bits, usually, of an unsigned integer) unsigned int bitcount(unsigned int x) { unsigned int count; for(count = 0; x; x &= (x-1)) count++; return count;  } You can also use a lookup table to count the number of set bits.

Implement an algorithm to reverse a singly linked list (with and without recursion).

Below is a sample implementation that reverses a singly linked list using recursion. The simplest way to do this with recursion is: void rev(Node* head, Node* prev) { if (!head) return; rev(head->next, head); head->next = prev; } Head is now pointing to the end instead of the start of the list. To fix that, you can use a wrapper function like below: void reverse(Node* &p) { if (!p) return; for (Node* tmp = p; tmp->next; tmp = tmp->next) { } rev(p, NULL); p = tmp; } An iterative algorithm to reverse a singly linked list is presented below: struct node *revlist (struct node *root) { struct node *np = root, *t, *r = 0; while (np) { root = np; t = np->next; np->next = r; r = np; np = t; } return root; } Note that an iterative solution to this problem is better than a recursive one, since every recursive call uses up more memory on the stack, and large lists can cause the stack to overflow. The iterative solution uses a constant amount of memory, so it’ll work fine no

A square picture is cut into 16 squares and then shuffled. Write a program to rearrange the 16 squares to get the original big square.

uppose the original picture is 16 pieces and the individual pieces are numbered as follows. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 The problem is then, given any one of these numbered pieces, how do you place each piece in the correct position in a two dimensional array. Let the string str contain the shuffled pieces. Then - int **restore(char const *str) { int x,y,i; int final[4][4]; for (i = 0, i < 16, i++) { if !(str[i]%4) { x = (int)(str[i]/4) - 1; y = 3; } else { x = (int)(str[i]/4); y = (int)(str[i]%4) - 1; } final[x][y] = str[i]; } return final; } Check: say str[i] = 5 x = 1 y = 0 So final[1][0] = 5 which is the correct position in the actual picture say str[i] = 12 x = 2 y = 3 So final[2][3] = 12 and so on. (Return to questio

Write an algorithm and C code to find the sub array with the largest sum given an array that contains both positive and negative integers

The information to be kept while going through the array only once (O(n)) is the best sub array ending in the current position and best sub array found for the entire array until the current step. If necessary, the starting and ending position for the sub array can be kept. After the processing of the last element, the algorithm will have determined the sub array having the largest sum. The algorithm works fine even if there is no negative number in the array. Algorithm: “arr” is the array of n integer. The function will return the largest sum and the limits of the sub array producing that value. int GetBestSubArray(int* arr , int n , int* nBegin , int* nEnd) { //starting/ending position of the best sub array for entire array int nBestBegin=0,nBestEnd=0; //starting/ending position of the best sub array ending in //current position int nCrtBegin=0,nCrtEnd=0; // index to loop in the array int nCrtIndex = 0; //the sum of whole best sub array and the sum of current best //sub array int nB

车祸后被拖车公司敲诈了1600多刀,可以告他们吗?

我去年年底出了个大车祸,人在医院躺了一个月,车total了。 出事时我老公不在美国,等他办完签证回来美国的时候我已经住院一个多礼拜了。然后 他接到了拖车公司的bill,说我的车陂拖走了,要交200多和每天35的存车费一共500多 。当时我老公忙着在医院照顾我,没空去取车,就打了个电话给拖车公司,跟他们说了 我们的情况,问能不能只收拖车费,免掉存车费,对方态度很差,说一毛钱都不能减。 因为我的车在车祸时起火了,警察的报告是说total了,所以我们就不打算再去取那车 了。 结果等我出院之后,拖车公司给我寄了封信,说bill已经涨到1600多刀了,再不去取车 就要告我们,会吊销我老公的驾照!!我当时虽然已经出院了,但是伤口还没close, 人也不能自理,我老公每天要给我换药照顾我,还要开车带我去看医生复查,如果没有 驾照会很麻烦,我老公就想赶紧解决掉这事,不想再让拖车公司纠缠我们。我出事的地 方离家差不多100迈,我老公来回开了几小时去交了1600多刀,那车就在当地处理掉了! 现在我的伤恢复得也差不多了,突然想起这事,觉得这个拖车公司很过分。我出事后人 躺在医院昏迷了三天,出事时我老公也不在美国,拖车公司收拖车费也就罢了,每天收 这么多存车费也太乘火打劫了! 不知道版上有人知道这种情况能告他们么?是要自己申请small claim court还是要找 律师?我完全没有头绪,如果谁能提供一些建议,非常感谢!

没想到薄熙来这么清廉

没想到薄熙来这么清廉 在薄熙来还如日东升之时,我曾经在一篇文章中这样说过(大意):不相信薄熙来像他 表面展现的这么“红”、这么清廉,当然,我相信他在重庆是清廉的,但以前在大连、 在沈阳时期呢?身处市场化大潮滚滚的时代,官场风气如此,自己又背景雄厚、敢作敢 为,薄熙来有可能在经济上不湿鞋吗?我那时觉得,他当年在大连应该也和其他官员差 不多,甚至可能胆子更大。 但这几天的济南审判,颠覆了我上述判断。通过庭审时各种细节的披露、以及控辩双方 激烈交锋,相信任何一个还存留起码理性的人都能看出,如果官方还能找到薄熙来在经 济方面的其他把柄,决不可能是现在这种表现,绝不会让自己陷入目前这种狼狈窘境; 薄熙来也不可能像现在这样理直气壮。庭审进行到今天,即使起诉书所列举的薄熙来罪 状桩桩属实,他也大大颠覆了我心目中对这个等级官员的印象----在我的认知中,很少 有官员拥有薄熙来这么大的权力,贪欲却如此不“旺盛”。 何况,即使仅依据目前公开披露的庭审记录,也已经可以作出推断:检控方所列举的贪 腐事实,基本上都只是谷开来瞒着薄熙来独自进行的。在昨日最后的法庭辩护阶段,薄 熙来发出了自此次庭审以来最雄辩有力的声音(就庭审记录的公开部分而言):“之后 十年谷开来一直在瞒着我,她费尽心机、屡遭挫败,甚至怒气冲天,最后铤而走险。这 十年有任何一个环节谷开来向我说过什么吗?和我商量过什么吗?请我帮过什么吗?所 有的情节一概没有!这合理吗?真有什么困难她应该和我商量商量,她干嘛不跟我商量 商量?我是她丈夫啊,我是知情人啊?有无数情节和机会。谷开来费这么大劲,为什么 不找我商量?直至尼尔・伍德和德某某出现,她宁肯找王立军和徐明说,但就是 对我守口如瓶,案卷中没有任何一点显示我知道这些事情。这不让人奇怪吗?我总应该 比谷开来权力大一点吧?能力、办法多一点吧?如果我知情,她跟我商量商量我再改上 几笔,再跟郭某某以某种方式通个信息,把握不是更大吗?但这个事没办成,多可惜啊 ?”----这一系列反问,以一种无可辩驳的逻辑力,一下击穿了我心中最后残存的困惑 ,就像八百多年前那次著名的审讯中,当狱卒剥下岳飞的上衣,突然袒露出他背上“精 忠报国”的四个大字一样。确实,如果谷开来将困难、将瓜瓜受到的威胁告诉薄熙来, 绝不可能发生后来系列事件。至少无论如何,

最极品的报告

现在想想, 人生在世,不过就是吃饱,穿暖,跟合得来的人在一起,做自己喜欢做的 事情。从这几点上来说,做科研都是很值得,很惬意的事情。做科研,最开心的当然是 自己的研究有成果,有突破。另外呢,跟牛X的人交流,或者读牛X的人的文章,那种如 沐春风,畅快淋漓,或者醍醐灌顶,豁然开朗的感觉,也是很爽的。但是呢,又有另外 一件事情,有另外一种爽法,那就是听很变态,很极品的报告。我这里跟大家报告一下 我听过以及听到过的最极品的报告: 第五名:做报告的是哈佛物理系的一个教授,搞基本粒子物理的。报告的开头,他为了 证明自己做的东西很牛X,居然放了一段Youtube的录像,是Jim Carrey 去 Conan O’ Brien 的talk show。Conan O’Brien 问他,你平时没事的时候都干啥呵,Jim Carrey 说,我没事喜欢看科学文献,比如说,我昨天读了一篇文章叫:“Stochastic Phase Switching of a Parametrically Driven Electron in a Penning Trap”,这里边讲 到……呵,真是有趣。这篇文章就是这个牛X教授1999年在Physical Review Letters上 的一篇文章。 第四名:一个试验物理的教授,在做报告的时候,用网络视频搞现场直播,连线到他的 实验室,他的学生正做实验,他就问,今天试验状态怎么样啊。然后他的学生就show给 大家看,今天状态怎么怎么好,结果怎么怎么牛。 第三名:一个原来在斯坦福的中国教授,本来是搞分子反应动力学的,后来走火入魔了 ,开始研究气功。一个大会邀请他去讲座。结果他花15分钟讲自由基(free radical) ,后面15分钟就开始讲气功,说经过他多年的研究,发现“气”无非就是人体内的自由 基…… 第二名:一个挪威的教授。他的报告分好几个部分,分别是他们实验室几项牛X的成果 。第一个成果讲完了,他就放了一张金发碧眼美女冬装的照片,然后说,你们大家说我 这个成果是不是很beautiful阿,就跟这张照片里我们挪威的女人一样beautiful。等到 第二个成果讲完,他又放了一张美女秋季运动装的照片,说,你看,我这个成果,就是 这样的beautiful。等到第三个成果结束,是春季休闲装。第四个

Write a function to print all the possible permutations of a string. Now, modify the algorithm to discard duplicates.

Below is a sample implementation that prints all possible permutations of a string: #include #include const int MAX_STR = 20; void CopyStr(char *s2, char *s1, int i) { for (int j = 0, k = 0, len = strlen(s2); j < len; j++) { if (i != j) { s1[k++] = s2[j]; } } s1[k] = '\0'; } void Permute(char *str1, char *str2) { int len = strlen(str1); if (len == 1) { //If you do not want to print duplicates, put the result in a // hash and then print the hash table. cout << str2 << str1 << "\n"; return; } for (int i = 0; i < len; i++) { char currentChar = str1[i]; char str3[MAX_STR]; CopyStr(str1, str3, i); int len2 = strlen(str2); str2[len2] = currentChar; str2[len2+1] = '\0'; Permute(str3, str2); str2[len2] = '\0'; } } int main () { char someStr[MAX_STR], someOtherStr[MAX_STR]; cout << "Enter a string(less then << MAX_STR << “characters:” "; cin >> someStr; someOtherStr[0] = '\0'; cout << &quo

Since web pages can have multiple URLs pointing to them, as a web browser developer how can you make sure you have never seen the same content before?

Make a list (or a binary tree) of hashes using MD5, SHA1 or a similar hash/digest algorithm of the pages you have visited. Then compare the digest of the current page to the hashes in the tree. A hash table is good here too! A hash table of other longer hashes is a quick, easy, and efficient solution.

design a browser

You are developing a web browser (something like e.g. Netscape, etc.) and need to display all visited links on a page. The visited links need to use a different color then that used to display scheme than the unvisited links. Now, given a history of links you have visited before, how would you go about writing the piece of code that makes the determination if you have seen this link before? Answer or not? The answer could be a simple string comparison, but then think about the time it will take for the client to render any HTML page. Alternatively, so, given a history of URLs, come-up with an elegant way (algorithm, data structures, etc.) to make the determination if a given link already exists in the history list? Using a Hash Table is probably the most efficient way to do this. You can use several hashing algorithms. For example, checksum of a link can be used as a key for hashing. This will ensure o (1) order provided a good checksum algorithm is used. Whenever a page loads, we can

ALGORITHMS & CODING

1) You are developing a web browser (something like e.g. Netscape, etc.) and need to display all visited links on a page. The visited links need to use a different color then that used to display scheme than the unvisited links. Now, given a history of links you have visited before, how would you go about writing the piece of code that makes the determination if you have seen this link before? Answer or not? The answer could be a simple string comparison, but then think about the time it will take for the client to render any HTML page. Alternatively, so, given a history of URLs, come-up with an elegant way (algorithm, data structures, etc.) to make the determination if a given link already exists in the history list? (Answer) 2) Since web pages can have multiple URLs pointing to them, as a web browser developer how can you make sure you have never seen the same content before? (Answer) 3) Write a function to print all the possible permutations of a string. Now, modify the algorithm t

What are the steps you take to write a program?

Refer to Code Complete or other similar titles by “Steve McConnell” (or any other book you know of) for a good Software Design Life-Cycle process. In short, the following steps generally make for a good SDLC: Start with clear requirement specification. Start designing with the core functionality in mind. The approach (top-down or bottom up) depends on whether the project is about writing a system from scratch or adding new functionalities. Implement the core functionality. Unit test core functionality to see if it is scalable and robust. Ensure that it has well defined interfaces for other modules. Start adding layers of other functionalities. Unit test and integrate the layers with the core functionality Keep working on the core functionality so as to make it more efficient. Many other aspects are also involved, but this should form the basis of good software.

How do you multiply an integer variable by 16 without using the multiplication, addition or division operator? What if you have to multiply by 15?

How do you multiply an integer variable by 16 without using the multiplication, addition or division operator? What if you have to multiply by 15? This is usually done by using bit-shifting operators (<< or >>). When you left shift a variable by 1 bit, you are essentially multiplying it by 2. Similarly, when you right shift a variable by 1 bit you are dividing it by 2. So, to multiply a variable by say 16, you can just left shift the variable by 4 bits (2*2*2*2 = 16). To multiply a variable by 15, you can multiply it by 16 (as above) and then subtract the original. Divide is very similar, just reversed. This operation may generate overflows/underflows, etc. A follow-up question can be how would you propose we handle these situations? You might get extra points afterward by engaging a discussion on why using bit-shifts these days is not usually a good idea. At the hardware level, bit-shifts and adds/subtracts are much faster than multiplication, but modern optimizing compil

How will you test a vending machine?

To test any software system, first you need the software requirements specification. So if you are asked to test a system, ask for the software requirements specification first. If there is no SRS, then you cannot test anything because you do not know what constitutes correct behavior. Now for the Vending machine. After getting the SRS, take each requirement and expand it into test cases. When a quarter is inserted, the user is asked to choose an item. When an item is chosen, the item will fall through slot. If the item is unavailable, the user will be told so and asked for another choice. If the user hits cancel, the money is refunded. Correct change will be made if the user puts in more than the purchase price. Additional change will be requested if the user puts in less than purchase price. Then proceed to test these requirements one at a time, using multiple choices and money inputs. The following questions may also be asked in conjunction with the original question: How about if

hat is a linked list?

A link list is a data structure which overcomes the problem associated with arrays (i.e. fixed size). The size of a link list can be manipulated dynamically. Where conventional lists arrange information in a linear sequence, linked lists are able to manage discontinuous bits of information through the use of pointers that link them together. This allows users (or list managers) to insert new pieces of information at any point in the list without having to disturb any of the existing pieces by merely adjusting pointers to link to the new value.

What is disk interleaving? Why do you need ?

To speed up the read access of the disk, the sectors are arranged such that when the computer finishes reading the sector, the disk head is on the position of the next sector to be read. Interleaving, with disk-based storage, refers to the physical arrangement of data sectors on a computer disk in such a way that sequentially read sectors are not necessarily contiguous. A disk, especially a hard disk, usually spins so fast that the computer cannot process the data from one sector before the next sector passes the head. Interleaving alternates sectors in a pattern that increases the likelihood that when the computer is ready for the next sector in numeric sequence, it will be the sequence just arriving at the head. For example, rather than being arranged in numeric order (1, 2, 3, 4 . . .) on the disk in a 1-to-1 interleave (no intervening sectors), sectors might be arranged in a 3-to-1 interleave pattern (1, 12,7,2,13,8,3 . . .), in which consecutive sectors are separated by two other

What is the difference between multitasking and multithreading?

They sound similar, but are very different. Multitasking refers to the ability of the operating system to execute multiple programs simultaneously. The processing time is shared between the programs. In preemptive multitasking, the OS divides the time between processes. In cooperative multitasking, the processes control the CPU for as long as it needs and then releases it for the next process to take ownership of the CPU. For example, multitasking in the Windows OS enables the user to use MS Word and MS Excel at the same time. Windows 2000 is preemptive, but Windows3.1 is cooperative (that's why one misbehaved application freezes the whole system). Multithreading refers to the ability of the operating system to execute multiple parts of a process simultaneously. The threads usually have access to the resources allocated by the main thread (process). Multithreading is usually used to do background processing without affecting the responsiveness of the program. For example, the user

implementing the software for an IP router.pr

You are implementing the software for an IP router. When a packet comes in, the router has to decide which link to route the packet out on, based on its destination IP address. How would you implement this? How would you optimize for speed? How would you optimize for space? Assuming that destination IP addresses are stored in a hash table, you can to do a lookup based on the destination IP address of the incoming packet. However, the question is what kind of algorithm to use to generate the hash? The two ends of the spectrum are using a hash table of size 2^32 (32 for the 32-bit IP address) in which case the time complexity would be O (1) but the space complexity will be very high (not practical). On the other end you can use a binary search lookup, with time complexity of O (log n). The right fit will depend on the time/space trade-off the particular application in question can make. See a fantastic paper on this topic at http://citeseer.nj.nec.com/crescenzi99ip.html.

List some of the problems unique to distributed databases?

Among other things, the following points must be considered while designing a distributed database: Storing data (fragmentation/replication, horizontal/vertical table partitioning) Catalog management (naming, data independence) Query processing (cost-based optimization, semi-join) Updating data (synchronous/asynchronous) Concurrency (distributed deadlock) Recovery (2 or 3 phase commit)

elevator design

 How can computer technology be integrated into an elevator system for a hundred story office building? How do you optimize for availability? How would variation of traffic over a typical work week, floor, or time of day affect this? How would you test this system? Implement a model similar to thread scheduling models found in most multitasking OS. Some points to consider: Some floor may have higher priorities, like the executive's floor for instance. Calls from those floors would always be serviced first. The elevator should only stop at a floor for x number of seconds, to avoid monopolizing the elevator. This time would be decreased during busy hours and increased during slow hours. If, for some reason, a floor has an elevator call outstanding for some long period of time, that floor's priority gets boosted so that it's serviced immediately. Based on weight (or # of people or some other similar metric) the elevator car could know when it's full and ignore calls until

GENERAL

1. GENERAL 1) How would you describe yourself? What are your strengths and weaknesses? (Answer) 2) Tell me about some of the major projects you have worked on. What challenges did you encounter and how did you deal with them? (Answer) 3) What were your biggest (professional) mistakes and successes? What did you learn from them? 4) What is the biggest misconception about you amongst your colleagues? Or friends? (Answer) 5) What is your ideal job? (Answer) 6) Why are you looking to change jobs? Why did you decide to seek a position with this company? (Answer) 7) In what ways do you think you can make a contribution to our company? 8) How much salary are you expecting? 9) Where do you see yourself in the future, say 5 years from now? (Answer) 10) How well do you work in a team environment? Can you give me an example of when you disagreed with a team, and how you dealt with it? Describe a situation in which you had to lead a team of people over which you had no formal authority.

PROGRAMMING FUNDAMENTALS

2. PROGRAMMING FUNDAMENTALS 1) How can computer technology be integrated into an elevator system for a hundred story office building? How do you optimize for availability? How would variation of traffic over a typical work week, floor, or time of day affect this? How would you test this system? (Answer) 2) Suppose we wanted to control different parts of a home using a computer. Describe the high level architecture of the system you would use to do this? (Answer) 3) List some of the problems unique to distributed databases? (Answer) 4) You are implementing the software for an IP router. When a packet comes in, the router has to decide which link to route the packet out on, based on its destination IP address. How would you implement this? How would you optimize for speed? How would you optimize for space? (Answer) 5) Find the fastest, simplest algorithm you can for determining if two rectangles overlap. (Answer) 6) What is the difference between multitasking and multithreading? (Answer

Where do you see yourself in the future, say 5 years from now?

The interviewer wants to know if your plans and the company's goals are compatible. Let him know that you are ambitious enough to plan ahead. Talk about your desire to learn more and improve your performance with time. Be as specific as possible about how you will meet the goals you have set for yourself. Also, keep in mind that the interviewer is mainly interested in what you can do for the company, not what the company can do for you. It helps if your long-term goals help the company too, for example “I would like go into management eventually, so I see myself as a manager for a successful product.” If you don’t have any specific plans you could use a prepared statement like “Five years from now, I see myself being an integral part of the this companies culture, being rewarded and appreciated for putting my best efforts forward, and geared up to take up a more challenging role here!”

hy are you looking to change jobs? Why did you decide to seek a position with this company?

Few questions are more important than these, so it is important to answer them clearly and with enthusiasm. Show the interviewer your interest in the company by sharing what you learned about the job, the company and the industry through your own research. Talk about how your professional skills will benefit the company. Unless you work in sales, your answer should never be simply "money"!! ☺

What is your ideal job?

If you know what motivates you, try to frame that in the context of the position you are applying for. If you do not want to give a specific answer, then try preparing a short organized statement you are comfortable with. For example: "My ideal job is the one that I can contribute my skills or knowledge on a daily basis and, in the process, add significant value to the company ".

Tell me about some of the major projects you have worked on. What challenges did you encounter and how did you deal with them?

When going to an interview, you should always be prepared to speak about difficult situations that you have encountered in the past and how you were able to effectively resolve them. It is good to remember at least three. And remember, the situation should always reflect an attribute that you think the employer/interviewer would admire. Some companies train in “Behavioral Interviewing”. Its premise is that past behavior is a very good predictor of future behavior, and the interviewing process focuses on asking lot of specifics on your past history. For example: “Tell me about a time you had a disagreement with a coworker, and how you dealt with the situation.” The best preparation for this and many other interview questions is to have two or three projects that had many challenges, and be prepared with details on how you overcame them.

How would you describe yourself? What are your strengths and weaknesses?

These types of questions are often best answered by focusing on 5 to 6 of your strong selling points. The answer should include your achievements, skills and talents that would enable you to succeed in the position that is being discussed. When asking this question, the interviewer is not looking for your history of school work and employment, but is giving you a chance to sell yourself in about 60 seconds. It is important to that you limit your answers to 60 seconds or so if possible, because if you go on talking about your past at length the interviewer might loose interest and may not remember the key points you were trying to communicate. If you have sufficiently researched the organization, you should be able to find out what skills the company values the most. Make sure that your strengths cover most of these skills. While talking about weakness, be positive; turn a weakness into strength. For example, you might say: "I often worry too much over my work. Sometimes I work la

文科生泡妞利器被码工摧毁了

你羡慕那些出口就会吟诗的文人吗?现在可以不用再羡慕他们了!因为一位网友“ yixuan”闲来无事,把《全宋词》拿出来“捣鼓”,算出了其中的99个高频词汇。熟记 这些高频词,你就可以随性所欲进行创作了!你还可以用“无序”的数字来创造一首“ 美妙绝伦”的宋词,圆周率也可以哦! 简化宋词就是“东风何处在人间”   署名为“yixuan”的网友在个人博客里写道:“突然想看看宋词里面什么样的意象是最 常见的,比如可以做个频率分析什么的。当然文本挖掘需要分词,我没法在其中花太多 时间,于是想出了一个土办法。宋词的句子都很短,如果穷举可能的字的组合的话并不 是太多,况且最常见的词语一般是两三个字,这样可能的组合就更少了。”比如“犹解 嫁东风”这句话,可能的二字组合是“犹解”“解嫁”“嫁东”“东风”,三字组合是 “犹解嫁”“解嫁东”“嫁东风”,词的字数越多,可能的组合就越少。如果把每句话 可能的字的组合都列举出来,就可以整体统计频率了。”大家一致分析这位网友一定是 个理科生。 随后, “yixuan”贴出了他算出来的高频词,排在前面的分别是: 1、1485 2、东风(1382) 3、何处(1230) 4、人间(1202) 5、风流(857) 6、归去(812) 7、春风(802) 8、西风(779) 9、归来(771) 10、江南(765) …… 至于为什么第一名是数字,他解释:“排在第一的是无效字符,这跟数据源有关。” 这个结果一出来,一位网友就一语道破了“玄机”,“原来,最流行的宋词就是‘东风 何处在人间’啊!” 生日、手机号 随意组合都很美 还有更绝的呢!署名为“达芬奇的鸡蛋”的果壳网友不知怎么地,就想到了拿大家都会 背一点的圆周率进行创作,两个数字一断,对照高频词表,一首“华丽丽”的词就出来 了!还附上了说明,特别像模像样。 达芬奇的鸡蛋 @ 果壳 清平乐·圆周率 回首明月(一看就是抒情诗) 14 15 悠悠心事空(果然,貌似失恋了) 92 65 西湖何事寂寞中(触景生情) 35 89 79 风吹斜阳匆匆(回忆那天下午的艳遇) 32 38 46 芳草平生斜阳(平生见过最美的太阳和芳草,都是因为那里有你的身影) 26 43 38 风吹寂寞今日(到现在就剩我自己)

What is the difference between new()/delete() and malloc()/free ()?

The main difference is that malloc() and free() don't know anything about constructors and destructors, where as new and delete do. The following lists the main differences: new automatically computes the size of the data object. In malloc you would have to use the sizeof operator. new automatically returns the correct pointer type. In malloc you would have to use a type cast. with new you can initialize the object while creating the object. new and delete can be overloaded. It's safe to delete a NULL pointer, but you'll get core dump to free a NULL pointer.