PFP Homework 1
Jump to navigation
Jump to search
Automatons
Let say, we have a finite automaton defined as: Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle (Q, Σ , q0, F, δ )}
type Transition = (Int, Char, Int)
type Automaton = (Int, String, [Int], Int, [Transition ])
where states are coded with numbers from 0 to n
ex1 :: Automaton
ex1 = (3, [0], [2], "ab", [(0,'a',1), (0,'b',0), (1,'a',1), (1,'b',2), (2,'a',1), (2,'b',0)])
ex2 :: Automaton
ex2 = (3, [0], [2], "ab", [(0,'a',1), (0,'a',0), (0,'b',0), (1,'b',2)])
- Create a function, that sorts an array using quicksort algorithm
quicksort
. Inside, you must use the mutable arraySTArray
.
quickSort :: Array Int Int -> Array Int Int
ghci> elems $ quickSort $ listArray (0,5) [8,4,9,6,7,1]
[1,4,6,7,8,9]