44 Answered Questions for the topic Algorithm

09/16/19

#### Write pseudocode Centigrade and Fahrenheit are two scales to measure temperature.

Write pseudocode and that prompts (input) the user to enter Centigrate and then print the Fahrenheit.Use following formula for conversion.

08/02/19

#### Could a truly random number be generated using pings to pseudo-randomly selected IP addresses?

The question posed came about during my comp sci lecture while discussing the impossibility of generating numbers in a deterministic computational device.This was the only suggestion which didn't...
more

08/01/19

#### Help Understanding Big O

I'm asking more about what this means to my code. I understand the concepts mathematically, I just have a hard time wrapping my head around what they mean conceptually. For example, if one were...
more

07/29/19

#### Which is the fastest way to get the absolute value of a number?

How fast is an `if` (and why please). My college programing professors always told me to avoid `if`s for they are extremely slow, but I always forgot to ask how slow and why.

07/25/19

#### Anyone know anything about OLAP Internals?

I know a bit about database internals. I've actually implemented a small, simple relational database engine before, using ISAM structures on disk and BTree indexes and all that sort of thing. It...
more

07/12/19

#### How to efficiently determine if a set of points contains two that are close?

I need to determine if a set of points (each given by a tuple of floats, each of which is in [0, 1]) contains two that are within some threshold, say 0.01, of each other. I should also mention that...
more

06/30/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

06/27/19

#### What's the approach to solving this kind of logic problem?

What would be the approach to a kind of problem that sounds like this:
A says B lies
B says C lies
D says B lies
C says B lies
E says A and D lie
How many lie and how many tell the truth?
I...
more

06/27/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

06/27/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

06/26/19

#### Digit-increasing number test?

A number is called digit-increasing if it is equal n + nn + nnn + ... for some digit n between 1 and 9. For example 24 is digit-increasing because it equals 2 + 22 (here n = 2).
Actually, a friend...
more

06/19/19

#### How do you find a point at a given perpendicular distance from a line?

I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that...
more

06/19/19

#### How do I calculate the area of a 2d polygon?

Assuming a series of points in 2d space that do not self-intersect, what is an efficient method of determining the area of the resulting polygon?
As a side note, this is not homework and I am not...
more

06/19/19

#### Display 1,2,3,4,5,6,8,10,11 as 1-6,8,10-11?

> I have this sequence **1,2,3,4,5,6,8,10,11**
>
> Expected output is **1-6,8,10-11**
This problem is about formatting the sequence in easy readable form
I tried with c# and used many...
more

06/19/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 <i>fastest</i> way of finding the middle of the three?
My...
more

06/19/19

#### Parsing Java Source Code?

I am asked to develop a software which should be able to create Flow chart/ Control Flow of the input Java source code. So I started researching on it and arrived at following solutions:
To create...
more

06/19/19

#### All possible words?

I want to create all possible 5 letter words using a-z.Please suggest any good and fast algorithms.
I have tried creating one and it looks something like this...
byte[] allchar=new byte[]...
more

06/14/19

#### Removing duplicates in lists?

Pretty much I need to write a program to check if a list has any duplicates and if it does it removes them and returns a new list with the items that werent duplicated/removed. This is what I have...
more

06/03/19

#### What is the fastest way to get the value of π?

I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using `#define` constants like `M_PI`, or hard-coding the...
more

06/01/19

#### 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

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

## 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.