orla-bradford
Uploaded by
11 SLIDES
236 VUES
110LIKES

Understanding The Halting Problem and Its Implications in Java Programming

DESCRIPTION

This discussion delves into the complexities of the Halting Problem and presents intriguing Java programming examples that illustrate well-formed mathematical problems unsolvable by computers, regardless of speed. We explore the behavior of various Java programs, including "CountWordsInFile", "RunForever", and "StrangeProgram", to highlight cases where programs can either run indefinitely or yield unexpected results. Through these examples, we aim to foster a deeper understanding of computability, the limits of programming, and the inherent challenges posed by the Halting Problem.

1 / 11

Télécharger la présentation

Understanding The Halting Problem and Its Implications in Java Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Very Hard Problems I am so not kidding about this. Please grab a handout.

  2. Theory

  3. What do you think? There are some well-formed mathematical problems that computers can’t solve, no matter how fast computers get. • True • False

  4. Java Programs That Take Files as Inputs For example: CountOfWordsInFile.java …we run it like this “CountWordsInFile file.txt” And it prints the number of words in that file.txt. What if we ran it like this: “CountWordsInFile CountWordsInFile.java” What would it print? • That doesn’t make sense • It would run forever • The number of words in the CountWordsInFile.java file (say 100)

  5. Ok, another program • RunForever.java • It’s a program with an infinite loop • …we run it like this “RunForever file.txt” • But no matter what file we put in, it runs forever • So what would happen if we run it like this: “RunForever RunForever.java” • That doesn’t make sense • It would run forever • It would print something

  6. Still Another Program • RunWithItself.java • Just runs the java program passed in, with itself as input. So “RunWithItselfJavaProg.java” is the same thing as “JavaProg JavaProg.java” • So say we ran “RunWithItself CountWordsInFile.java” • That doesn’t make sense • It would run forever • It would print out a number

  7. Penultimate Program WillRunForever.java • Really handy program that determines if a program will run forever *if passed itself as an input* (it acts a lot like RunWithItself.java) • Prints either “SAFE” or “DANGER” • This program never runs forever • What is the output of:

  8. Last Program • StrangeProgram.java • Runs WillRunForever.java on it’s input. If WillRunForever.java prints “SAFE”, StrangeProgram runs forever. If WillRunForever.java prints “DANGER” StrangeProgram prints “STRANGE” and exits.

  9. Final Question • What is the output of: StrangeProgram StrangeProgram.java • Hint: It helps if you figure out the output of WillItRunForever StrangeProgram.java first

  10. The halting problem is not computable.There are others.

  11. You can see my PNP “slides” here: • http://prezi.com/k8e5v1wgicit/copy-of-copy-of-ghp-pnp/

More Related