Iteration uses a looping control structure (while, do while, for) to repeat a section of code until a condition is met.

learn more… | top users | synonyms

1
vote
1answer
38 views

Is a Recursive-Iterative Method Better than a Purely Iterative Method to find out if a number is prime?

I made this program in C that tests if a number is prime. I'm as yet unfamiliar with Algorithm complexity and all that Big O stuff, so I'm unsure if my approach, which is a combination of iteration ...
2
votes
3answers
84 views

Eliminating nested each

I have an unusual data structure that I need to search - the structure is the result of parsing a JSON file returned from an HTTP request. The top-level object is an Array, but from top to bottom I ...
4
votes
3answers
205 views

Implementing an algorithm that walks the DOM without recursion

Here's a simple algorithm that walks the DOM given a node: function walkDOM(n) { do { console.log(n); if (n.hasChildNodes()) { walkDOM(n.firstChild) } } ...
4
votes
2answers
125 views

Python line condenser function

This is a function I just wrote that tries to condense a set of strings into grouped lines. It actually works, but looks ugly. Is there a better way to achieve the same thing? Take 4 filtering empty ...
1
vote
3answers
124 views

How to flatten the nested for loops?

The problem I am facing is: I need to interate through a bunch of lists, and there are separated conditions which needs to be satisfied by the list. conditons are not independent. I care about the ...
2
votes
3answers
505 views

More efficient way to retrieve first occurrence of every unique value from a csv column?

A large .csv file I was given has a large table of flight data. A function I wrote to help parse it iterates over the column of Flight ID's, and then returns a dictionary containing the index and ...
2
votes
1answer
162 views

Iterating X times (where X > Y) over Y element dictionary - is there a nicer way of doing this?

I need to write a procedure, that will take a dictionary consisting of server names and their available slots and a number of slots required, and redispatch it over the servers, so that every server ...
3
votes
3answers
562 views

Most efficient way to iterate through arrays/can I use .times method in place of while method?

I created a quick program to test the precision of randomness generated by the .rand method. The primary question is whether I can use the .times method in place of the while code blocks to increase ...
1
vote
0answers
144 views

How to add faster object to an array

I have a list with contentlets and want all languages from every contentlet (I get these with the method languageAPI.getAllValuesByKey(key , contentList). I get a Hashmap and iterate over it. There ...
1
vote
3answers
190 views

jQuery iterate or two-step?

I have an array of values of the form: configs = ["26W", "27W", "28W"...] They correspond to some of the a elements in a list: <ul id="value-list"><li><a ...