# Basic CS-Algorithms [Redpine Infotech Placement]: Sample Questions 1 - 2 of 2

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

## Question 1

Algorithms

### Question

MCQ▾evaluates 18 then

- -left associative ⚹ has precedence over-
- -right associative ⚹ has precedence over-
- ⚹ left associative - has precedence over ⚹
- ⚹ right associative - has precedence over ⚹

Which is correct?

### Choices

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

a. | 1 |

b. | 3 |

c. | 2 |

d. | 4 |

### Answer

d.### Explanation

Given,

Evaluates 18

Then,

- has precedence over ⚹ and it associates from the right.

## Question 2

Algorithms

### Explanation

- Merge sort problem can be solved using divide and conquer strategy.
- The problem is divided into smaller sub-problems and each one solved independently.
- When we divide the subprograms into even smaller sub-programs, we reach a stage where no more division is possible.
- Those “atomic” smallest possible sub-programs are then solved.

## Merge Sort Problem

- Based on divide and conquer technique.
- First divides the array into equal halves and then combines them in a sorted manner.
## Ex

Merge sort, will take an unsorted array as below:

- Divide first equal into two parts.
- Array of 8 items is divided into two array of size 4.

- Does not change sequence of item.
- We divide these two arrays into further equal parts.

- Further divide these array

- Now, we combine them in exactly the same manner they broken down.
- We see the 18 and 32 are in sorted positions.
- We compare 26 and 9 and in the target list of 2 values, we put 9 first, followed by 26.
- We change the order of 17 and 35 whereas 42 and 46 are placed sequentially.

- We compare lists of two data values, and merge them into list of found data values placing all in a sorted order.

- The final merging is below:

- This is solution of merge problem.