Self Studies

Computer Science Test - 11

Result Self Studies

Computer Science Test - 11
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

If our Website helped you a little, then kindly spread our voice using Social Networks. Spread our word to your readers, friends, teachers, students & all those close ones who deserve to know what you know now.

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    5 / -1
    In stack, memory allocation and deallocation is performed in ________.
    Solution

    The correct answer is option 1.

    Concept:

    A stack is a linear data type that acts as a collection of elements. A stack is a linear data structure that operates memory allocation and deallocation on the Last-In-First-Out (LIFO) principle. In linear data structures, the elements are accessed in sequential order but it is not compulsory to store all elements sequentially. It has two main operations:

    • Push, which adds a new element to the collection, and
    • Pop, which removes the most recently added element that hasn't been removed yet.

    Hence the correct answer is Last­-in-­first­-out (LIFO) manner.

    Additional Information

    Stack applications:

    • Balancing of symbols.
    • Infix to postfix conversion.
    • Evaluation of postfix expression.
    • Implementing function calls.
    • Finding of spans in stock markets.
    • Page-visited history in a web browser.
    • Undo sequence in the text editor.
    • Matching tags in Html and xml.
  • Question 2
    5 / -1
    Which of the following data structures is most suitable for evaluating postfix expressions? 
    Solution

    Stack data structure is suitable for evaluating postfix expression. 

    Stack : Stack is a linear data structure in which elements are inserted and deleted from one end only i.e. top of the stack. It follows a order to insert the elements into stack which is known as LIFO (Last in first out). Operations that are performed on a stack are : Push , Pop and peek.

    Applications of stack :

    • Stack can be used for evaluating arithmetic expression.(Postfix, prefix evaluation).
    • It can be used for conversion from one expression to another.
    • It can be used to check matching parenthesis in any expression.
    • It can be used for memory management.
    • It can undo the operation of a document editor or similar environment.
    • It is used for backtracking.
    • It keeps track of page visiting history  of a web user.
    • It is used in the implementation of recursive procedures.

     

    Evaluation rule of postfix expression :

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

    2) Pop the two operands from the stack, if the element is an operator and evaluate it.

    3) Push back the result of evaluation. Repeat till the end of expression.

  • Question 3
    5 / -1

    Which of the following applications may use a stack?

    (a) Parenthesis balancing program

    (b) Process scheduling operating system

    (c) Conversion of infix arithmetic expression to postfix form
    Solution

    Stack:

    • Stack is a data structure which possesses the LIFO property i.e. last in first out. The element which inserted at the last will come out first from the stack.
    • Two operations that can be performed on the stack are Push and Pop.
    • Push is used to insert element into the stack and pop operation is used to remove element from the top of the stack.


    Applications of stack:

    1) Expression conversion such as infix to postfix, infix to prefix.

    2) Expression evaluation

    3) Parsing well-formed parenthesis

    4) Decimal to binary conversion

    5) Reversing a string

    6) Storing function calls

    Note:

    Queue data structure is used for process scheduling operating system. 

  • Question 4
    5 / -1

    What is the postfix representation of the following infix expression?

    (A + B) * C – D * E / F
    Solution

    Concept:

    () has highest precedence

    * and / has same precedence while + and – has same precedence

    (* and /) and higher precedence than (+, -)

    Associativity is left to right:

    Explanation:

    (A + B) * C – D * E / F

    A B + * C – D * E / F

    A B + C * – D * E / F

    A B + C * D E * / F

    A B + C * D E * F /

    A B + C * D E * F / –

  • Question 5
    5 / -1

    A is an empty stack. The following operations are done on it.

    PUSH(1)

    PUSH(2)

    POP

    PUSH(5)

    PUSH(6)

    POP

    What will the stack contain after these operations?

    Solution

    Key Points   Stack is a simple linear data structure that is used for storing data. In stack, the order in which the data arrives is the most important. Considering this, a stack can be defined as an ordered list in which insertion and deletion are performed at one end which is called top.

    The element inserted at the last is the first one to be deleted. Hence, a stack is called First In Last Out (FILO) or Last In First Out (LIFO) list.

    Mainly the following three basic operations are performed in the stack:

    Push: Push operation adds an item/data into the stack. If the stack is full, then it is called an Overflow condition.

    Pop: Pop operation removes an item/data from the stack. The items are popped in the reversed order in which they are pushed into the stack. If the stack is

    empty, then it is called an Underflow condition.

    So the poped elements are 1,5

    Hence the correct answer is 1,5.

    Additional InformationApplications of the stack:

    • Balancing of symbols.
    • Infix to Postfix /Prefix conversion.
    • Implementing function calls (recursion).
    • Undo sequence in a text editor.
    • Forward and backward features in web browsers.
    • Other applications can be Backtracking, a Knight tour problem, a rat in a maze, an N-queen problem, and a sudoku solver.

     

  • Question 6
    5 / -1

    Carefully observe the below given stack with stack pointer pointing to element 2.

    2

    4

    1

    7

    5

    9

     

    How many pop operations are needed to delete the smallest element from the stack?
    Solution

    The stack pointer is pointing at top of the stack, that is, to element 2

    After 1st pop:

    4

    1

    7

    5

    9

     

    2 is deleted

    After 2nd pop:

    1

    7

    5

    9

     

    4 is deleted

    After 3rd pop

    7

    5

    9

     

    1 is deleted

    Therefore, the number of pop operation performed is 3
  • Question 7
    5 / -1

    Which is the prefix of the below given expression:

    A – B + C / (D – E) * F
    Solution

    A – B + C / (D – E) * F

    A – B + C / –DE * F     //bracket has highest precedence

    A – B + /C–DE * F      //associativity of * and / is left to right with same precedence

    A – B + */C–DEF

    –AB + */C–DEF     //associativity of + and – is left to right with same precedence

    +–AB*/C–DEF

    Therefore answer 4 is correct.

  • Question 8
    5 / -1

    Consider the following postfix expression with single digit operands:

    6 2 3 * / 4 2 * + 6 8 * -

    The top two elements of the stack after second * is evaluated, are:

    Solution

    Postfix expression: 6 2 3 * / 4 2 * + 6 8 * -

  • Question 9
    5 / -1

    The following sequence of operations is performed on a stack:

    PUSH(50), PUSH(60), PUSH(70), POP, POP, PUSH(80), PUSH(90), PUSH(100), PUSH(110), POP, PUSH(120) PUSH(130), POP, POP, PUSH(140), POP

    The sequence of values popped out is:
    Solution

    PUSH: 50, 60, 70

    50

    60

    70

    POP: 70 and POP: 60

    50

     

     

     

    PUSH: 80, 90, 100,110

    50

    80

    90

    100

    110

    POP: 110

    50

    80

    90

    100

     

    PUSH: 120, 130

    50

    80

    90

    100

    120

    130

    POP: 130 and POP 120

    50

    80

    90

    100

     

    PUSH: 140

    50

    80

    90

    100

    140

    POP: 140

    50

    80

    90

    100

     

    PUSH(50), PUSH(60) (2), PUSH(70) (1), POP, POP, PUSH(80), PUSH(90), PUSH(100), PUSH(110) (3), POP, PUSH(120) PUSH(130)(4), POP, POP, PUSH(140), POP

  • Question 10
    5 / -1
    Identify the wrong output stack permutation for the Input sequence in 1, 2, 3, 4, 5 and pop can occur at any time in stack.
    Solution

    for a)

    for b)

    So, 2 3 5 4 1

    for c)

    so, 4 3 5 2 1

    for d)

    So, the permutation 3, 4, 1, 5, 2 is invalid

Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Self Studies Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Self Studies
Click on Allow to receive notifications
Allow Notification
Self Studies
Self Studies Self Studies
To enable notifications follow this 2 steps:
  • First Click on Secure Icon Self Studies
  • Second click on the toggle icon
Allow Notification
Get latest Exam Updates & FREE Study Material Alerts!
Self Studies ×
Open Now