48 Answered Questions for the topic Algorithm
Algorithm
10/08/20
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
09/12/20
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
03/10/20
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
02/12/20
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
12/26/19
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
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/21/19
What is an NP-complete in computer science?
What is an NP-complete problem? Why is it such an important topic in computer science?
07/19/19
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
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
Algorithm Logic
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
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
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
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
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
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
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?
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.