Skip to main content

Theory of Computation | NFA - Non-deterministic Finite Automata

Prerequisites :

When there is a chance for multiple state changes on a given single input, the non-deterministic in autoama handles the scenario.

The non determinism may even lead a in to null states.

Non-deterministic Finite Automata(NFA) are pseudo machines, means cannot be implemented in reality, even though they are finite state machines.

But of course NFA are very useful to resolve problem by exhaustive searching and backtracking.


A null state is represented using Greek letter Φ

The figure represents a NFA, which accepts all strings which starts with alphabet 'a'

Here we have two states, A and B.

so, set of all states Q = {A, B}

and set of all symbols Σ = {a, b}

Final state F = {B} and initial state q0 = { A }

When input 'a' is given to state A, the state changes to B

But input 'b' on A leads to a null(Φ) state.

Any input on state B loop backs to state B itself.

since a alphabet/symbol input can give more than one final state, we have to track all the possible way a string can end up with.

And if there is a path, which ends on any final state the string considers as acceptable.

Example:

string 'baa', on giving its first symbol 'b' as input to initial state A leads to Φ state, and no further transitions possible.

This scenario is known as dead configuration, where there is no further movements possible, and the string gets rejected.

for string 'ab', the first alphabet 'a' gives transition to state B and second alphabet 'b' loop backs to same final state.

This the final state of string 'ab' is at final state B, it considers as a acceptable string.

String 'baa' follows a path A ➡ Φ and 'ab' follows A ➡ B .

Since in NFA a alphabet/symbol input can give more than one transition, there might be multiple path for a given string.

In all of those possible paths, if any one of them ends in final state, the string will be acceptable.

The path followed by strings in NFA varies from string to string. So these path cam be either a subset of Q(set of all states) or a Q itself or even be a null set.

so, state transition function delta can be represented as δ : Q x Σ ➡ {all subsets of Q}

Since Q is also a part of all possible subsets(2Q in number), every DFA is a subset of NFA

Comments

Popular posts from this blog

Operating Systems | Scheduling Algorithms : Round Robin

Round RobinFeatures : Most popular algorithm of allPractically implementableImplementable with basic data structures like queueExtremely lesser starvationOptimum efficiency can be set by controlling time quantumThe round robin algorithm will continuously switch between processes if a process in CPU (under execution) exceeds a time limit set by OS called time quantum.Flow Chart :Scheduler allocated process to for execution.CPU starts monitoring the execution time right after from allocation.If the process completes its execution before exceeding time quantum, OS forwards the process to termination state.else, the processes gets preempted once the time quantum limit exceeded and if the process finished at this moment, OS moves the process to termination state, else it moves to ready queue and iterates over the whole process listed above.Example : Consider the following table of processes and calculate completion time, turn around time and waiting time using Round Robin algorithm.Assumpt…

Operating Systems | Scheduling Algorithms : SJF

Shortest Job First(SJF)SJF algorithm schedules the shortest job(low burst time) available on main memory at the time of context switching in ready state . It can be either preemptive or non-preemptive depending on the nature of scheduler.Since the SJF select the job which is shorted among available jobs on main memory, Non-preemptive SJF algorithm will have larger waiting time if a job with longer burst time get scheduled first. In short SJF is also vulnerable to Convoy EffectTo find shortest process among min-heap would be the best data structure to be usedExample : Consider the following table of processes and calculate completion time, turn around time and waiting time using SJF algorithm with the following assumptions. No preemption.No I/O request will be there from any process.Arrival time is relative to CPU on time.Process NumberATBT103222324442View Answer

The execution of processes can be visualized as follows : By analyzing above representation completion time, turn around ti…

Operating Systems | Concept of shared memory and critical section

While printing your document opened in Adobe Acrobat Reader, if you gave a same command for document opened in Microsoft Word! How will it be?These are the real time situations where two processes competing together for same resources due to improper process synchronization. An unstructured access approval to these resources may lead to a abnormal output or a breach in information security or even it may cause for data loss. In the above case which might be a bunch of over-written papers coming out of the printer connected to that system.

Shared Memory and Critical Section Resources or memory spaces where different processes have access to read, write or update at same time are known as shared memory.And the piece of program which tries to access the shared memory is known as Critical Section. There are situations where an operating system need to handle multiple request from critical sections of various processes in a machine, in order to maintain data consistency in resources