Data Structure interview questions


16. What is meant by overflow and underflow
Overflow is when the absolute value of the number is too high for the computer to represent it.
Underflow is when the absolute value of the number is too close to zero for the computer to represent it.
You can get overflow with both integers and floating point numbers. You can only get underflow with floating point numbers.
To get an overflow, repeatedly multiply a number by ten. To get an underflow repeatedly divide it by ten.

17.What is a queue?
A queue is defined as an ordered collection of items from which items may be deleted at one end and items inserted at the other end .It obeys FIFO rule there is no limit to the number of elements a queue contains.

18. What is the formula to calculate the position of rear and front of the circular queue?
When the value (rear+1)%size=0, this means that the rear position has been occupied and so it has to be equal to 0(if front is not 0, because if it is, then this both will satisfy the full condition), And then continue insertion. Also, if front is not 0 and is less than rear value, this will mean the queue is empty and u can play with it further.

19. What is Stack?
Stack is a data structure used to store a collection of objects. Individual items can be added and stored in a stack using a push operation.

20. Which are the places stack can be used?
Infix to Postfix Conversion using Stack.
Evaluation of Postfix Expression.
Reverse a String using Stack.
Implement two stacks in an array.
Check for balanced parentheses in an expression.

Author: user

Leave a Reply