Monday, April 30, 2012

Given a function bool Zoo(int x) and its called for y times , how you will generate the true with probability x/y times .

lest say if x = 65 & y=100, how will you generate true with probability 65/100. You can represent true by 1 and false by 0.

Sunday, April 29, 2012

Find the kth smallest element in a (MxN) matrix.

PS:Think how efficiently u can do same for an array .

Tuesday, April 24, 2012

Three tips to succeed as a programmer

I Found its worth to read so thought to share.......

I've learned a lot of things over the years that I wish I knew before I graduated. From choosing the right job to figuring out where to focus in programming, here are three simple tips I’ve learned to help you as you embark on your career in software engineering.

1. Look for jobs that will let you program. 
You didn’t spend the past four years studying this field to stop now, right? You want your job title to be ‘software developer,’ ‘software engineer,’ ‘programmer,’ ‘coder’ or whatever other name describes exactly what you want to do.  So, make sure to steer clear of positions in marketing, testing, sales, etc. and seek out companies that are interested in hiring and mentoring you along your chosen career path.

2. Don’t give up on becoming a programmer.
Your education is only just about to begin.  After spending years obtaining a degree, brace yourself because the amount of time you’ll spend working on collaborative projects is where the real fun kicks in.  So far, you’ve probably been writing code, and that’s good. But to be a programmer, you need to learn how to read code. That’s the hard part because it requires you to understand, maintain, fix, and extend existing products.  You will have to become very good at reading code and deciphering what other programmers intended to do.

This will be frustrating and hard. You’ll feel like you’re not good at it, like the job is too difficult, like you could do so much better if you only rewrote everything from scratch. But it’s not too hard, and with practice, you will get better, and you will understand. Expect it to take time, and know that the rewards are certainly worth it - good programmers can change the world.

3. Learn how to take charge of your career.
Spend some time to figure out if you want to work on front-end code, back-end code, new product, or something else. Ideally, you’ll get to move around and learn from each unique position. So, if there’s some new and interesting opportunity to move, raise your hand and find your spark. People are not likely to come searching for you when great opportunities show up because there are probably going to be plenty of other people to choose from.

This can be hard, but you need to get out of the mindset that you are being pushy, demanding or somehow greedy when you do this. I’m not saying you need to trample over everyone around you and fight to the death, nor am I saying that you should demand to be given a new task. What I am recommending is that you find a way to politely indicate your interest and excitement about the opportunity to the right people- your boss, whoever is in charge of the opportunity, possibly the lead developer, etc. Find out how you could be a part of it and make the transition. The worst-case scenario is that you are told you are not quite ready; in which case you can work on figuring out what else is needed and be ready for the next opportunity that comes up.

Part of managing your career means taking a stock of your personal progress once or twice a year, especially early on in your career. Are you achieving your goals? Are you getting more complex tasks? Is your work increasing in scope and importance? If you notice yourself stagnating, take action right away. You don’t want to find yourself five years after starting your job still at the same level as a college new grad.

So, remember: learn how to read code, dedicate yourself to programming and manage your career.  Soon, you’ll be up and running in the programming world and making an impact.

Source: Goranka Bjedov is a capacity engineer on the Tech Ops team at Facebook. Goranka recently shared some of this advice at a computer science event with women from Mills College in Oakland, Calif.

Tuesday, April 17, 2012

Never Stop Hacking- A Good Post After Long Time :)


Though it comes out from some other programmer's heart but its pretty much reflects my life so thought to share it with readers .A must read for programmers :)

This is a quick post, something that I have to get out of my mind and onto paper (err, the internets!).

I was thinking earlier today about what makes me happy--really, truly happy. I had just stopped coding, and was feeling frustrated that my builds weren't working like I had hoped. I decided to go onto IRC for some procrastination, and ended up chatting with a really good friend.

My friend (who will remain unnamed), is an extremely smart fellow. One of the smartest I've ever had the pleasure of talking to. He's a fucking amazing programmer, always positive, and constantly learning new things. As we were talking about programming, I started to feel better. I started to feel excited. My frustration began to melt away, and all that was left was desire.

The desire to learn new things. The desire to build something that has never before been built. The desire to hunt down problems--and then solve them.

It was at this moment I realized something. Something which, to me, is an incredibly powerful revelation. Often times, I find myself hunting for solutions. I find myself desperately trying to figure out what I should do about X, and how to optimize Y. I find myself searching for solutions to problems, hoping to get them out of the way as quickly as possible so that I can move onto the next thing, the next chore, the next item on my todo list. It was in this moment that it all became clear to me--

I enjoy the problems. I crave them.

The more I focus on solutions, the more I treat them as a chore, as a task that needs to be finished--the more stressed and frustrated I become. It is only when I focus on the experience, the act of learning something new and hunting down problems, that I feel really, truly happy.

As programmers, we're given a unique gift: the ability to spend a majority of our time learning things and solving problems. The next time I'm feeling stressed, frustrated, or even angry--I'm going to remember that it's the process I really enjoy--that the process of learning new things is what really motivates me, and makes me love what I do so much.

Never stop hacking
Source Never Stop Hacking

Monday, February 27, 2012

Write an algorithm that prints an unordered sets of k elements chosen from a set of size n.

Example, let the size of the give set be n and set = {0, 1, 2, 3, 4} and we need to find all the subsets of size 3, then there will be a total of 10 such subsets given as:

{0, 1, 2}
{0, 1, 3}
{0, 1, 4}
{0, 2, 3}
{0, 2, 4}
{0, 3, 4}
{1, 2, 3}
{1, 2, 4}
{1, 3, 4}
{2, 3, 4}


Sunday, February 26, 2012

Fastest Super Computer is From Japan Till Today :) ,its K Computer

 Japanese supercomputer becomes world’s fastest and first to clear 10 petaflops
The fastest got faster, as the K Computer topped its own record on the twice-yearly supercomputer speed test by scoring 10.51 quadrillion calculations per second
The performance of the fastest machine on the Top500 supercomputer list hasn't stopped surging since the list began in 1993. Here, it's measured with a linear scale. 
The performance of the fastest machine on the Top500 supercomputer list hasn't stopped surging since the list began in 1993. Here, it's measured with a linear scale.
(Credit: chart by Stephen Shankland; data from Top500.org)
The rankings of the 10 fastest machines didn't change at all on today's new version of the Top500 supercomputer list, but the top dog cleared the notable performance hurdle of 10 petaflops.
"Flops" stands for floating-point operations per second and is a measure of how fast a supercomputer can perform mathematical calculations using the Linpack benchmark. The K Computer, at the Riken Advanced Institute for Computational Science in Japan, moved up from 8.16 petaflops, the score it used to reach the top of the twice-yearly supercomputer ranking last June, to 10.51 petaflops.
It reached the new top speed through being fully assembled, with all 705,024 of its Fujitsu Sparc64 processor cores running.
The Tianhe-1A in China, a former No. 1 machine at 2.57 petaflops, remains No. 2. It uses a combination of Intel central processing units and Nvidia graphical processing units. The United States is the top market for supercomputers on the list, but China is in second place, list organizers said.
Intel remains king of the heap when it comes to processor designs, supplying chips for 384 of the systems.
Among other aspects of the November 2011 list:
• Even though the top 10 machines remained the same--a first since the Top500 list began in 1993--there was still plenty of flux elsewhere on the list. The bottom of the barrel for the November list ranked No. 305 in June, and the total performance of all 500 machines rose from 58.7 petaflops to 74.2 petaflops.
• It's now required 50.9 teraflops to get on the list at all. That score beats the top system from 2004. The scores, though somewhat simplify the broad range of computing work that researchers strive to accomplish on these massive systems.
• A total of 39 systems now us graphics chips as accelerators for some computing tasks. That's the approach employed by a forthcoming Cray-built system with AMD 16-core processors and Nvidia Tesla chips slated for shipment to the National Center for Supercomputing Applications.
• IBM supplied 223 of the 500 systems and Hewlett-Packard supplied 146.
• At least 29 of the systems gulp down more than 1 megawatt of power--enough to power 10,000 100-watt light bulbs. The K Computer consumes 12.66 megawatts, but it's "one of the most efficient systems on the list," with a performance of 830 megaflops per watt, the list organizers said.
The Top500 supercomputer list shows plenty of changes over the 
years, but one constant is surging performance. This chart at the 
top shows performance in calculations per second, with a logarithmic 
scale that makes the rate of change look steady--for example by 
making the jump from 1 teraflops to 10 teraflops look as significant 
as the jump from 10 teraflops to 100 teraflops.


(Credit: Top500.org)