Back to home

Topics

1.What do you mean by polish notation and reverse polish notation of an expression?

Prefix expression is known as polish notation and postfix expression is meant by reverse polish notation.

2.Give the order for evaluating an infix expression?

While evaluating an infix expression, there is an evaluation order according to which take place in the below mentioned specified order.

              ♦ Brackets or Parenthesis

              ♦ Exponentiation

              ♦ Multiplication or division

              ♦ Addition or Subtraction

The operators with the same priority (example: * and /) are evaluated from left to right.

3.Write down the steps to convert an infix expression into a postfix expression?

The steps to convert an infix expression into a postfix expression are given below:

a)Determine the actual evaluation order by inserting braces.

b)Convert the expression in the innermost braces into postfix notation by putting the operator after the operands.

c)Repeat step b until entire expression is converted into postfix notation.

4.Why it is said that a postfix expression is easy to carry out than an infix expression?

An infix expression is difficult for the machine to know and keep track of precedence of operators. On the other hand, a postfix expression itself determines the precedence of operators. Therefore, for the machine it is easier to carry out a postfix expression than an infix expression.

5.State the rules for evaluating a postfix expression.

Evaluation of a postfix expression states:


          ♦ While reading the expression from left to right, push the element in the stack if it is an operand.


          ♦ Pop the two operands from the stack, pop one operand from the stack and then evaluate it (two operands and  an operator)


          ♦ Push back the result of the evaluation. Repeat it till the end of the expression.

6.What is Queue?

A queue is a FIFO structure and it can be implemented either as an array or as a linked list. In its implementation, insertions take place at the "rear" end and deletions at the "front" end.

7.Explain the implementation of queue as an array.

When a queue is created as a array, its space required (no. of elements) is declared before processing. The beginning of the array becomes its "front" end and the end of the array becomes its "rear" end. "Front" stores the number of first element in the queue and "rear" stores the number of last element in the queue.

8.How insertions works in an array queue?

A queue is stored in the memory using an array QUEUE with N elements. New elements will be added to the rear end of the queue. With every insertion, the value of "rear" is increased by 1. This means that after N insertions, the rear element will occupy QUEUE [N] and after it, the queue becomes FULL and no more elements can be added to it. The working of insertions in an array queue is shown detail in the below figure:

9.Briefly explain how deletion of an element works in an array queue.

Deletions can occur at the "front" end only, with every deletion, the "front" gets modified. Whenever an element is deleted from the queue, the value of "front" is increased by 1. 

10.What is linked queue?

Linked queues are the queues having links among its elements. Two pointers are maintained to store the "front" position and the "rear" position.

11.How insertion and deletion takes place in linked queue?

Insertions in a linked queue take place only at the "rear" end i.e., the "rear" gets modified with every insert.

Deletions in a linked queue take place from the "front" end. Therefore, the "front" gets modified with every delete.

12.Which are the popular variations of queues?

The two popular variations of queues are


               ♦ Circular queue

               ♦ Dequeue(double-ended queue)

13.What do you mean by circular queues?

Circular queues are the queues implemented in circle form rather than a straight line. It overcomes the problem of utilized space in linear queues implemented as arrays

14.What is dequeue?

Dequeue or double - ended queues are the refined queues in which elements can be added or removed at either end but not in the middle.

15.Mention the variations of a deque and explain it?

There are two variations of a deque -

  •   input restricted deque
  •   output restricted deque.

An input restricted deque is a deque which allows insertions at only one end but allows deletions at both ends of the list.

An output restricted deque is a deque which allows deletions at only one end of the list but allows insertions at both ends of the list.

Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Paid Users Only!
Powered By