49 Answered Questions for the topic Algorithm

What is tail recursion?

While learning lisp, I've come across the term *tail-recursive*. What does it mean exactly?

05/29/19

How do I check if cartesian coordinates make up a rectangle efficiently?

The situation is as follows: - There are N arrays. - In each array (0..N-1) there are (x,y) tuples (cartesian coordinates) stored - The length of each array can be different I want to extract the... more
Algorithm Geometry Python Points

05/29/19

Find equidistant points between two coordinates?

I have a function which needs to take out equidistant points between two points on the screen(2d). Like this - |--------------| The distance is already decided. For example, I take it as `2`... more

05/24/19

The shortest path between two integers by adding or subtracting?

You are given two integers a and b. You want to find the shortest sequence of operations necessary to transform a into b, where at each step you are allowed to add or subtract 5, 7, or 12. For... more

05/13/19

Predicate vs Functions in First order logic?

I have been so confused lately regarding difference between predicate and function in first order logic. My understanding so far is, Predicate is to show a comparison or showing a relation... more
Algorithm Logic

05/12/19

What is the logic for solving this sequence?

The sequence goes like this.. `7,8,77,78,87,88,777,778,787,788` and so on.. What can be the logic for finding the nth number of the sequence? I tried that by dividing it by 2 and then by 4 and... more
Algorithm Photography C Light

05/11/19

How to convert between lux and exposure value?

How to convert from an [exposure value][1] to [lux][2]? Thanks! i.e. what's the formula behind [this chart][3]? [1]:... more
Algorithm Math C++ Logic

05/07/19

Most efficient/elegant way to clip a number?

Given a real (n), a maximum value this real can be (upper), and a minimum value this real can be (lower), how can we most efficiently clip n, such that it remains between lower and upper? Of... more
Algorithm Math Calculus Matlab

04/23/19

creating random numbers that favor smaller numbers?

say i generated a set of random numbers and put them into an array, (pre-sorted for simplicity) i'll use javascript to show the math: var vals = new... more
Algorithm Math Calculus Matlab

04/23/19

Derivative of sigmoid?

I'm creating a neural network using the backpropagation technique for learning. I understand we need to find the derivative of the activation function used. I'm using the standard sigmoid... more

04/12/19

Distinguishing extra element from two arrays?

One of my friend was asked this question in an interview - - You have given two integer arrays each of size 10. - Both contains 9 equal elements (say 1 to 9) - Only one element is... more
Algorithm Logic Arrays

03/19/19

Median of 5 sorted arrays?

I am trying to find the solution for median of 5 sorted arrays. This was an interview questions. The solution I could think of was merge the 5 arrays and then find the median [O(l+m+n+o+p)]. I... more
Algorithm Java Logic Median

03/18/19

Fastest way of finding the middle value of a triple?

Given is an array of three numeric values and I'd like to know the middle value of the three. The question is, what is the fastest way of finding the middle of the three? My approach is this kind... more

finding GCD using Euclidean

i) Use the Euclidean Algorithm to calculate the greatest common divisor of 95658 and 48685.Clearly outline all the steps in the algorithm. (ii) Reverse Euclid’s Algorithm in (i) to find integers x... more

11/24/17

How can I find the lowest number, who's factors add up to exceed N?

How can I find the lowest number, who's factors add up to equal or exceed N?For example, 48 is the first number where it's factors add up to equal or over 100 with it's factors adding up to 124. So... more
Algorithm

10/18/17

why is 2 * n * (n - 1) equal to 2 * n^2 - 2 * n

I am learning algorithm efficiency in computer data structures class. I just can't remember how some of these equations are equated. An answer and explanation for each step in the multiplication... more
Algorithm C++

05/20/17

Meaning of "two comparisons" in the context of the provided question from geeksforgeeks.com

This is the exact question from the website.Given a sorted array having 10 elements which contains 6 different numbers in which only 1 number is repeated five times. Your task is to find the... more

05/10/17

This is a coding question. However, I do not require the answer in code. I just need help in figuring out the math behind this question.

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent... more
Algorithm

11/28/16

A certain radioactive isotope has leaked into a stream

A certain radioactive isotope has leaked into a small stream. Two hundred days after the leak, 8% of the original amount of the substance remained. Determine the half-life of this radioactive... more

polar coordinates

Write in polar coordinates all 8-th roots of unity. Find all pairs of roots r1 and r2 such that r1 = r2
Algorithm

08/09/16

Write the digits 0-7 in the row of boxes below.

Write the digits 0-7 in the row of boxes below. No consecutive numbers may be side by side and include a pattern that alternates numbers higher, then lower than the one before.
Algorithm

12/15/15

what does it mean when there is a tiny number in an algorithm ex. 15a1+ 14a2 (but the 1 and 2 is half the size)

The full algorithm is 15a1+14a2+13a3+12a4+11a5+10a6+9a7+8a8+7a9+6a10+5a11+4a12+3a13+2a14+1a15 with all the letters after the a being miniature. I just don't understand what to do with the smaller... more

Designing an algorithm, numerical analysis

Suppose you need to numerically ?nd a value of x on an interval [0, 5] for which function f(x) = x3 is equal to 2.197. (a) Design an algorithm for this problem which is (i) guaranteed to... more
Algorithm Logic Problem

10/22/14

Long logic question from UMD math competition

There are 11 ants on a ruler. Each ant is on an inch marker (1 - 12). The ants on the left side of the ruler, on numbers 1-6, are crawling toward the right end of the ruler (towards 12). Ants on... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.