Bhanu Priya

Bhanu Priya

1,060 Articles Published

Articles by Bhanu Priya

Page 102 of 106

Explain the concept of state elimination method in TOC

Bhanu Priya
Bhanu Priya
Updated on 11-Jun-2021 4K+ Views

There are two methods for converting a Deterministic Finite Automata (DFA) to Regular expression (RE). These methods are as follows −Arden's Theorem Method.State Elimination Method.Now, let us learn about the state elimination method used in TOC.State Elimination MethodStep 1Initial state of DFA does not have any incoming edge.If there exists any incoming edge to the initial state, then we need to create a new initial state which has no incoming edge to it.An example about the relation between incoming edge and initial state is given below−Step 2There must be only one final state in DFA.If there exist multiple final states ...

Read More

What is an anagram in C language?

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 4K+ Views

Anagram strings are nothing but, all the characters that occur for the same number of times in another string, which we call as anagrams.A user enters two strings. We need to count how many times each letter ('a' to 'z') appears in them and then, compare their corresponding counts. The frequency of an alphabet in a string is how many times it appears in it.If two strings have same count of the frequency of particular alphabet then, we can say those two strings are anagrams.Example 1String 1 − abcdString 2 − bdacThese two strings have same letters which appear once. ...

Read More

C Program find nCr and nPr.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 18K+ Views

In C programming language, nCr is referred as the combination. nCr is the selection of r objects from a set of n objects, where the order of objects does not matter.nPr is referred as the permutation. nPr is arrangement of 'r' objects from a set of 'n' objects, which should be in an order or sequence.Permutations and combinations formulasThe formulas to find the permutation and combination of given numbers in C language are given below −nCr = n!/(r!*(n-r)!)nPr = n!/(n-r)!.The logic used to find nCr is as follows −result = factorial(n)/(factorial(r)*factorial(n-r));The logic used to find nPr is as follows −result ...

Read More

C Program to find sum of perfect square elements in an array using pointers.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 2K+ Views

ProblemWrite a program to find the sum of perfect square elements in an array by using pointers.Given a number of elements in array as input and the sum of all the perfect square of those elements present in the array is output.SolutionFor example, Input= 1, 2, 3, 4, 5, 9, 10, 11, 16 The perfect squares are 1, 4, 9, 16. Sum = 1 + 4 + 9 +16 = 30 Output: 30AlgorithmRefer an algorithm given below to find the sum of perfect square elements in an array by using pointers. Step 1 − Read number of elements in array at ...

Read More

C program to represent the numbers in spiral pattern

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 1K+ Views

The spiral pattern to represent the numbers is shown below −The logic applied to print the numbers in spiral pattern is as follows −for(i=1;i

Read More

C Program to display the numbers in X pattern

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 2K+ Views

Refer an algorithm given below for the C program to display the numbers in X pattern.AlgorithmStep 1: Start Step 2: Declare variables Step 3: Read number of rows Step 4: for loop satisfiesif(i==j || i+j==rows-1)print i+1Print " "Step 5: Print new line Step 6: StopThe logic to print numbers in X pattern is as follows −for(i=0;i

Read More

C program to remove the brackets from a given input.

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 923 Views

ProblemLet’s create a simplified expression by removing brackets from the expressions.SolutionExample 1Input: A string expression with bracket is as follows: (x+y)+(z+q) The output is as follows: x+y+z+qExample 2The input is as follows: (x-y+z)-p+q The output is as follows: x-y+z-p+qAlgorithmRefer an algorithm to remove the brackets from a given input.Step 1: Declare and read the input at runtime.Step 2: Traverse the string.Step 3: Copy each element of the input string into new string.Step 4: If anyone parenthesis is encountered as an element, replace it with empty space.ExampleFollowing is the C program to remove the brackets from a given input −#include int ...

Read More

Explain queue by using linked list in C language

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 1K+ Views

Queue overflow and Queue under flow can be avoided by using linked list.Operations carried out under queue with the help of linked lists in C programming language are as follows −InsertDeleteInsertionThe syntax is as follows −Syntax&item : Newnode = (node*) mallac (sizeof (node)); newnode ->data = item; newnode ->link = NULL; if ((front = = NULL) || (rear = = NULL)){    front= newnode;    rear = newnode; }else{    Rear->link = newnode;    rear = newnode; }DeletionThe syntax is as follows −Syntaxif ((front= = NULL)) printf("Deletion is not possible, Queue is empty"); else{    temp = front;    front ...

Read More

Explain the stack by using linked list in C language

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2021 3K+ Views

Stack over flow and stack under flow can be avoided by allocating memory dynamically.Operations carried out under stack in C programming language are as follows −PushPopPushFollowing is the basic implementation of a linked list −&item = 10 newnode = (node*) malloc (sizeof (node)); newnode ->data = item; newnode ->link = NULL; newnode ->link = start; start = newnode;popThe syntax is as follows −Syntaxif (start = = NULL) printf("Deletion is not possible.List is empty") else{    temp = start;    start = start link;    free (temp); }ProgramFollowing is the C program for stack by using linked lists −#include #include ...

Read More

C program to calculate the standard deviation

Bhanu Priya
Bhanu Priya
Updated on 25-Mar-2021 6K+ Views

Standard deviation is used to measure deviation of data from its mean. The mathematical formula to calculate the standard deviation is as follows −$$s=\sqrt{Variance}$$whereVariance$$=\frac{1}{n}\:\:\displaystyle\sum\limits_{i=1}^n (x_{i}-m)^{2}$$and$$m=mean=\frac{1}{n}\:\displaystyle\sum\limits_{i=1}^n x_{i}$$AlgorithmRefer an algorithm given below to calculate the standard deviation for the given numbers.Step 1 − Read n items.Step 2 − Calculate sum and mean of the items.Step 3 − Calculate variance.Step 4 − Calculate standard deviation.The logic used in the program for calculating standard deviation is as follows −for (i = 1 ; i

Read More
Showing 1011–1020 of 1,060 articles
« Prev 1 100 101 102 103 104 106 Next »
Advertisements