## Brute Force Approach in Compiler Design

Brute Force Approach in Compiler Design is the easiest topic in computer science, In this article, you will learn easily Brute Force Approach in Compiler Design. In this tutorial, we are going to learn about Brute Force Approach in Compiler Design.

The brute-force algorithm is actually the most straight forward approach to solving a problem. This technique usually involves direct computation based on the problem’s statement and the definition of the concepts involved.

**Example**: computing factorial of a number – the input is assumed to be ‘n’. Now, we know the problem statement clearly, so we can directly compute the result as ‘1*2*3*…*n’

## Advantages of Brute Force Approach in Compiler Design

This method is used by default to solve some problems such as sorting, searching, matrix multiplication, binomial expansion etc.

used for solving smaller instances or modules of a larger problem.

## Disadvantages of Brute Force Approach in Compiler Design

It is inefficient and hence useless when dealing with homogeneous problems of higher complexity

Not suitable for solving problems that have an hierarchical structure and involve logical operations.

### Write a program to parse using Brute force technique of Top-down parsing :

**Closest Pair Problem (Brute Force method)**

```
Finding the shortest distance between two points on a two dimensional plane.
Input : (x1,y1), (x2,y2)
#include<stdio.h>
#include<math.h>
void main()
{
int x1,y1,x2,y2;
float dist;
//assuming inputs are recieved
dist=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
printf("\n distance = %ld", dist);
}
```

- Can Only Compare Identically-Labeled Series Objects
- This Vector Function Is Used To Insert An Item Into A Vector
- Cannot Use Import Statement Outside a Module Node
- What Are Streams in C++? What Are Predefined Streams in C++?
- Storage Allocation in Block Structured Language

Brute Force Search – Wikipedia