iterative

Iterative version of Python's deepcopy

Is there an existing implementation of an iterative version of deepcopy for Python 2.5.2? The deepcopy method available from the copy module is recursive and fails on large trees. I am not in a position where we can safely increase the stack limit at runtime. EDIT I did track this down: http://code.activestate.com/recipes/302535/ I h...

Is it possible to speed up a recursive file scan in PHP?

I've been trying to replicate Gnu Find ("find .") in PHP, but it seems impossible to get even close to its speed. The PHP implementations use at least twice the time of Find. Are there faster ways of doing this with PHP? EDIT: I added a code example using the SPL implementation -- its performance is equal to the iterative approach ED...

Jquery Onlick not happening second time

I'm a bit confused as to why this isn't working; I assume that because I'm adding the class and its not being added back into the collection I'm not sure. Here it is on a jsbin http://jsbin.com/ayije although code is below also. Either way I can only get the action to happen on an element once; <html> <head> <script src="http...

how to do a iterative rollup in sql

Hi I want to do a rolling sum (of valx) based on previous row value of rolling sum(valy) and the current row value of valx valy=previousrow_valy + valx animal valx valy cat 1 1 cat 3 4 cat 2 6 dog 4 4 dog 6 10 dog 7 17 dog 8 25 ...

Need help converting iterative pattern into formula

var = 8 itr 1: var == 8 (8 * 1) itr 2: var == 24 (8 * 3) itr 3: var == 48 (8 * 6) itr 4: var == 80 (8 * 10) itr 5: var == 120 (8 * 15) Pattern: (var * (last multiplier + current iteration)) Basically I want to get the result of formula(itr) without having to iterate up to itr. ...

Non-recursive post order traversal

Hi, I saw the following post order traversal algorithm in some website... it seems to be correct. I just want to verify that this algorithm works correctly — is this algorithm correct for post order traversal without recursion? void postOrderTraversal(Tree *root) { node * previous = null; node * s = null; push(root); w...

Iterative version of Binary Tree Search

Basic Tree-search algorithm for searching a node (with value k) in a binary search tree. 'x' denotes the node of the binary search tree. TREE-SEARCH (x, k) if x= NIL or k = key[x] then return x if k < key[x] then return TREE-SEARCH(left[x], k) else return TREE-SEARCH(right[x], k) Iterative Version: ITERATIVE-TREE-SEARCH...

jQuery iterative Timer

I want to create a jQuery iterative timer. For this I wrote the following script: $(document).ready(function(){ var t; function x() { alert('x') t = setTimeout("x()",1000); } x(); }); First time the function x() called successfully. But from the next function x() is detect as undefined. What could I...

Change a Recursive function that has a for loop in it into an iterative function?

So I have this function that I'm trying to convert from a recursive algorithm to an iterative algorithm. I'm not even sure if I have the right subproblems but this seems to determined what I need in the correct way, but recursion can't be used you need to use dynamic programming so I need to change it to iterative bottom up or top down ...

Anyone know an example algorithm for word segmentation using dynamic programming?

If you search google for word segmentation there really are no very good descriptions of it and I'm just trying to fully understand the process a dynamic programming algorithm takes to find a segmentation of a string into individual words. Does anyone know a place where there is a good description of a word segmentation problem or can a...

How do you estimate an agile project up front?

When working on fixed price software development projects, I frequently find myself having to estimate the total number of hours a project will take after the price is set, but before the work is started (or VERY early on in the development). Unfortunately, these types of projects are best developed using an iterative/agile method, whic...

Iterative hashing

I'm just wondering, is there a reason why some libraries (be it any language) use iterative hashing such that the hashed data is encoded in hex and rehashed again instead of rehashing the actual binary output? ...

Scaling an iterative, bitwise algorithm to solve the Towers of Hanoi using X discs and Y towers

I like the algorithm mentioned in this question: "How does this work? Weird Towers of Hanoi Solution" http://stackoverflow.com/questions/2209860/how-does-this-work-weird-towers-of-hanoi-solution Is there any way to scale that non-recursive solution of Towers of Hanoi to use X disks and Y towers, with towers represented as stacks? ...

How can I make a recursive version of my iterative method?

Greetings. I am trying to write a recursive function in Java that prints the numbers one through n. (n being the parameter that you send the function.) An iterative solution is pretty straightforward: public static void printNumbers(int n){ for(int i = 1; i <= n; i++){ System.out.println(i); i++; } As a novic...

Hadoop: Iterative MapReduce Performance

Is it correct to say that the parallel computation with iterative MapReduce can be justified mainly when the training data size is too large for the non-parallel computation for the same logic? I am aware that the there is overhead for starting MapReduce jobs. This can be critical for overall execution time when a large number of iterat...

Iterative text replacement across multiple files?

Disclaimer: Not a programmer by trade, but I've messed around a little in the past. Problem: I have a CLI program that generates an output text file from a text file list of inputs. I have been manually changing inputs in the text file to view the changes in output; however, this is inefficient. I would like to define a range of inputs ...

How does this iterative Tower of Hanoi work? C

Possible Duplicate: How does this work? Weird Towers of Hanoi Solution Hello, while surfing google, i found this interesting solution to Tower Of Hanoi which doesn't even use stack. Can anybody explain me in brief, what is it actually doing? And this solution really acceptable? #include <stdio.h> #include <stdlib.h> int main...

How to Transition to Scrum

My team has grown fairly quickly from 1 to 5 over the last year or so and are very interested in changing our development style from Waterfall to a more iterative approach like Scrum. We work for a University and specialize in CRUD web apps for internal customers who are always changing requirements along the way. So, my question is...H...

Make nested for loop algorithm - dynamic

I have an algorithm that goes something like this: for m = 1 to 2 initialize(work_item(m)) for l = 1 to 2 initialize(work_item(l)) for k = 1 to 2 initialize(work_item(k)) for j = 1 to 2 initialize(work_item(j)) for i = 1 to 2 initialize(work_item(i)) doSomething(work_item(i)) ...