Java Trying to come up with simple algorithm of significant time complexity in Java

AI Thread Summary
The discussion focuses on finding algorithms that can significantly slow down computer processing times for specific tasks. The original poster is exploring methods beyond simple calculations, like recursively computing Fibonacci numbers, and seeks NP problems that can effectively tie up computational resources. Suggestions include implementing a 3SAT solver, a boolean satisfiability problem that evaluates complex logical expressions, and tackling the traveling salesman problem, which involves finding the most efficient route through a set of cities. Both problems are highlighted for their high time complexity, specifically O(2^n), indicating that as input size increases, the processing time escalates dramatically, making them suitable for the intended purpose of the program.
frankfjf
Messages
166
Reaction score
0
Hi PF,

I'm working on a program that requires measuring how long it takes a given computer to process a certain task, but am having trouble coming up with algorithms that won't take most computers a trivial amount of time to perform. The only one I've got so far is recursively computing Fibonacci numbers.

Can anyone suggest similarly simple methods that will tie up a computer for more than an instant? It's fine if the method only slows things down for large inputs.
 
Technology news on Phys.org
You need an NP problem! Here's a list of some good hard (for a computer) algorithms. Last year I implemented a 3SAT-Solver and brought my computer to it's knees. It wasn't too hard. A 3SAT problem is a boolean satisfiability problem, given a conjunction of clauses

i.e.

(a OR b OR ~c) AND (b OR c OR ~d) AND (...) AND (...) etc

What is an assignment you can give to a, b, c, d, etc that will make the expression evaluate to true?

The traveling salesman problem is another famous one. Given a set of cities with some cost between each one, what is the route that visits all cities once (hamiltonian path) with the least cost. You can represent the cities and connecting paths with a graph and write a graph traversal algorithm to find hamiltonian paths, which is computationally costly in the first place, and you need to find every possible hamiltonian path before you can be sure that you have the one with least overall cost.

These problems have time complexity of O(2n) where n is the size of the input, so you can see that as soon as n gets even remotely big, the time it takes to solve these problems gets very, very, very, very, very big!
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top