Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:41:55+00:00 2026-06-10T18:41:55+00:00

I am looking for code wchich parses prefix expressions using recursion. Primarily in C++,

  • 0

I am looking for code wchich parses prefix expressions using recursion. Primarily in C++, but it can bee in other language, i will translate. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:41:57+00:00Added an answer on June 10, 2026 at 6:41 pm

    It’s really easy to do yourself (you just need a stack for the operators (and sometimes/optionally its first term)).

    But if you really don’t want to do much work, here’s a link:

    prefix notation string to int conversion

    If you need to use recursion, you basically use local variables in the function as individual elements in your stack.

    Eg. pseudo-C++ code follows:

    int naughtyglobalendindex = 0;
    int parse(string str) {
    
      if (/* str starts off with an integer */) return the integer;
    
      char operator;
      operator = ?? // you will need to get the first op here. Maybe sscanf(str,"%c",&operator) or similar
    
      // get first argument
      int first = parse(/* str with 1st operator removed */);
      // get 2nd integer argument
      int second = parse(/* str - get substring from naughtyglobalendindex to end*/)
    
      // return first operator second <- this is pseudocode
      // in effect you want a switch clause
      switch (operator) {
        case '+': return first + second;
        case '-': return first - second; // and so on
      }
    }
    

    You can convert the pseudocode to actual C++, and if you want, fix the global naughtyglobalendindex variable if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking at code which has the correct using statements declared but yet
I am looking for javascript code which will give me 1st date of the
I'm looking at some code which should be trivial -- but my math is
I am looking for a C/C++ code which can get icon for a given
I'm looking at some legacy code which has the following idiom: Map<String, Boolean> myMap
I am looking at an example which code is: class SimpleThread extends Thread {
I am currently looking at some code for PHP detection of mobiles, which is
I was looking at an authentication system which had this code: # prevents a
I'm looking for a free code profiler (performance profiler, not a memory profiler) which
I’m working on some expression tree code written by a colleague and am looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.