Skip to main content

Questions tagged [algorithms]

In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.

Filter by
Sorted by
Tagged with
1654 votes
11 answers
836k views

Which hashing algorithm is best for uniqueness and speed?

Which hashing algorithm is best for uniqueness and speed? Example (good) uses include hash dictionaries. I know there are things like SHA-256 and such, but these algorithms are designed to be secure,...
Earlz's user avatar
  • 22.9k
152 votes
13 answers
18k views

Is it just me or is this a baffling tech interview question? [closed]

Background I was just asked in a tech interview to write an algorithm to traverse an "object" (notice the quotes) where A is equal to B and B is equal to C and A is equal to C. That's it. ...
Matt Cashatt's user avatar
  • 3,315
143 votes
14 answers
14k views

Simple method for reliably detecting code in text?

GMail has this feature where it will warn you if you try to send an email that it thinks might have an attachment. Because GMail detected the string see the attached in the email, but no actual ...
75 votes
7 answers
79k views

What is a helper? Is it a design pattern? Is it an algorithm?

Maybe a little tongue-in-cheek, but as I can't find this answer anywhere through Google, so to ensure Software Engineering has the answer: What is a helper? I have seen the name being used ...
Aaron Hall's user avatar
  • 5,943
69 votes
4 answers
78k views

Which algorithms/data structures should I "recognize" and know by name? [closed]

I'd like to consider myself a fairly experienced programmer. I've been programming for over 5 years now. My weak point though is terminology. I'm self-taught, so while I know how to program, I don't ...
Earlz's user avatar
  • 22.9k
67 votes
17 answers
18k views

Is big-O really that relevant when working in industry?

In every interview I have been in, I have been quizzed on mathematical analysis of complexity, including big-O notation. How relevant is big-O analysis to development in industry? How often do you ...
64 votes
1 answer
4k views

What task did Dijkstra give volunteers, which was mentioned in his paper "The Humble Programmer"?

In Dijkstra's paper "Humble Programmer", he mentions that he gave some volunteers a problem to solve: “I have run a little programming experiment with really experienced volunteers, but something ...
user712092's user avatar
  • 1,412
62 votes
2 answers
42k views

Best practice/Patterns for two way data synchronisation

Quite often in my work the idea of 2-way data synchronisation between database systems crops up. The classic example is two slightly different CRM systems (say, Raiser's Edge and Salesforce) and the ...
codeulike's user avatar
  • 809
61 votes
3 answers
10k views

What's the difference between recursion and corecursion?

What's the difference between these? Recursion Corecursion On Wikipedia, there is little information and no clear code explaining these terms. What are some very simple examples explaining these ...
user167908's user avatar
60 votes
11 answers
11k views

Why is the use of abstractions (such as LINQ) so taboo? [closed]

I am an independent contractor and, as such, I interview 3-4 times a year for new gigs. I am in the midst of that cycle now and got turned down for an opportunity even though I felt like the ...
Matt Cashatt's user avatar
  • 3,315
59 votes
7 answers
19k views

How important is it for a programmer to know how to implement a QuickSort/MergeSort algorithm from memory? [closed]

I was reviewing my notes and stumbled across the implementation of different sorting algorithms. As I attempted to make sense of the implementation of QuickSort and MergeSort, it occurred to me that ...
John Smith's user avatar
59 votes
5 answers
55k views

get weighted random item

I have, for example, this table +-----------------+ | fruit | weight | +-----------------+ | apple | 4 | | orange | 2 | | lemon | 1 | +-----------------+ I need to return a random ...
fl00r's user avatar
  • 701
58 votes
11 answers
5k views

Should a competent programmer be able to come up with his own shortest path algorithm?

I'm suffering a crisis of confidence in my ability as a computer programmer. Yesterday I tried to come up with my own shortest path algorithm for a graph and after some hours I simply threw in the ...
Newbie Programmer's user avatar
58 votes
2 answers
79k views

How would you implement Google Search? [closed]

Supposed you were asked in an interview "How would you implement Google Search?" How would you answer such a question? There might be resources out there that explain how some pieces in Google are ...
ripper234's user avatar
  • 1,114
54 votes
9 answers
72k views

Why is it impossible to produce truly random numbers?

I was trying to solve a hobby problem that required generating a million random numbers. But I quickly realized, it is becoming difficult to make them unique. I picked up Algorithm Design Manual to ...
Vinoth Kumar C M's user avatar
53 votes
11 answers
7k views

Writing my problem solving approach on paper? [closed]

I'm a freshman Computer Science student and we just started doing some actual projects in Python. I have found I'm very efficient when I use the pen and paper method that my professor suggested in ...
ComicStix's user avatar
  • 646
52 votes
8 answers
40k views

I'm a CS student, and honestly, I don't understand Knuth's books [closed]

I stumbled upon this quote from Bill Gates: "You should definitely send me a resume if you can read the whole thing." He was talking about The Art of Programming books. So I was pretty curious and ...
Rho's user avatar
  • 673
52 votes
28 answers
119k views

What is your favorite whiteboard interview problem? [closed]

Just as the title says, what is your favorite whiteboard interview problem, and why has it proven effective for you? Junior, senior, Java, C, Javascript, PHP, SQL, pseudo-code, etc.
51 votes
4 answers
30k views

What are the data structures behind a spreadsheet?

I would like to understand how a spreadsheet (a group of named or otherwise identified cells containing values or formulas referencing other cells) is solved. I have tried looking at existing projects,...
hildred's user avatar
  • 749
49 votes
8 answers
67k views

What methods are there to avoid a stack overflow in a recursive algorithm?

Question What are the possible ways to solve a stack overflow caused by an recursive algorithm? Example I'm trying to solve Project Euler problem 14 and decided to try it with a recursive algorithm....
Lernkurve's user avatar
  • 837
48 votes
11 answers
14k views

Random number generation algorithm for human brains? [closed]

Are you aware of, or have you devised, any practical, simple-to-learn "in-head" algorithms that let humans generate (somewhat "true") random numbers? By "in-head" I mean.. preferably without any ...
Magnus Wolffelt's user avatar
48 votes
6 answers
70k views

Can an algorithm be patented? [closed]

So can an algorithm be patented? I saw this statement which made me think: Everybody would abstain from patenting the improvements of contour dot algorithm for at least several years, say up ...
Shawn Mclean's user avatar
45 votes
6 answers
61k views

Why isn't Radix Sort used more often?

It's stable and has a time complexity of O(n). It should be faster than algorithms like Quicksort and Mergesort, yet I hardly ever see it used.
Queequeg's user avatar
  • 453
44 votes
14 answers
10k views

Unit-testing of inherently random/non-deterministic algorithms

My current project, succinctly, involves the creation of "constrainably-random events". I'm basically generating a schedule of inspections. Some of them are based on strict schedule constraints; you ...
KeithS's user avatar
  • 22.2k
42 votes
4 answers
49k views

What algorithm is used by elevators to find the shortest path to travel floor orders?

I'm trying to simulate an elevator, as always I started very simple by taking only a single order at a time, then added memory to the elevator in the form of queues so that floors are traveled in the ...
Raed Tabani's user avatar
41 votes
10 answers
16k views

Difference between Algorithm and Code

A few days ago I had a conversation with a Civil Engineer with a background in Pascal and BASIC, and we talked about programming in Python. When I was talking, I used the term "code" to ...
Jalkhov's user avatar
  • 557
41 votes
12 answers
31k views

Do I need to understand algorithms and data structures to be called a programmer? [closed]

It has been six years since I have been coding. Coding into all kinds of things like ActionScript, JavaScript, Java, PHP, Ajax, XML HTML, ASP, etc. I have used arrays, maps, linked lists, sets, etc ...
sushil bharwani's user avatar
41 votes
8 answers
26k views

When to use DAG (Directed Acyclic Graph) in programming?

I recently found a framework named ecto. In this framework, a basic component named "plasm", which is the ecto Directed Acyclic Graph.In ecto, plasm can be operated by ecto scheduler. I am ...
Po-Jen Lai's user avatar
41 votes
2 answers
18k views

What is O(...) and how do I calculate it?

Help! I have a question where I need to analyze the Big-O of an algorithm or some code. I am unsure exactly what Big-O is or how it relates to Big-Theta or other means of analyzing an algorithm's ...
40 votes
28 answers
4k views

Which are the significant algorithms for humankind in past decades? [closed]

Which world most important algorithms have contributed most to humankind in past decades? I thought this is a good general knowledge for a developer to know about. Update: If possible, please keep ...
40 votes
12 answers
60k views

How to check if 4 points form a square?

Assume I have 4 points (they are 2-dimension), which are different from each other, and I want to know whether they form a square. How to do it? (let the process be as simple as possible.)
MarshalSHI's user avatar
39 votes
20 answers
7k views

Do real-world algorithms that greatly outperform in the class below exist? [closed]

Last night I was discussing with another programmer that even though something may be O(1), an operation which is O(n) may outperform it if there are is a large constant in the O(1) algorithm. He ...
39 votes
5 answers
247k views

Why is mergesort O(log n)?

Mergesort is a divide and conquer algorithm and is O(log n) because the input is repeatedly halved. But shouldn't it be O(n) because even though the input is halved each loop, each input item needs to ...
perseverance's user avatar
39 votes
2 answers
84k views

General way to convert a loop (while/for) to recursion or from a recursion to a loop?

This problem is mainly focusing on the algorithm, maybe something abstract and more academic. The example is offering a thought, I wanna a generic way, so example is only used as to make us more ...
xqMogvKW's user avatar
  • 543
38 votes
10 answers
83k views

How do I learn algorithms and data structures? [closed]

This is in continuation to my previous question where I asked is it necessary to learn algorithms and data structures. I feel yes it is. Now I work in an environment where I won't ever get the chance ...
sushil bharwani's user avatar
37 votes
9 answers
9k views

Is the algorithm more important than the programming language?

During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of ...
superspacemarines's user avatar
37 votes
7 answers
48k views

What algorithm would you best use for string similarity?

I am designing a plugin to uniquely identify content on various web pages, based on addresses. So I may have one address which looks like: 1 someawesome street, anytown, F100 211 later I may find ...
Squiggs.'s user avatar
  • 511
36 votes
7 answers
135k views

How to quickly search through a very large list of strings / records on a database

I have the following problem: I have a database containing more than 2 million records. Each record has a string field X and I want to display a list of records for which field X contains a certain ...
Giorgio's user avatar
  • 19.7k
36 votes
4 answers
59k views

Prerequisite math skill for Introduction to Algorithms (CLRS) book [closed]

I already have knowledge about basic algorithms. Now I plan to study more advance algorithms and I decide to go with Introduction to Algorithms. I'm not sure, do I need to refresh my math's skill ...
Anonymous's user avatar
  • 2,049
35 votes
4 answers
49k views

What does it mean to say an algorithm is Sound and Complete?

I heard different interpretations of sound and complete. I understand that completeness means finding a solution if there is one. What does it mean to say an algorithm is sound. What does it mean ...
mutelogan's user avatar
  • 453
34 votes
5 answers
16k views

Divide and Conquer algorithms – Why not split in more parts than two?

In divide and conquer algorithms such as quicksort and mergesort, the input is usually (at least in introductory texts) split in two, and the two smaller data sets are then dealt with recursively. It ...
beta's user avatar
  • 1,012
34 votes
9 answers
7k views

Is there an encyclopedia of algorithms? [closed]

Is there an encyclopedia of algorithms similar in style to the Handbook of Mathematics? It seems useful to have large numbers of them available in one place. I know the Art of Computer Programming is ...
user avatar
34 votes
1 answer
39k views

I know JavaScript really well, but i bomb coding interviews [closed]

So I'm currently on a hunt for a new position as a Front-End Developer. I know JavaScript very well and can wax poetically about Closures, Currying, Prototypal Inheritance, Design Patterns, App ...
Mike Fisher's user avatar
34 votes
3 answers
47k views

Which string search algorithm is actually the fastest?

I have been stuck for some time on which is the fastest string search algorithm, heard many opinions, but in the end I'm not sure. I have heard some people saying that the fastest algorithm is Boyer-...
vandamon taigi's user avatar
34 votes
6 answers
38k views

How do you identify "edge" cases on algorithms?

Basically how do you find out which could be your worst or best case and any other "edge" cases you might have BEFORE having them and so, how do you prepare your code for them?
Luis Armando's user avatar
34 votes
3 answers
7k views

How will quantum computing change programming? [closed]

How is programming a quantum algorithm different? What would a C like language look like if it was designed for qubits? Would types change?
MaiaVictor's user avatar
  • 5,830
33 votes
5 answers
7k views

Why is deletion usually much harder to implement than insertion in many data structures?

Can you think of any specific reason why deletion is usually significantly harder to implement than insertion for many (most?) data structures? Quick example: linked lists. Insertion is trivial, but ...
Leo Brito's user avatar
  • 421
33 votes
5 answers
90k views

Determining if an Algorithm is O (log n)

I'm refreshing my CS Theory, and I want to know how to identify that an algorithm O (log n) complexity. Specifically, is there an easy way to identify it? I know with O(n), you usually have a single ...
Atif's user avatar
  • 915
33 votes
6 answers
6k views

I'd like to write an "ultimate shuffle" algorithm to sort my mp3 collection

I'm looking for pseudocode suggestions for sorting my mp3 files in a way that avoids title and artist repetition. I listen to crooners - Frank Sinatra, Tony Bennett, Ella Fitzgerald etc. singing old ...
DeveloperDan's user avatar
32 votes
8 answers
8k views

What is beautiful code? [closed]

I often read that developers must write beautiful code, but for a beginner as I am it remains obscure of what is beautiful code and how do you recognize it? The corollary question is: How to write ...
torr's user avatar
  • 493

1
2 3 4 5
45