# Basic CS-Data Structures [3i Infotech Placement]: Sample Questions 7 - 8 of 52

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

## Question 7

Data Structures
Edit

### Describe in Detail

Essay▾

What are the notations used in Evaluation of Arithmetic Expression using prefix and postfix forms?

### Explanation

• Polish and reverse polish are the notations used in evaluation of arithmetic expression using prefix and postfix forms.

## Polish Notation

• Polish notation is also called as prefix notation.
• A form of notation for logic, arithmetic, and algebra.
• Its distinguishing feature is that it places operators to the left of their operands.
• While prefixing the operator to the number, it is called polish notation.

For example, ( (a + B) ⚹ C (D E) ^ (F + G) )

Prefix notation: ^ -⚹ + ABC-DE + FG

## Reverse Polish Notation

• A mathematical notation where every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position.
• It suffixes the operator to the number called reverse polish notation.

Ex. . ( (a + B) ⚹ C (D E) ^ (F + G) )

Postfix notation: AB + C ⚹ DE — FG + ^

## Question 8

Data Structures
Edit

### Describe in Detail

Essay▾

What is your favourite sorting algorithm? Why?

### Explanation

• Bubble sort is a good simple algorithm.
• Not suitable for large data sets as its average and worst-case complexity are of where n is the number of items.
• Beautiful algorithm easy to visualize with sorted elements bubbling up.

Bubble sort:

• let՚s solve unsorted array:
• 1st Iteration:
• Start with two elements, comparing them to check which one is greater.
• Value 33 is greater than 14
• Therefore, they are in sorted locations.
• We compare 33 with 27.
• New array looks like
• Compare 33 and 35.
• Both are in sorted positions.
• The next two values, 35 and 10
• 10 is smaller then 35 and hence are not sorted.
• Swap values.
• We find that we reached the end of the array.