B7 Informatics 2 SoSe 2020

Website of Prof. Dr. Barne Kleinen, Professor for Media Informatics (Bachelor/Master) at HTW Berlin

Info2: Exercise 11: Finite State Automata and Sorting Algorithms

     <prev next>

Pre-Lab

P1. What is the difference between an NFA and an DFA?

P2. Which sorting algorithms have you learned about so far? Review their algorithms.

Geeks for Geeks has some helpful explanations, including nice videos. Useful for a quick reminder of the algorithms. Eg. Selection Sort.

Really good more detailed explanations can be found at the Back to Back SWE YouTube Channel:

Assignment

Part 1: Finite Automata

This is to get some practice with Finite Automata.

A: Understand Finite Automata

The following two Finite Automata are given by their transition tables:

Automaton A Start state: q0, accept state: q0

01
q0q0q1
q1q2q3
q2q0q1
q3q2q3

Automaton B Start state: q1, accept states: q2, q4

01
q1q2q4
q2q1q3
q3q4q2
q4q3q1
  1. Draw transition diagrams for all two Finite Automatas and describe the language they accept in English (or German) sentences. Are they DFA or NFA?
  2. What are words in and not in the language? Create Simulations for both Finite Automata with fitting words as test cases. You can use NFA1AtThirdFromLast.java as an example. You find an NFA Simulator in https://github.com/htw-imi-info2/Lab11_DFA.

B: Design Finite Automata

The following three Finite Automata are given by their description:

Automaton C: The Finite Automaton accepts all strings of 0’s and 1’s not containing 010 as a substring.

Automaton D: The Finite Automaton that accepts all strings with at most one pair of consecutive 0’s and at most one pair of consecutive 1’s.

Automaton E: The Finite Automaton that accepts the language of all Strings of 0 and 1s, that when interpreted as a binary number, are divisible by three.

  1. Define the given Finite Automata and fitting test cases. Draw transition diagrams for all three Finite Automata. Are they DFA or NFA?
  2. Test your automata by using the simulator above. Again, you can use NFA1AtThirdFromLast.java as an example.

Part 2: Sorting

  1. Generate an array (on paper) containing 10 random integers between 1 and 100 and perform manual walkthroughs of the 5 sorting algorithms given at https://github.com/htw-imi-info2/Lab11_Sorting. Each persone should do at least one walkthrough. Use the exact algorithms from the repository.

Lab Report / What to turn in

All info on the lab reports can be found on the Labs page.

Also answer the following questions in your report:

  • Part 1, A, 1: Put the transition diagrams in your report, as well as the description of the languages
  • Part 1, A, 2: Which test cases did you chose?
  • Part 1, B: Put the transition diagrams in your report.
  • Part 2: Each of the algorithms has a location marked with //step. In your report, note down the state of the array at this location for each time the algorithm passes this line.