Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

Which of the following is not an inherent application of stack?(a) Reversing a string(b) Evaluation of postfix expression(c) Implementation of recursion(d) Job schedulingMy query is from Stack Operations in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in class test.

Answer» RIGHT ANSWER is (d) Job scheduling

Easiest EXPLANATION - Job Scheduling is not PERFORMED USING stacks.
52.

Which of the following statement(s) about stack data structure is/are NOT correct?(a) Linked List are used for implementing Stacks(b) Top of the Stack always contain the new node(c) Stack is the FIFO data structure(d) Null link is present in the last node at the bottom of the stackI need to ask this question from Stack Operations topic in portion Abstract Data Types of Data Structures & Algorithms II had been asked this question in homework.

Answer»

The CORRECT answer is (c) Stack is the FIFO data structure

The best explanation: Stack FOLLOWS LIFO.

53.

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?(a) 600(b) 350(c) 650(d) 588My query is from Stack Operations in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in an interview for internship.

Answer»

The correct CHOICE is (b) 350

For EXPLANATION: The postfix EXPRESSION is EVALUATED using stack. We will get the infix expression as

(5*(4+6))*(4+9/3). On solving the Infix Expression, we get

(5*(10))*(4+3)

= 50*7

= 350.

54.

Which data structure is used for implementing recursion?(a) Queue(b) Stack(c) Array(d) ListEnquiry is from Stack Operations in section Abstract Data Types of Data Structures & Algorithms IThis question was posed to me by my school principal while I was bunking the class.

Answer» RIGHT ANSWER is (B) Stack

Easiest explanation - Stacks are USED for the implementation of Recursion.
55.

The prefix form of an infix expression (p + q) – (r * t) is?(a) + pq – *rt(b) – +pqr * t(c) – +pq * rt(d) – + * pqrtAsked question is from Stack Operations in division Abstract Data Types of Data Structures & Algorithms II had been asked this question in examination.

Answer»

Correct option is (c) – +PQ * rt

Easy explanation - GIVEN Infix Expression is ((p+q)-(R*t))

(+pq)-(r*t)

(-+pq)(r*t)

-+pq*rt. Thus PREFIX expression is -+pq*rt.

56.

The prefix form of A-B/ (C * D ^ E) is?(a) -/*^ACBDE(b) -ABCD*^DE(c) -A/B*C^DE(d) -A/BC*^DEI would like to ask this question from Stack Operations topic in section Abstract Data Types of Data Structures & Algorithms IThis question was posed to me during an interview.

Answer» RIGHT answer is (c) -A/B*C^DE

Easy explanation - Infix EXPRESSION is (A-B)/(C*D^E)

(-A/B)(C*D^E)

-A/B*C^DE. THUS prefix expression is -A/B*C^DE.
57.

Which data structure is needed to convert infix notation to postfix notation?(a) Branch(b) Tree(c) Queue(d) StackI need to ask this question from Stack Operations topic in section Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in semester exam.

Answer»

Right answer is (d) Stack

The best EXPLANATION: The Stack data structure is used to convert INFIX expression to postfix expression. The purpose of stack is to reverse the order of the OPERATORS in the expression. It ALSO serves as a storage structure, as no OPERATOR can be printed until both of its operands have appeared.

58.

The postfix form of A*B+C/D is?(a) *AB/CD+(b) AB*CD/+(c) A*BC+/D(d) ABCD+/*My question is taken from Stack Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was posed to me by my college professor while I was bunking the class.

Answer» RIGHT CHOICE is (b) AB*CD/+

To explain: Infix EXPRESSION is (A*B)+(C/D)

AB*+(C/D)

AB*CD/+. Thus POSTFIX expression is AB*CD/+.
59.

The process of accessing data stored in a serial access memory is similar to manipulating data on a ________(a) Heap(b) Binary Tree(c) Array(d) StackThis intriguing question comes from Stack Operations in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in an international level competition.

Answer»

Right option is (d) Stack

Explanation: In serial ACCESS memory data records are stored one after the other in which they are created and are accessed SEQUENTIALLY. In stack data STRUCTURE, elements are accessed sequentially. Stack data structure RESEMBLES the serial access memory.

60.

What data structure would you mostly likely see in non recursive implementation of a recursive algorithm?(a) Linked List(b) Stack(c) Queue(d) TreeMy doubt stems from Stack Operations topic in chapter Abstract Data Types of Data Structures & Algorithms II have been asked this question in an interview.

Answer»

The correct answer is (b) Stack

Explanation: In recursive algorithms, the order in which the recursive process comes back is the REVERSE of the order in which it GOES forward during execution. The compiler uses the stack data STRUCTURE to implement recursion. In the forwarding phase, the values of local variables, parameters and the return address are pushed into the stack at each recursion level. In the backing-out phase, the STACKED address is popped and used to execute the REST of the code.

61.

The data structure required to check whether an expression contains a balanced parenthesis is?(a) Stack(b) Queue(c) Array(d) TreeThis intriguing question comes from Stack Operations in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in class test.

Answer» RIGHT option is (a) Stack

Explanation: The stack is a simple data structure in which elements are added and removed based on the LIFO principle. Open parenthesis is pushed into the stack and a closed parenthesis POPS out elements till the top ELEMENT of the stack is its corresponding open parenthesis. If the stack is empty, parenthesis is balanced otherwise it is unbalanced.
62.

The postfix form of the expression (A+ B)*(C*D- E)*F / G is?(a) AB+ CD*E – FG /**(b) AB + CD* E – F **G /(c) AB + CD* E – *F *G /(d) AB + CDE * – * F *G /Enquiry is from Stack Operations in portion Abstract Data Types of Data Structures & Algorithms II had been asked this question in an interview.

Answer»

Correct choice is (C) AB + CD* E – *F *G /

Best explanation: (((A+ B)*(C*D- E)*F) / G) is CONVERTED to postfix expression as

(AB+(*(C*D- E)*F )/ G)

(AB+CD*E-*F) / G

(AB+CD*E-*F * G/). THUS Postfix expression is AB+CD*E-*F*G/

63.

What is the value of the postfix expression 6 3 2 4 + – *?(a) 1(b) 40(c) 74(d) -18I would like to ask this question from Stack Operations in section Abstract Data Types of Data Structures & Algorithms II had been asked this question in my homework.

Answer»

Correct choice is (d) -18

The best explanation: Postfix EXPRESSION is (6*(3-(2+4))) which RESULTS -18 as output.

64.

Which of the following is not the application of stack?(a) A parentheses balancing program(b) Tracking of local variables at run time(c) Compiler Syntax Analyzer(d) Data Transfer between two asynchronous processMy enquiry is from Stack Operations in section Abstract Data Types of Data Structures & Algorithms II got this question in homework.

Answer»

Right answer is (d) DATA TRANSFER between two asynchronous PROCESS

The EXPLANATION is: Data transfer between the two asynchronous process uses the queue data structure for SYNCHRONISATION. The rest are all stack applications.

65.

Entries in a stack are “ordered”. What is the meaning of this statement?(a) A collection of stacks is sortable(b) Stack entries may be compared with the ‘

Answer»

Correct answer is (d) There is a SEQUENTIAL entry that is one by one

Easy explanation - In stack DATA structure, ELEMENTS are ADDED one by one using push operation. Stack follows LIFO Principle i.e. Last In First Out(LIFO).

66.

Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________(a) Overflow(b) Crash(c) Underflow(d) User flowThis interesting question is from Stack Operations topic in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me during an interview for a job.

Answer»

Right answer is (a) OVERFLOW

For explanation: The stack is filled with 5 elements and pushing one more ELEMENT causes a stack overflow. This results in overwriting MEMORY, code and LOSS of unsaved work on the COMPUTER.

67.

In a stack, if a user tries to remove an element from an empty stack it is called _________(a) Underflow(b) Empty collection(c) Overflow(d) Garbage CollectionThe above asked question is from Stack Operations topic in section Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in a job interview.

Answer» RIGHT choice is (a) Underflow

The best I can EXPLAIN: Underflow occurs when the user performs a pop operation on an empty STACK. Overflow occurs when the stack is full and the user performs a PUSH operation. Garbage Collection is used to recover the MEMORY occupied by objects that are no longer used.
68.

Process of removing an element from stack is called __________(a) Create(b) Push(c) Evaluation(d) PopThe question is from Stack Operations topic in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me during an internship interview.

Answer» RIGHT answer is (d) Pop

For explanation: ELEMENTS in the stack are REMOVED USING pop operation. Pop operation removes the top most element in the stack i.e. last entered element.
69.

Process of inserting an element in stack is called ____________(a) Create(b) Push(c) Evaluation(d) PopI'm obligated to ask this question of Stack Operations in section Abstract Data Types of Data Structures & Algorithms IThe question was asked in an online quiz.

Answer» RIGHT option is (b) Push

The explanation is: Push OPERATION allows users to INSERT elements in the stack. If the stack is FILLED completely and trying to perform push operation stack – overflow can HAPPEN.
70.

Elements in an array are accessed _____________(a) randomly(b) sequentially(c) exponentially(d) logarithmicallyThis interesting question is from Array and Array Operations in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question in an internship interview.

Answer»

Correct ANSWER is (a) randomly

Easiest EXPLANATION - Elements in an ARRAY are accessed randomly. In Linked LISTS, elements are accessed sequentially.

71.

In general, the index of the first element in an array is __________(a) 0(b) -1(c) 2(d) 1Asked question is from Array and Array Operations in division Abstract Data Types of Data Structures & Algorithms II had been asked this question in semester exam.

Answer»

The CORRECT OPTION is (a) 0

Best explanation: In general, Array Indexing starts from 0. Thus, the INDEX of the FIRST ELEMENT in an array is 0.

72.

Assuming int is of 4bytes, what is the size of int arr[15];?(a) 15(b) 19(c) 11(d) 60The above asked question is from Array and Array Operations topic in chapter Abstract Data Types of Data Structures & Algorithms IThe question was posed to me by my college professor while I was bunking the class.

Answer» RIGHT CHOICE is (d) 60

Best explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 = 60bytes.
73.

What are the disadvantages of arrays?(a) Data structure like queue or stack cannot be implemented(b) There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size(c) Index value of an array can be negative(d) Elements are sequentially accessedThe origin of the question is Array and Array Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked during a job interview.

Answer»

Right choice is (b) There are chances of wastage of memory space if elements INSERTED in an ARRAY are lesser than the allocated SIZE

To explain: ARRAYS are of fixed size. If we insert elements less than the allocated size, unoccupied positions can’t be used again. Wastage will occur in memory.

74.

What are the advantages of arrays?(a) Objects of mixed data types can be stored(b) Elements in an array cannot be sorted(c) Index of first element of an array is 1(d) Easier to store elements of same data typeQuery is from Array and Array Operations topic in section Abstract Data Types of Data Structures & Algorithms II got this question in examination.

Answer»

Correct answer is (d) EASIER to STORE elements of same data type

Easy explanation - ARRAYS store elements of the same data type and present in continuous memory locations.

75.

Which of the following concepts make extensive use of arrays?(a) Binary trees(b) Scheduling of processes(c) Caching(d) Spatial localityEnquiry is from Array and Array Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in exam.

Answer»

Correct answer is (d) SPATIAL locality

Easiest explanation - Whenever a particular memory location is referred to, it is likely that the locations NEARBY are also referred, ARRAYS are stored as contiguous blocks in memory, so if you want to access array ELEMENTS, spatial locality makes it to access quickly.

76.

When does the ArrayIndexOutOfBoundsException occur?(a) Compile-time(b) Run-time(c) Not an error(d) Not an exception at allEnquiry is from Array and Array Operations in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked by my school principal while I was bunking the class.

Answer»

The correct ANSWER is (B) Run-time

Easy EXPLANATION - ArrayIndexOutOfBoundsException is a run-time exception and the COMPILATION is error-free.

77.

Which of the following is the correct way to declare a multidimensional array in Java?(a) int[] arr;(b) int arr[[]];(c) int[][]arr;(d) int[[]] arr;This intriguing question originated from Array and Array Operations in portion Abstract Data Types of Data Structures & Algorithms II got this question in examination.

Answer»

The correct choice is (C) int[][]arr;

To explain: The syntax to DECLARE multidimensional ARRAY in java is EITHER int[][] arr; or int arr[][];

78.

How do you instantiate an array in Java?(a) int arr[] = new int(3);(b) int arr[];(c) int arr[] = new int[3];(d) int arr() = new int(3);This intriguing question comes from Array and Array Operations in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me at a job interview.

Answer» CORRECT ANSWER is (c) int ARR[] = NEW int[3];

For explanation: Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to instantiate an array.
79.

How do you initialize an array in C?(a) int arr[3] = (1,2,3);(b) int arr(3) = {1,2,3};(c) int arr[3] = {1,2,3};(d) int arr(3) = (1,2,3);Origin of the question is Array and Array Operations in chapter Abstract Data Types of Data Structures & Algorithms IThe question was posed to me by my college director while I was bunking the class.

Answer» RIGHT answer is (C) int arr[3] = {1,2,3};

EXPLANATION: This is the SYNTAX to initialize an ARRAY in C.
80.

Which of these best describes an array?(a) A data structure that shows a hierarchical behavior(b) Container of objects of similar types(c) Arrays are immutable once initialised(d) Array is not a data structureMy question is based upon Array and Array Operations topic in chapter Abstract Data Types of Data Structures & Algorithms IThe question was asked in an international level competition.

Answer»

Right answer is (b) CONTAINER of objects of SIMILAR types

The EXPLANATION is: ARRAY contains elements only of the same type.

81.

You have two jars, one jar which has 10 rings and the other has none. They are placed one above the other. You want to remove the last ring in the jar. And the second jar is weak and cannot be used to store rings for a long time.(a) Empty the first jar by removing it one by one from the first jar and placing it into the second jar(b) Empty the first jar by removing it one by one from the first jar and placing it into the second jar and empty the second jar by placing all the rings into the first jar one by one(c) There exists no possible way to do this(d) Break the jar and remove the last oneWant answer with solution....

Answer»

Correct option: (b) EMPTY the FIRST jar by removing it one by one from the first jar and placing it into the SECOND jar and empty the second jar by placing all the rings into the first jar one by one

This is similar to performing dequeue OPERATION using push and pop only. Elements in the first jar are taken out and placed in the second jar. After removing the last element from the first jar, remove all the elements in the second jar and PLACE them in the first jar.

82.

What does ‘stack underflow’ refer to?(a) accessing item from an undefined stack(b) adding items to a full stack(c) removing items from an empty stack(d) index out of bounds exceptionWhat is the answer? Thanks in advance

Answer» CORRECT answer is (c) REMOVING items from an EMPTY STACK

The best explanation: Removing items from an empty stack is termed as stack UNDERFLOW.
83.

Assume that the operators +,-, X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is?(a) abc X+ def ^^ –(b) abc X+ de^f^ –(c) ab+c Xd – e ^f^(d) -+aXbc^ ^defPlease solve with an explanation.

Answer»

Correct option is (b) abc X+ de^F^ –

Easy explanation - GIVEN Infix Expression is a + b X c – d ^ e ^ f.

(a b c X +) (d ^ e ^ f). ‘–‘ is present in STACK.

(a b c X + d e ^ f ^ -). Thus the final expression is (a b c X + d e ^ f ^ -).

84.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?(a) 1(b) 2(c) 3(d) 4Please solve the problem as soon as possible.

Answer»

Correct answer is (B) 2

Easy explanation - In the entire parenthesis balancing method when the INCOMING token is a left parenthesis it is pushed into stack. A right parenthesis makes POP operation to DELETE the elements in stack till we get left parenthesis as top most element. 2 left parenthesis are pushed whereas ONE right parenthesis removes one of left parenthesis. 2 elements are there before right parenthesis which is the maximum number of elements in stack at run time.

85.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?(a) 1(b) 2(c) 3(d) 4 or moreIt is really nice to ask questions here. Thank you

Answer»

The correct answer is (c) 3

Easiest explanation - In the entire parenthesis BALANCING method when the incoming token is a left parenthesis it is PUSHED into stack. A right parenthesis makes pop operation to delete the elements in stack till we get left parenthesis as top most element. 3 elements are there in stack before right PARENTHESES comes. THEREFORE, MAXIMUM number of elements in stack at run time is 3.