Day 3: Exploring Advanced Topics
Artificial Intelligence
Artificial intelligence is an area of computer science which studies how a computer performs an activity which is currently performed better by a human. Diagnosing diseases or driving a car are examples of activities a human can (currently) perform better than a computer. You will investigate how to simulate intelligent behavior in a computer and write computer programs to play a game, such as tic-tac-toe, or solve a puzzle, such as sudoku.
Sudoku
There are several algorithms for finding solutions to Sudoku puzzles. Today, we will explore the simplest algorithm which uses a stack.
As a group, develop the algorithm for solving Sudoku puzzles.
Resources
- A Demo (to run, download and double-click)
- Use the provided skeleton NetBeans project: Sudoku Skeleton
- Sample puzzles which can be used as input (from Web Sudoku)
- Web Sudoku (a source of new puzzles)
- Sudoku (Wikipedia)
- Sample solution
Concurrent Programming
With the advent of multi-core processors on the desktop, concurrent programming, which involves writing programs which perform more than one activity at once by dispatching each activity to a different processor, is an essential ingredient in the development of modern computer programs. For instance, Google's new Chrome web browser is a concurrent program in that all open tabs in the browser run in parallel. Moreover, concurrent programs can model many real-world situations such as multiple customers in a food court dynamically entering and exiting the various queues therein. Specifically, you will implement i) finding prime numbers and ii) sorting - specifically merge sort.
Prime Number Exercise
Steps:
- Write a program to check if a given number is prime.
- Write a program to identify all the prime numbers up to a certain point.
- Write a program to simultaneously check multiple numbers for primality, identifying all the prime numbers up to a certain point.
For text-based I/O, use MainPrime.java for step 1 and MainRange.java for steps 2 and 3.
Refer to the concurrency thread through the Java tutorial for information on using threads in Java.
Merge sort
Steps:
- Sort 10 numbers on paper by tracing through the merge sort algorithm.
- Implement merge sort.
- Implement merge sort using threads.
For text-based I/O, use MainMerge.java.