48 Answered Questions for the topic Algorithm



2. Suppose a linked list of 20 nodes.

Suppose a linked list of 20 nodes. The middle node has a data –250. Write the pseudocode to replace the middle node of the linked list with a new node and new data. Assume that the... more
Algorithm Heapsort


Data and analysis of algorithm

1. illustrate the operation of HEAPSORT on the array A = {15, 113, 12, 125, 17, 117, 120, 18, 14}. Show, visually, the binary tree just after the BUILD-HEAP is called and at the end of each of the... more
Algorithm Math Permutations


Permutations algorithm maximum difference/contrast

Hello, I was wondering what would be the algorithm for permutations with 5 numbers and 4 possible kinds of numbers used and order being important. To make each iteration as different as possible... more


How to generate random numbers with specific mean

Is there any formula that I can understand which will allow me to generate random numbers with a specific mean. I'm using java. Thanks


What are some approaches/algorithms to solve the problem of supply-demand-price?

Problem statement: transport some products from (A, B, C) to (D, E, F), each place has a specified amount of supply (from) and demand (to). Each route has multiple choices (multiple vendors) and... more
Algorithm It Steps Pseudocode


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.


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


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

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.


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

What is an NP-complete in computer science?

What is an NP-complete problem? Why is it such an important topic in computer science?

Explaining computational complexity theory?

Assuming some background in mathematics, how would you give a general overview of computational complexity theory to the naive? I am looking for an explanation of the P = NP question. What is P? ... more

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
Algorithm Logic


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
Algorithm C++ C Logic


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
Algorithm Math Geometry Graphics


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
Algorithm Geometry 2d


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
Algorithm Java Logic C#


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
Algorithm Java Logic Median


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


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
Algorithm Java Logic


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


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
Algorithm Unix Pi Performance


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

What is tail recursion?

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

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.


Find an Online Tutor Now

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