# Tagged Questions

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.

1k views

### Does it make sense to ask, “What is the difference between Design Pattern and Algorithm?”

From Wikipedia: In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. In software ...
377 views

### Most efficient way of finding entities in a grid?

I'm working on my first game; a tower defense. So far It's coming along nicely. The only issue I am having (so far) is I can't figure out a way to effciently discover if an entity has entered a towers ...
355 views

### What are some common algorithm optimization opportunities - mathematical or otherwise

What are some common algorithmic optimization opportunities that everyone should be aware of? I have recently be revising/reviewing some code from an application, and noticed that it appeared to be ...
927 views

### Simplified knapsack in PHP

I have two instances where I'd like to display information in a "justified" alignment - but I don't care if the values are switched in order. One example being displaying the usernames of people ...
162 views

### Clarification of pseudo random number generator

I am asked to create a pseudo-random number generator using the following algorithm: The generator will generate every integer from 1 to N-1 exactly once The algorithm for N=2^n ...
7k views

### AVL Trees and the REAL world

in school we are taught how we can balance an AVL tree upon an insertion or deleting. How is this type of knowledge actually going to be useful in the real world? Can someone give an example on when ...
152 views

### Find next occurence in a Tree

Have a tree of variable depth, and width. What is the best algorithm to find the next occurence of the node in that tree. Next = Search to the right side of the tree ( as in breadth first search ) ...
2k views

### What is the best way to keep track of the median?

I read a question, and I'm looking for input on how to solve it: Numbers are randomly generated and stored into an (expanding) array, How would you keep track of the median? There are two data ...
3k views

### Parsing scripts that use curly braces

To get an idea of what I'm doing, I am writing a python parser that will parse directx .x text files. The problem I have deals with how the files are formatted. Although I'm writing it in python, I'm ...
8k 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 ...
343 views

### Why does the iterative version take longer?

I was looking over at http://programming.lispdream.com/blog/2011/06/recursion-vs-iteration/ and I saw that on his implementation of the recursive and iterative implementations of the factorial ...
7k views

### Can we technically un-blur images?

Since there is an algorithm to blur images, so that part of it cannot be recognised, can we reverse the algorithm and unblur part of than image? Is there a program that already does that, is that ...
260 views

### Useful Pre-requisites for Operating Systems course?

How important is knowledge of data structures and algorithms for an Operating Systems and Systems Programming course where we will be required to design and implement a kernel of a real-time operating ...
2k views

### Search for a sub-string in a given array of strings

I have an array of n strings. I want to select all the elements of the array that starts with the given string. Sorry if that is not clear. I'll give an example. input = "as" array = ["abas", "aras",...
4k views

### What algorithms would be useful for designing a stock market simulator?

We are in the process of building a stock market simulation game. The frontend design is ready but we are clueless about how exactly the back-end algorithms are to be designed. What algorithms should ...
935 views

### Floyd's algorithm [closed]

Is it possible(expected) for an individual to figure out(having never seen it before) the algorithm if asked at an interview? What other problems have equally interesting solutions? Edit: Due to the ...
177 views

### Repeat digit problem

There are numbers 1 to N present in a list, and an additional number that has been included by mistake. So, in total there are N+1 numbers. Assume that the largest integer that the language can handle ...
278 views

### Process each row against each other, how much would it cost?

If I have n rows in a database, and I want to compare every row against each other, how many loops (or processes) would I need to do. Is it n2? (so if I have 30,000 rows then it would be 900,000,000) ...
2k views

### Is it ok to not fully understand RB Trees? [closed]

So I just learned red black trees at Cormen and wow! Typically I like to understand all algorithms and data structures to the point I can rebuild them from scratch without having to cheat looking at ...
979 views

### Coding site with test harness for basic data structures like linked list,graph,strings etc [closed]

I just took an Amazon online test and I messed it up badly. I am out of practice and have low confidence in writing code. Are there any coding sites with test harnesses for basic data structures and ...
7k views

### Is Bubble Sort the slowest sorting algorithm? [closed]

Is bubble sort the least Big-O efficient? If the answer is no, then what is the least efficient sorting algorithm?
2k views

### What do you consider to be the essential design patterns? And do you use them? [closed]

It seems to me that programmers have an increasingly uphill task of staying up-to-date. In my efforts to improve my programming ability, I am in search of the essential design patterns that are ...
716 views

### Subset sum problem is NP-complete?

If I know correctly, subset sum problem is NP-complete. Here you have an array of n integers and you are given a target sum t, you have to return the numbers from the array which can sum up to the ...
513 views

### How do we know if a problem is hardest in NP

I read that the definition of NP-complete is : These are the hardest problems in NP. Such a problem is NP-hard and in NP How do we know if a problem is hardest in NP, and no harder problem ...
279 views

### NP hard/complete

I have never been very clear on this concept. Please help: At the end of the day, we should want to identify useful problems for which we don't have polynomial solution so far and only have ...
3k views

### Which sorting algorithms have a different worst case complexity than their average case? [closed]

I'v been working on sorting for a while now but I can't figure these two questions apart, I'm kind of getting mixed up somewhere ... Somebody help a) Which sorting algorithms have a different worst ...
47k views

### Difference between a pseudo code and algorithm?

Technically, Is there a difference between these two words or can we use them interchangeably? Both of them more or less describe the logical sequence of steps that follow in solving a problem. ain't ...
12k 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.
3k views

### Is Google's Go a type-safe language?

this page http://golang.org/doc/go_faq.html writes: although Go has static types the language attempts to make types feel lighter weight than in typical OO languages So my question is ...
1k views

### Why do most languages provide a min-heap instead of a max-heap implementation?

I just noticed something and I wonder if there is any reason for that. Except for C++ (std::priority_queue is a max heap), I don't know any other language that offers a max heap. Python's heapq ...
2k views

### algorithm from scientific paper [closed]

In my application I want to use a mixture of several algorithms described in some recently published scientific papers. But I have some legal questions. Q1 If an algorithm was published in a ...
6k views

### Generating every combination of a 32 character alpha numeric string?

Is it possible to generate every possible combination of a 32 character alpha numeric string? If so, how long would it take on today's fast computers? My lecturer at university said it's impossible, ...
730 views

### All possible solutions to equation, where operators are arbitrary?

Given something like this: 1 5 3 4 = 18 I need to determine (using an algorithm) if there is a combination of operators and brackets that bring me to 18. Only "+" and "*" and "(" and ")" are allowed....
2k views

### A better way of doing Regex? [duplicate]

I really dislike regular expressions, each time I come back to it I seem to have to relearn it. It's also incredibly hard to maintain, modify and at a glance understand what it is doing. Has anyone ...
668 views

### Why would I care about the asymptotic growth of the lower bound of the worst case time/space?

In mathematics, there are notations for asymptotic lower bounds, upper bounds, and tight (within-a-constant-factor) bounds. When describing the growth of functions in general, it makes sense that all ...
1k views

### Ideal data structure for storing map data?

I was asked this in an interview test. I did okay on the test but didn't know enough to answer this question. I am curious to know what data structures I can use to query the data quickly. Basically ...
6k 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?
3k views

### NP complete or NP hard problems in real life

Does anybody have real life examples where they regularly solve NP complete or NP hard problems (by heuristics, or chasing a suboptimal solution or whatever) in their job? I know they occur in ...
7k views

### Most Efficient Cache Replacement Algorithm [closed]

Wikipedia lists 11 cache replacement algorithms. Assuming I know almost nothing about the application I'm going to develop, what should I use as a "default" cache replacement algorithm? If I recall ...
1k views

### What language does Introduction to Algorithms by Cormen use?

What language, if any, is used in this book? My school is currently using a terrible book for the algorithms course that I have to take next year and I'd like to convince the department head that ...
12k views

### What is an algorithm?

What exactly is an algorithm, as in what does Algorithm mean? The little I understand the word, is that it's not specific to a particular language, or design pattern, rather it's one the most basic ...
837 views

### Is a genetic algorithm a correct approach to this problem?

I am trying to calculate a set of items that produce the highest damage output in a video game. There are about 50 different items, of which you can choose 6. There are all sorts of conditions that ...
5k views

### TEA algorithm constant 0x9e3779b9 said to be derived from golden ratio, but the golden number is 1.618?

I'm trying to understand a constant 0x9e3779b9. What kind of data is this? It's not binary, not decimal, what is this? It's a constant used on the TEA algorithm. It says it's derived from the golden ...
286 views

### Starter BOOKS On Data Analytics and Algorithms in Computer Science

Am Programmer cum Co-Founder of Start-up,Am a computer Science Graduate though am not good at Algorithms,I want to learn and sharp that side.Please suggest me some nice books for starters and Advance ...
389 views

### How to organize a MST when one node disappear?

I'm doing my research and stuck with a question: I am having a minimum spanning tree (prim algorithm), now one node in my tree gets deleted, I wonder if there is a way i can re-organize my tree such ...
508 views

### Gossip protocol in a Ring topology

I am implementing a gossip based membership detection mechanism. Lets say we have a ring topology, i.e. node1 only knows about the 2 nodes (node4 and node2) around it. node1 ...
262 views

### Improve address lookup usability and accuracy?

In my application,I have a feature like this: The user wants to add a new address to the database. Before adding the address, he needs to perform a search(using input parameters like country,city,...
2k views

### Database fuzzy search concept

I thought about this, and have been trying to come up with solutions on how to fuzzy search a database, if for say example a user types a spelling mistake. Any glaring problems with the logic behind ...