Data Structure Quiz 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the time complexity of enqueue operation?

O(1) Explanation: Enqueue operation is at the rear end, it takes O(1) time to insert a new item into the queue.

What is the time complexity of pop() operation when the stack is implemented using an array?

O(1) Explanation: pop() accesses only one end of the structure, and hence constant time.

Pushing an element into stack already having five elements and stack size of 5, then stack becomes

Overflow

Process of removing an element from stack is called

Pod

The type of expression in which operator succeeds its operands is?

Postfix Expression

To obtain a prefix expression, which of the tree traversals is used?

Pre-order traversal Explanation: As the name itself suggests, pre-order traversal can be used.

Process of inserting an element in stack is called

Push

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a ?

Queue

Which of the following statement(s) about stack data structure is/are NOT correct?

Stack is the FIFO data structure Explanation: Stack follows LIFO.

Convert the following infix expressions into its equivalent postfix expressions (A + B ⋀D)/(E - F)+G

(A B D ⋀ + E F - / G +) Explanation: Applying the postfix expression evaluation.

The prefix form of an infix expression p + q - r * t is?

- +pq * rt Explanation: Applying the prefix expression evaluation.

The prefix form of A-B/ (C * D ^ E) is?

-A/B*C^DE Explanation: Applying the prefix expression evaluation.

Consider the following operation performed on a stack of size 5. Push(1); Pop(); Push(2); Push(3); Pop(); Push(4); Pop(); Pop(); Push(5); After the completion of all operation, the number of elements present in stack are

1

Which of the following applications may use a stack?

1.A parentheses balancing program 2.Tracking of local variables at run time 3.Compiler Syntax Analyzer (Explanation: All are applications of stack)

Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

3 (Explanation: Below is algorithm for Postfix to Infix. 1.While there are input symbol left ...1.1 Read the next symbol from the input. 2.If the symbol is an operand ...2.1 Push it onto the stack. 3.Otherwise, ...3.1 the symbol is an operator. ...3.2 Pop the top 2 values from the stack. ...3.3 Put the operator, with the values as arguments and form a string. ...3.4 Push the resulted string back to stack. 4.If there is only one value in the stack ...4.1 That value in the stack is the desired infix string. )

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

350

What is a complete binary tree?

A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right

The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

AB + CD* E - *F *G / Explanation: Applying the postfix expression evaluation.

The postfix form of A*B+C/D is?

AB*CD/+ Explanation: Applying the postfix expression evaluation.

If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed?

ABCD Explanation: Queue follows FIFO approach.

If the elements "A", "B", "C" and "D" are placed in a stack and are deleted one at a time, what is the order of removal?

DCBA Explanation: Stack follows LIFO(Last In First Out).

The number of edges from the root to the node is called __________ of the tree.

Depth

A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is?

Dequeue

What is a full binary tree?

Each node has exactly zero or two children

What happens when you pop from an empty stack while implementing using the Stack ADT in Java?

EmptyStackException is thrown Explanation: The Stack ADT throws an EmptyStackException if the stack is empty and a pop() operation is tried on it.

A queue is a ?

FIFO (First In First Out) list

Which of the following properties is associated with a queue?

First In First Out Explanation: Queue follows First In First Out structure.

The number of edges from the node to the deepest leaf is called _________ of the tree.

Height

In a binary search tree, which of the following traversals would print the numbers in the ascending order?

In-order traversal Explanation: In a binary search tree, a node's left child is always lesser than the node and right child is greater than the node, hence an in-order traversal would print them in a non-decreasing fashion.

Which of the following is not an inherent application of stack?

Job scheduling Explanation: Job Scheduling is not performed using stacks.

In a full binary tree if number of internal nodes is I, then number of leaves L are?

L = I + 1 Explanation: Trace with respect to the diagram.

In a full binary tree if number of internal nodes is I, then number of nodes N are?

N = 2I + 1 Explanation: Trace with respect to the diagram.

In a full binary tree if there are L leaves, then total number of nodes N are?

N = 2L - 1 Explanation: Trace with respect to the diagram.

What is the value of the postfix expression 6 3 2 4 +-*:

None of the above (Explanation: On solving the postfix expression the answer comes out to -18. 6 3 2 4 + - * 6 3 (2 + 4) - * 6 3 (6) 6 (3 - 6) * 6(-3) 6 * (-3) = -18

A normal queue, if implemented using an array of size MAX_SIZE, gets full when

Rear = MAX_SIZE - 1 Explanation: Condition for size of queue.

Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N).

S[N-1]. Explanation: Array indexing start from 0, hence N-1 is the last index.

Queues serve major role in

Simulation of limited resource allocation. Explanation: Rest all are implemented using other data structures.

Which of the following is not the type of queue?

Single ended queue Explanation: Queue always has two ends.

The data structure required to check whether an expression contains balanced parenthesis is?

Stack

The process of accessing data stored in a serial access memory is similar to manipulating data on a ________

Stack

What data structure would you mostly likely see in a non-recursive implementation of a recursive algorithm?

Stack

Which data structure is needed to convert infix notation to postfix notation?

Stack

Which data structure is used for implementing recursion?

Stack Explanation: Stacks are used for implementation of Recursion.

Entries in a stack are "ordered". What is the meaning of this statement?

There is a Sequential entry that is one by one

In a stack, if a user tries to remove an element from empty stack it is called

Underflow

Which of the following is not an advantage of trees?

Undo/Redo operations in a notepad Explanation: This is an application of stack.

What is the result of the following operation Top (Push (S, X))

X

What is the term for inserting into a full queue known as?

overflow Explanation: Just as stack, inserting into a full queue is termed overflow.

Which of the following real-world scenarios would you associate with a stack data structure?

piling up of chairs one above the other Explanation: Stack follows Last In First Out(LIFO) policy. Piling up of chairs one above the other is based on LIFO, people standing in a line is a queue and if the service is based on priority, then it can be associated with a priority queue.

What does 'stack underflow' refer to?

removing items from an empty stack Explanation: Removing items from an empty stack is termed as stack underflow.

'Array implementation of Stack is not dynamic', which of the following statements supports this argument?

space allocation for array is fixed and cannot be changed during run-time Explanation: You cannot modify the size of an array once the memory has been allocated, adding fewer elements than the array size would cause wastage of space, and adding more elements than the array size at run time would cause Stack Overflow.


संबंधित स्टडी सेट्स

Sem 3 - Unit 4: Perfusion (HF, MI, Cardiac Dysrh, Fetal Monitoring) TB

View Set

Chapter 51: Assessment and Management of Patients With Diabetes

View Set

SALT Final, R1 M3, Chapter 1, Chapter 23: State and local taxes, ACCT 4400 - SALT #2 Apportionment, Multijurisdictional Tax Issues, Uses of Local/State Taxes, ACCT 570 - Ch 12: State & Local Taxes, 4400, Multi-Jurisdictional Tax, State and Local Taxa...

View Set

Module 9 Quiz (MGBU 371): National Text Chapter 8 & 9 + MD Chapter 2 & 6

View Set

Chapter 2 Study Guide and Review

View Set

FNP Pediatric Exam Practice Questions

View Set

Standard Steps for all Nursing Procedures

View Set

DECA Hospitality and Tourism Cluster - Performance Indicators (DETAILED)

View Set

AP Comparative Government - Iran

View Set