I am at a crossroads in my program and I was wondering which path would be more efficient time wise [closed] - performance

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I currently see two ways to code the next step of my program and there are probably more, but the two routes I have are as follows.
I take the factors of the lowest number and loop through the other numbers two see if they share those common factors.
I find the factors of the lowest number and add it to a list. I then find the factors of the other numbers that do not exceed the lowest and add them to the same list. I then run through the list to check which is the highest number that appears x times.
I am leaning towards 1, but I'm not sure.
Sorry if this is too ambiguous, thanks.

Well, given the ambiguity, as stated: the 1st requires less steps and avoids the allocation of a data structure.

Related

the number of swaps in sorting algorithm [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
This post was edited and submitted for review 3 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Recently I was learning sorting algorithms, and a description that I found in a book illustrated the numbers of comparisons, swaps, and extra space that will determine the performance. So I was very confused about that. Why will the number of swaps hurt the performance?
"performance" refers to the running time of code. I have seen another post that mentioned swapping elements is vastly more expensive.
in practice, swapping elements is vastly more expensive than comparing. This is even more pronounced when elements are far apart, due to caching. So, on modern hardware, algorithms that tend to swap less - and when they do swap, move elements the furthest toward their final destination - tend to win out.
I want to know the affection of swaps in sorting algorithms. I'm new to this, pls.

Is there any algorithm to achieve some optimization for hanger placement? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this question
I need to do a job where I need to place a particular object(Hanger) in a standard distance.
The rules are:
We should try to place each object in a given standard distance from each other.
There is a max distance from one object to adjacent object which in no way should be violated.
From the start and end also similar standard and maximum distance rule applies.
And there are some portions given where the objects placement needs to be avoided.
I'm not even able to start... which algorithm to use.
If anyone has any suggestion how I can achieve this or some related source please let me know.

Real time applications for counting numbers [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am solving interesting questions which are quite frequently asked in programming interview like following:
Compute sum of digits in all numbers from 1 to n?
Compute number of perfect square between two given numbers?
Count numbers from 1 to n that have 4 as a digit?
I am wondering what are real time applications for above? Can any one please share there views.
I think these questions have multiple solutions. Question 1 and 3 are interesting because you can solve these problems without iteration in very clever ways, but also solve them using very long winded ways. As someone who does a lot of interviewing, I would want use this type of question to gauge the sophistication of the candidate at solving problems. On that basis I don't think giving you a clever answer to these question is going to be in your best interests to succeeding at interviews. How you tackle a problem and how far you can push the boundaries is what is likely being tested.

Searching through an list [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm reading about AI and in the notes it is mentioned
A lookup table in chess would have roughly 35^100 entries.
But what does this mean? Is there any way we could find out how long it would take the computer to search through and find it's entry? Would we assume thereis some order or that there is no order?
The number of atoms in the known universe is estimated to be around 10^80 which is much less than 35^100. With current technology, at least a few thousand atoms are required to store a single bit. I assume that each entry of your table would have multiple bits. You would need some really advanced technology to implement the memory of your computer.
So the answer is: With current technology it is not a matter of time, it is simply impossible.

Algorithm for finding similar words [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In order to support users learning English, I want to make a multiple-choice quiz using the vocabulary that the user is studying.
For example, if the user is learning "angel" then I need an algorithm to produce some similar words such as "angle" and "angled"
Another example, if the user is learning "accountant" then I need an algorithm to produce some similar words such as "accounttant" and "acountant", "acounttant"
You could compute the Levenshtein Distance from the starting word to each word in your vocabulary and pick the 2 or 3 shortest ones.
Depending on how many words are in your dictionary this might take a long time though, so I would recommend bailing out after a certain (small) number of steps - i.e. if you have made 3 mutations and still haven't arrived at your target word then stop and move on to the next one.

Resources