# 3i Infotech Placement: Sample Questions 446 - 447 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 446

### Explanation

- Backtracking is the type of the algorithm used in solving the 8 Queens problem.
- Considers searching every possible combination in order to solve an optimization problem.
- Also known as depth-first search.

**Algorithm of backtracking**:

- Boolean solve (Node n)
{

If n is a leaf node

{

If the leaf is goal node, return true

Else return false

}

Else

{

For each child c of n

{

If solve (c) succeeds, return true

}

Return false

}

}

- The algorithm is expressed as a Boolean function.

## Question 447

### Question

MCQ▾Semaphore is used for

### Choices

Choice (4) | |
---|---|

a. | dead-lock avoidence |

b. | box |

c. | synchronization |

d. | None of the above |

### Answer

c.### Explanation

- Semaphore is a simple variable used which uses critical sections to achieve process synchronization in a multi-processing environment.
- Two common semaphores are:
- Counting semaphore which takes non-negative integer values
- Binary semaphore which takes the value .

- If semaphores are implemented using file descriptors. Semaphore creations are not atomic. Thus if two processes try to create, initialize and use a semaphore at the same time, a race condition is created.
- They are thus implemented through interrupts or by using test-set operations to achieve atomicity