How can an inductive definition be realized?
An inductive definition of a set can be realized by using a given finite set of elements A and the following three clauses.
1) Basis Clause
2) Inductive clause
3) External clause
Write a program to find cycle or detect loop in a single linked list
The most common and easiest way to find a loop or cycle in a linked list is to have too pointer . Increment the first pointer by one and second pointer by two . If both the pointer of linked list matches then there is a loop in a linked list .
Below code show the way how to achieve or find loop in a linked list
public static boolean hasCycle(Node head) {
Node fast = head;
Node slow = head;
while (true) {
if (fast == null || fast.next == null)
return false;
else if (fast == slow || fast.next == slow)
return true;
else {
fast = fast.next.next;
slow = slow.next;
}
}
}
Descibe Markov algorithm terminates in terms of last production and terminal production?
Markov algorithm terminates in one of the two ways.
1) The last production is not applicable
2) A terminal production is applicable
A terminal production is a statement of the form x map to y., where x and y represent the strings in V* and the symbol “.” Immediately follows the consequences.
On which strategy Markov Algorithm works?
The general strategy in a Markov Algorithm is to take as input a string x and, through a number of steps in the algorithm, transform x to an output string y. this transformation process is generally performed in computers for text editing or program compilation.
Markov algorithm terminates in one of the two ways.
1) The last production is not applicable
2) A terminal production is applicable
A terminal production is a statement of the form x map to y., where x and y represent the strings in V* and the symbol “.” Immediately follows the consequences.
