TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How much of your time is spent on classical algorithmic problems?

75 pointsby petenixeyabout 12 years ago
Almost none of the time my team and I spend writing code is spent focussed on solving "classical algorithmic problems" - search / sort / comparison etc. It is all writing clear logic.<p>Our efforts are all around writing unambiguous code which does what it says on the tin (and says on the tin what it does). Code which other programmers can easily work with and code which interacts defensively with the rest of the system and only affects that which its told to.<p>I'm interested in how representative that is. How many of you have programming jobs which are genuinely algorithmically driven?<p>What fraction of your time is spent on "classical algorithmic problems"?

42 comments

ispiveyabout 12 years ago
5% - but it's the very important 5% where I'm optimizing existing code. The "classical algorithmic problems" you reference are almost all optimization problems; there's a naive search/sort/comparison, but how can you do it better?<p>The algorithmic problems I deal with are things like:<p>- Why the hell is this API call running O(n*m) SQL queries? Can I tweak my logic and use of the ORM get it down to O(1)? The ORM doesn't let you forget about the underlying algorithms, it just makes it easy for you to shoot yourself in the foot if you don't understand them.<p>- Why is my single SQL query so slow? DB optimization is very much a "classic algorithmic problem", in that you need to understand the operations the DB performs and optimization is reducing its search space / # of operations.<p>- We're using too many jQuery pseudoselectors like ":hidden" and they're causing framerate drop on a particular page; can we use some dynamic programming / memoization techniques to dramatically reduce use of pseudoselectors?<p>- We need to figure out what font size will allow a piece of text to fit within a container on a PDF, but the bounds of the font (space consumed) don't scale perfectly linearly with the font's point-size. Finding the best fit is a search problem!<p>- And that's not even getting into infrastructure scaling issues! Do you know why Vertica might be a better fit for your data set and end user needs than Hadoop? If you understand the difference between an ETL approach and a MapReduce approach to data analysis, you're thinking about algorithms!<p>I spend a meaningful amount of time on "classical algorithmic problems" while doing frontend and backend web development, even if I've never had to re-implement mergesort.
评论 #5386227 未加载
chipsyabout 12 years ago
In the last two months I started deliberately increasing the amount of coding time that is classical algorithm time. Not by working through books and problem sets, but by redefining day-to-day engineering problems that have an easy way out - bash away at it with "industry best practices" and whatever comes to mind, until it doesn't break - into formalized versions that become first data-driven, and then a DSL, so that each "100 lines" solution becomes an effective 1-liner, in the fashion suggested by VPRI's work on new languages. This motivates studying at the algorithmic level and researching PL theory to synthesize that ideal solution.<p>As a result of this, I am writing very, very few lines of code, in a start-and-stop fashion. I believe it is over 70% algorithmic at this point. The reliance on deep insight is leading me to actively avoid the typical coder's flow state and spend a lot more time on "sit and think" instead. If I hit flow for a long stretch something is wrong.<p>And, certainly, I would have more "shipping code" at the moment without going this route. But it's still ultimately guided by problems I'm familiar with from doing them the "best practices" way - and each time I make progress, I think to myself "why did I not do it this way before?" (It helps that I have a lot of freedom, working alone.)<p>Also, it's quite scary doing things this way. The high uncertainty about what the solution is, even knowing the problems well going in, is absolutely terrifying.
评论 #5386498 未加载
yen223about 12 years ago
My current job is to write software for those huge assembly-line robots you see in factories.<p>I entered this field (taking a significant pay cut) thinking that maybe I could put some of my algorithmic knowledge to use. Turns out 90% of my job is rote logic - rewriting process flows and the like. Nothing too smart. Really boring tedious stuff.<p>The 'cleverest' task I did was implementing a Kalman filter to smooth over some encoder readings. That was the most fun I had in a while.
mindcrimeabout 12 years ago
Averaged over my entire career, about 0%.<p>In isolation, I've had a few brief stretches where I spent some time doing low level algorithmic stuff. I wrote some sorting/searching stuff by hand once, because I was working on external files, not doing it in memory. There was, at the time, either no library that did exactly what I was trying to do, or I didn't know about it.<p>More recently I've done some graph theory based stuff (Floyd-Warshall algorithm for "all pairs - shortest paths"), as I was experimenting with some social network analysis stuff that I wanted to do. But even that probably won't go anywhere. As I explore the capabilities of existing off-the-shelf graph database products, I'm finding most - if not all - of what I need.. At one point I thought I might need to roll my own, but it's a burgeoning field and there are more and more OSS options popping up all the time.
karamazovabout 12 years ago
The most useful part of studying algorithms is knowing what problems they solve. If you've never heard of sorting algorithms, you'll waste time implementing a bad solution.<p>(Everyone knows about sorting algorithms, but many algorithms are not well-known. They're almost never needed, but when they're useful, they're <i>really</i> useful.)
评论 #5386103 未加载
gsoltisabout 12 years ago
Leading up to my current job, virtually none. However, at my current job (Firebase), it now makes up a significant percentage of what I do. The way I've described it to friends is: "You know how most companies ask you tree traversal/sorting/search questions in an interview, then when you show up for work the first day, your job turns out to be 'add this button to this web form'? We actually work on those algorithm problems." It helps that we are an infrastructure company and that our user interface is an API.<p>If this is something you're looking for, my recommendation is to look at either large companies that have large infrastructure needs (Google, Facebook, Twitter, Amazon, LinkedIn, etc.) or small infrastructure-related startups, depending on your preferred working environment. If the hard parts of your job are offloaded to the database/language runtime/middleware, look for companies that work on databases, language runtimes or middleware. And in the interview, ask them for examples of hard problems that they have solved.<p>Also, I have absolutely nothing against the companies that don't do this kind of work. In fact, Firebase exists so others don't have to do this kind of work. This is just an observation that occasionally, the skillset tested in these interviews is not in line with the responsibilities a successful candidate will end up having, so make sure you ask.
yankoffabout 12 years ago
No one spends time on job solving "classical algorithmic problems", they are solved already ;) Unless you work in research and looking for more efficient solutions.<p>But understanding algorithms brings you to a new level and opens a wide scope of other problems you can solve by applying this knowledge.<p>If you are not using knowledge about algorithms in your programming job it doesn't mean such knowledge is useless. Maybe that means your problems are not hard enough for this knowledge to be applied.
obsurveyabout 12 years ago
I dont spend a lot of time on these kind of problems. But the times I do, it's an exillerating experience. Knowing the theory of big O notation and time complexety of algorithms has allowed me to build amazing things, I've even used for GUI and JavaScript in the browser.<p>The most exciting stuff has been implementing things where I have been unsure if what I was trying to would be possible at all in a browser. The feeling you then get when it actually works, and you know that you've pushed a limit that you have never seen anyone do in the browser before, can' be beaten.<p>If you push yourself to the limit, think outside the box etc. You are going to need knowledge of algorithms.
pkalerabout 12 years ago
I did game development in a previous lifetime. Probably half my day was implementing algorithms and thinking about the correct data structure for a problem.<p>I spend less time these days implementing algorithms. However, you need a good understanding of algorithms to decide between using ActiveRecord or a service layer. You need a good understanding of algorithms to pick between a relational DB, a key-value store, or a document store.<p>Maybe you aren't picking difficult enough problems if you don't have to think about this kind of stuff.
评论 #5386121 未加载
barredoabout 12 years ago
Pretty much 0%. Mostly because of libraries already solving the problem for me.
freeworkabout 12 years ago
Just about every project I've worked on contained one "chunk" of the project that was an algorithm, while the remaining 95% of the functionality was achieved by implemented by Postgres, Apache, Django, etc. This is why I (and other people that work this way) am able to get things done so fast. As I've gotten better at launching projects, my algorithm writing skills have not gotten much better, but my "open source understanding and researching" skills have multiplied hundred-fold.
atiripabout 12 years ago
In 25 years of coding i needed to sort something about three times (not counting sql) in total. So when somebody asks me to write some sorter as like in job interview, i'll probably fail...
评论 #5386138 未加载
femto113about 12 years ago
My experience over about 20 years of writing software professionally is that I need to tackle one algorithmic problem a year. Probably amounts to a day or two of work, and usually it is a refinement or adaptation of an existing algorithm, rather than totally new code. Call it less than 1% of my time.
rcj_about 12 years ago
I work on a large commercial database mainly on optimizing joins and a lot of the work that has to be done is algorithmic.<p>Library functions normally are to generic and therefor we end up implementing lots of different variations of fast and memory efficient searching, sorting, graph optimizing, etc.
shepikabout 12 years ago
At my last job, the coolest project i did was to create an image duplicate detection system (so that it would tell, given an image, that the image is new, or it's a version of what was uploaded before, or the image contains fragments of some known image, etc). It used opencv for feature points detection, so i had to maintain an index to search for those points (there were around 7M images, and load was up to 50 rps). I came up with a rather clever algorithm, which as i later discovered (thanks, wikipedia) is a kind of implicid k-d tree.<p>That task was the most algorithm-intense task I ever had, and that algorithmical part took 20% of the time. 80% was straight coding, glueing things together, testing and putting all that in production system.
adnamabout 12 years ago
100% of my time is spent on cache invalidation and naming things.
评论 #5386543 未加载
nayefcabout 12 years ago
A lot of CS people complain about that. Especially in college and those who are just joining the work-force.<p>The classical problems were problems back in the day. There is no point in re-implementing them nowadays. But it is very important to know how they are implemented, and the logic behind them.<p>Why?<p>Because we are tackling much, much harder problems. Fields like data analysis, NLP, machine learning are yet to reach their potential. If we cannot master the easy classical problems, how are we expected to tackle the bigger fields? By master, I mean understand and not re-implement/re-invent the wheel every single time.
jes5199about 12 years ago
Conversations like this make me wonder if there's some disruption waiting to happen. My understanding is that from a theoretical perspective software should be reducible to a combination of algorithms and business rules, but we seem to spend our time on something else. Is there some meta-solution to the rote stuff that we just haven't noticed? Doesn't it seem like the most tedious tasks - Extract-Transform-Load, for example - could get automated away? Is there something preventing that from happening? What is it?
评论 #5386109 未加载
vbtempabout 12 years ago
First, in education, sorting algorithms are used as prime examples of well-defined problems with well studied solution.. they are not taught because every student is expected to work on sorting problems for the rest of their life. It is usually the first part of a course on the <i>design and analysis</i> of algorithms.<p>As for my answer: Most of my time is definitely in the usual grind of software engineering: designing, testing, maintaining, etc... However, at my lab we have been engaged in a number of projects involving network protocol engineering and the development of formal code/model verification tools. As a first step toward the development of systems like this, you must be able to construct a precise formal model, and then show that in such a model, then <i>so-and-so</i> properties hold true (including memory usage, upper/lower bounds, stability [in cases of routing algorithms], intractability of certain values [in the case of secure protocols], etc...). If you are developing software for usual line-of-business type applications, you'll do much less basic algorithm development than if you are, say, developing the routing software for a wireless ad-hoc mesh network.
jplurabout 12 years ago
When I was writing games, There was a lot of re-implementing nearest neighbor searches in python. Now that I'm working on a Saas web app, it's 90% UI busy work.
rm999about 12 years ago
A lot. I work with large amounts of data so relatively minor changes in algorithmic complexity can determine if a method is practical or not.<p>Recently I found a great new dataset but it didn't work well with our database - the naive method of doing lookups was at least 10x too slow to be practical. Studying the underlying algorithms of our database helped me find a solution that took up 10x as much space but was 100x faster.
alexdowadabout 12 years ago
How much of my time is spent on algorithmic problems? Not as nearly as much as I would like!<p>I once wanted to stay away from web development because I knew a lot of it would be boring stuff like learning to work around browser bugs (which change with every generation of browsers, rendering your previous learning useless), rather than the mathematical/algorithmic mind puzzles which I really enjoy. I gave in because there's so much work available (and I found some clients who pay really well).<p>I think having experience working on both low-level embedded software and algorithmically intensive software (natural language processing, etc) gives me some advantage as a web developer. When the need to devise an algorithm or do something else hard-core comes up (which it does from time to time), I take it on with pleasure rather than shrinking back in fear. Or if I find a bug in my platform, I can drop down into the C source, figure it out, and submit a fix to the maintainers, rather than waiting for someone else to help.
norswapabout 12 years ago
I'm writing my master thesis in computer science, so quite a bit (it's a lisp-like macro system for Java). But then it's not a real job.
评论 #5385910 未加载
dereferencedabout 12 years ago
0%, these are solved problems that you can easily use a library for.
评论 #5386226 未加载
评论 #5386558 未加载
sophaclesabout 12 years ago
Directly writing? Almost none. Indirectly? A lot.<p>Queueing theory turns out to be a big part of the system I'm working on, as do graph traversals. I'm not proving anything new, but I am certainly transforming known solutions to be present implicitly in the way data flows through the device (a network gateway).<p>I've also done work on numerical solutions, implementing various formulae the researchers have come up with, and dealing with various optimization (in the mathematical sense) problems.<p>Lately there has been a lot of talk on "new classic" things, applying machine learning algorithms to data sets, and finding relevant classifiers and adjustments to the ML algorithms that provide better results. Hopefully I'll get into implementing and doing real work on that soon.<p>I do work in academia though, in a department focused on implementing research in ways that industry can actually use it.
lutormabout 12 years ago
Zero. It's all refactoring ugly, old, unmaintainable and unexpandable code to remove all those characteristics. It's an exercise in "engineering" that involves zero algorithmic work apart from the occasional replacing of a linear scan through an array with some more efficient data structure.
smillikenabout 12 years ago
At Mixrank we process a lot of data, so a lot of our time goes into designing efficient data systems. Algorithmic complexity really matters, and small tweaks can result in large improvements.<p>If you'd like to spend more time designing algorithms, then working on big data systems is a sure bet.
pjungwirabout 12 years ago
Only a few times, but when I needed to solve something like that, it was really important. A few examples: processing a giant, highly-interconnected graph that was too big for memory, so figuring out how to split it up into parts small enough to handle; learning Bayesian statistics to make strong inferences from millions of weakly-indicating data points; making inferences about the nature of edges in a graph with tens of millions of nodes.
pidgeabout 12 years ago
~50% - I'm in "big data" right now, partly because I get to worry about the algorithmic complexity of things all the time. As the scale of a task goes up and the feasibility of just throwing more machines at it decreases, you can suddenly justify spending a lot of programmer time on interesting things.
dhruvbirdabout 12 years ago
Your job (much like your life) is what you make of it. If you seek out problems that are unsolved &#38; require solutions that involve thinking up a clean/simple solution, you'll find yourself spending much more time solving algorithmic problems than just writing/copying rote logic.
alok-gabout 12 years ago
Zero percent. On the other hand, for as much as 50% of the problems I solve, it needs understanding the nature of the problem and its solution <i>in terms of the classical algorithms</i>, which then are by definition already available somewhere at least as pseudo-code.
orangethirtyabout 12 years ago
Professionally: 0<p>My own project: At least once a week.
ams6110about 12 years ago
Zero. I have not implemented any "classical algorithmic" code since college. Nobody writes search/sort/comparison code, or even implements data structure code such as balanced trees, skip lists, etc. because your framework or libraries provide those.
eLobatoabout 12 years ago
About 1/4th I'd say, another 1/3rd is thinking about architectural decisions (or restructuring bits that are broken) and the rest is mundane work including meetings. I work on infrastructure stuff
acgourleyabout 12 years ago
At BitGym we solve vision and sensor problems, and it has to be efficient because the result will run on an iPad. So yes, we spend a fair amount of time on it. Maybe 20% of our heads down time.
yesimahumanabout 12 years ago
I think it depends. I've been building GUI builders and there is a ton of tree manipulation and traversal. Beyond that though most operations are already available in the standard libs.
zapharabout 12 years ago
roughly 50% of my current duties involve parsing and transforming an AST. As well as performing static analysis.<p>All of it is to support web developers by giving them tools to handle html and css well. But this is not the usual case for my career much of it has been exactly what you describe instead.<p>I'm just glad that I knew enough of this stuff to be able to tackle these problems when there was a need to.
djbenderabout 12 years ago
Zero.
manojiabout 12 years ago
I would say less than 1 % . Most of the time its picking the best from an already existing solution to suit the need.
hergeabout 12 years ago
Not much of my time but a lot of my value.
lognabout 12 years ago
Take a job involving map-reduce. Search/sort/comparison in about all you'll do.
graycatabout 12 years ago
First, let's look at what is an 'algorithm': The examples that got famous were the sorting and searching algorithms in Knuth's TACP. So, people quickly coded up bubble sort which has running time proportional to n^2 for sorting n items, and in practice n^2 grew too darned fast. So, people were eager for Shell sort, quick sort, heap sort, merge sort, etc. which all had running times proportional or nearly so to (n)log(n) in average case or even worst case. Then there was radix sort which could beat (n)log(n). So, people got excited about 'algorithms'.<p>So, what did we get? We wanted to sort (or work with trees, etc.). We knew how to do that manually. We could write the code, but our first cut code tended to be too slow. Heap sort, etc. are really clever. Stare at the code (typically are doing an informal proof of correctness by mathematical induction based on the definition of the natural numbers) and can confirm that it sorts, and with analysis as in Knuth can confirm the running time, e.g., worst case (n)log(n). So, net, there's not much question about what it does, that it actually sorts, and how fast it is. Great -- for sorting and searching.<p>Do I ever do such things? Actually, early in my project I wrote a bunch of heap sort routines, polymorphic, etc. I wanted to write some 'stable' versions but didn't get around to it this time. Also can write versions that sort by 'surrogate', that is, move only pointers and not the data. For some of the details of how Microsoft's Visual Basic .NET works with strings and instances of objects, there is some question about the value of sorting by surrogate! Then with the results, can have an O(n) routine that will take the 'permutation' of the pointers and move the data. Etc. I didn't write everything I could think of in sorting, but some of what I wrote is good and used in my code. And I got some polymorphic code that is only 2-3 times slower than a non-polymorphic version. So, yes, I did some work in algorithms, even some quite old ones.<p>Next I needed a 'priority queue' so borrowed the heap data structure from heap sort and, presto, got a nice priority queue routine. It's in my production code.<p>So, yes, I worked in algorithms. And for my project, that work is crucial in the sense that without it my software wouldn't work or, if I had used code I knew about from others, not work as well.<p>But now there is another issue in computing and software: There are old examples; since they are more explicit, let's start with those. For a positive integer n, suppose A is an n x n matrix of real numbers and we seek x, n x 1, to solve Ax = b where b is also real numbers and n x 1.<p>Now we need an 'algorithm'? Not really! An 'algorithm' as in sorting is not enough! Instead we need some mathematics prior to any sense of an 'algorithm'! Usually the mathematics we use is Gauss elimination, and a good chunk of a course in linear algebra makes clear just what that is doing and why it works.<p>Here's much of the difference: Looking at a description of code for, say, heap sort, it's easy to see that it sorts. Looking at a description of code for Gauss elimination, it's totally obscure why it solves Ax = b, that Ax = b has none, one, or infinitely many solutions, and if infinitely many how to characterize them. Instead of just the code, just the 'algorithm' for Gauss elimination, we need the math from, say, linear algebra. Similarly for a numerical solution to an initial value problem for an ordinary differential equation.<p>Then more generally, for some software, it may be that some math, new or old, is crucial for knowing what the software will do, much as the linear algebra was crucial for knowing what some Gauss elimination code will do. E.g., in Gauss elimination, turns out have some choice about the 'pivot' elements. Well, typically want to select the pivot that is largest in absolute value. Why? Some math! Next, do a lot of 'inner product' arithmetic. Then want to accumulate inner products in double precision. Next, when get a solution, want to do a little more work with double precision and do some 'iterative improvement'. And would like to know the 'condition number' to get some error bounds -- all in the code and all needing some math to know why it works.<p>So, net, for many good solutions to real problems, an 'algorithm' alone has not enough to recommend it and need some prior logical support from, say, some applied math. So, in code, algorithms are not everything that is important; in such cases, an algorithm alone does not have enough to recommend it.<p>In my project, some original math was crucial, and got converted into code. But to have any confidence in what the code will do, can't just stare at the code and, instead, need the math. That is, just an algorithm was not enough.<p>So, in my project there has been work in both algorithms and applied math. That work is crucial in that without it the project would flop or nearly so.<p>But, right, also is working through a lot of routine logic. E.g., the code for yesterday was to be clear at the start of the code for a Web page just where the user came from. There were three cases, the first two legal and the third a symptom of an attempt at hacking. So, I needed to work out the logic. For that I needed some answers to some of how Microsoft's ASP.NET worked. E.g., if transfer to page B from page A via in page A code server.transfer("B"), then in the code of page B, what is the value of Request.UrlReferrer? Use the TIFO method -- try it and find out. So, right, such 'logic' is routine but takes time.<p>Then where most of the time went! Right, to none of the above! Most of the time, likely over 80%, went, may I have the envelope, please? Yes, here it is (drum roll): The nominees for where most of the time went are (1) working through poorly written technical documentation, (2) software installation, (3) software configuration, (4) data backup and recovery, especially for the boot partition, (5) system security, e.g., fighting viruses, and (6) fighting bugs. And the winner is, (1) working through poorly written technical documentation! Heck, reading Knuth, Ullman, Sedgewick, etc. was fast, fun, and easy, but reading the documentation on the 'platform' was painful and wasteful.<p>So, the crucial stuff unique to the project took the least time. The rest of the work unique to the project took much more time but still was fast, fun, and easy. Work on (1)-(6) essentially independent of the project took maybe 80% of the time.<p>In particular, the most valuable work, that gives the project some potential, took the least time; routine work still unique to the project took much more time but still was fast; nearly all the time went for work not unique to the project.<p>Why? There is good/bad news: Some of the good news is that there is now so much infrastructure software that write less of own code and use code written by others. The bad news is that when using code written by others, also need to use their documentation, and for the industry so far writing good documentation is, in practice, essentially too difficult. E.g., I had to use just the TIFO method to determine what would be the value of Request.UrlReferrer. As far as I could tell from my 4000+ Web pages of documentation, the only way to know was the TIFO method. Then, of course, in my code I did put some documentation. I wish I didn't have to write my own documentation of the tools I am using from others.<p>Net, what's crucial and unique to a project may not take the most time. That is, the work that takes the most time may not be the most important work. And, then, can't measure importance to a project of some work by the time the work took.
评论 #5386207 未加载