CLASS XII & X Exam (24.09.14) HelpDesk

[CLOSED]

Please ask your queries or doubts in the comments section.

Please allow 2-3 hours to reply.

Thank you and Best of luck!


Solution to Jitesh Khuttan's question on Converting Infix to Postfix notation (asked via WhatsApp)

There is an algorithm to convert an infix expression into a postfix expression. It uses a stack; but in this case, the stack is used to hold operators rather than numbers. The purpose of the stack is to reverse the order of the operators in the expression. It also serves as a storage structure, since no operator can be printed until both of its operands have appeared.

In this algorithm, all operands are printed (or sent to output) when they are read. There are more complicated rules to handle operators and parentheses.
Example:

1. A * B + C becomes A B * C +

The order in which the operators appear is not reversed. When the '+' is read, it has lower precedence than the '*', so the '*' must be printed first.
We will show this in a table with three columns. The first will show the symbol currently being read. The second will show what is on the stack and the third will show the current contents of the postfix string. The stack will be written from left to right with the 'bottom' of the stack to the left.
Current SymbolOperator StackPostfix String
1AA
2**A
3B*A B
4++A B * (pop and print the '*' before pushing the '+')
5C+A B * C
6A B * C +
More>>

5 comments:

  1. How OOPS is focused on data? asked by Jitesh on WhatsApp
    Object-oriented programming (OOP) is programming primarily focused on data, while data and behavior are being inseparably linked. Data and behavior together constitute a class, while objects are class instances.
    Click Here to Visit mql4.com

    ReplyDelete
  2. What are namespaces? asked by Jitesh on WhatApp
    A namespace is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that’s normally not noticeable in any way (except for performance), and it may change in the future. Examples of namespaces are: the set of built-in names (containing functions such as abs(), and built-in exception names); the global names in a module; and the local names in a function invocation. In a sense the set of attributes of an object also form a namespace. The important thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two different modules may both define a function maximize without confusion — users of the modules must prefix it with the module name.

    More>>>

    ReplyDelete
  3. What is TypeError? asked by Jitesh on WhatsApp
    exception TypeError
    Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.


    Example: TypeError: __init__() takes exactly 2 arguments (1 given)
    The reason the error message says you are passing one argument is that self is passed implicitly. You need to also pass the second argument (npcId).

    ReplyDelete
  4. What is Ethernet? asked by Ravneet Kaur via WhatsApp (Class X)
    Ethernet is a family of computer networking technologies for local area (LAN) and larger networks.The primary alternative for contemporary LANs is not a wired standard, but instead a variety of IEEE 802.11 standards for wireless connection, also known as Wi-Fi. Wiki

    ReplyDelete
  5. Algorithm for Infix to Postfix conversion. asked by Jitesh Khuttan via WhatsApp
    Answer is given in the main post above.

    ReplyDelete