Sign Up

Have an account? Sign In Now

Sign In

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

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

SIKSHAPATH

SIKSHAPATH Logo SIKSHAPATH Logo

SIKSHAPATH Navigation

  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
  • About
    1. Asked: October 16, 2021In: Programming Language

      Create two threads, one thread to display all even numbers between 1 & 20, another to display odd numbers between 1 & 20. Note: Display all even numbers followed by odd numbers Hint: use join

      Professor
      Professor
      Added an answer on October 16, 2021 at 10:03 am

      public class Main { public static void main(String[] args) { Runnable r = new Runnable1(); Thread t = new Thread(r); t.start(); Runnable r2 = new Runnable2(); Thread t2 = new Thread(r2); t2.start(); } } class Runnable2 implements Runnable{ public void run(){ for(int i=1;i<=20;i++){ if(i%2 == 1) SRead more

      public class Main {

      public static void main(String[] args) {
      Runnable r = new Runnable1();
      Thread t = new Thread(r);
      t.start();
      Runnable r2 = new Runnable2();
      Thread t2 = new Thread(r2);
      t2.start();
      }
      }

      class Runnable2 implements Runnable{
      public void run(){
      for(int i=1;i<=20;i++){
      if(i%2 == 1)
      System.out.println(i);
      }
      }
      }

      class Runnable1 implements Runnable{
      public void run(){
      for(int i=1;i<=20;i++){
      if(i%2 == 0)
      System.out.println(i);
      }
      }
      }

      See less
        • 0
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
    2. Asked: October 14, 2021In: Data Structure

      Write a program to convert the expression “a+b” into “ab+”.

      Professor
      Professor
      Added an answer on October 14, 2021 at 5:58 am
      This answer was edited.

      /* C++ implementation to convertinfix expression to postfix*/#include<bits/stdc++.h>using namespace std;//Function to return precedence of operatorsint prec(char c) {if(c == '^')return 3;else if(c == '/' || c=='*')return 2;else if(c == '+' || c == '-')return 1;elsereturn -1;}// The main functiRead more

      /* C++ implementation to convert
      infix expression to postfix*/

      #include<bits/stdc++.h>
      using namespace std;

      //Function to return precedence of operators
      int prec(char c) {
      if(c == '^')
      return 3;
      else if(c == '/' || c=='*')
      return 2;
      else if(c == '+' || c == '-')
      return 1;
      else
      return -1;
      }

      // The main function to convert infix expression
      //to postfix expression
      void infixToPostfix(string s) {

      stack<char> st; //For stack operations, we are using C++ built in stack
      string result;

      for(int i = 0; i < s.length(); i++) {
      char c = s[i];

      // If the scanned character is
      // an operand, add it to output string.
      if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
      result += c;

      // If the scanned character is an
      // ‘(‘, push it to the stack.
      else if(c == '(')
      st.push('(');

      // If the scanned character is an ‘)’,
      // pop and to output string from the stack
      // until an ‘(‘ is encountered.
      else if(c == ')') {
      while(st.top() != '(')
      {
      result += st.top();
      st.pop();
      }
      st.pop();
      }

      //If an operator is scanned
      else {
      while(!st.empty() && prec(s[i]) <= prec(st.top())) {
      result += st.top();
      st.pop();
      }
      st.push(c);
      }
      }

      // Pop all the remaining elements from the stack
      while(!st.empty()) {
      result += st.top();
      st.pop();
      }

      cout << result << endl;
      }

      //Driver program to test above functions
      int main() {
      string exp = "a+b";
      infixToPostfix(exp);
      return 0;
      }
      See less
        • 0
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
    1 … 24 25 26

    Sidebar

    store ads

    Stats

    • Questions 1k
    • Answers 1k
    • Posts 149
    • Best Answers 89
    • This Free AI Tool Translates Entire Books in Minute !
    • AI News: 🎬 Hollywood’s AI Studios, 🎓 OpenAI’s Latest Gift to Educators, 🚚 Class8 Bags $22M, 🧠 Google Gemini’s Memory Upgrade
    • AI NEWS: Legal Action Against OpenAI, $16M Paid, & Elon Musk’s Praise from Investor 🤖💰📑 | AI Boosts Cloud Seeding for Water Security 🌱💧
    • AI News: 🎬AI Video Tool Scam Exposed🤯, 🛰️ AI-Powered Drones to Ukraine 😱, Google’s $20M AI Push, Sam Altman Joins SF’s Leadership Team
    • AI News: 🤝 Biden Meets Xi on AI Talks, 💡 Xavier Niel’s Advice for Europe, ♻️ Hong Kong’s Smart Bin Revolution, 🚀 AI x Huawei

    Explore

    • Recent Questions
    • Questions For You
    • Answers With Time
    • Most Visited
    • New Questions
    • Recent Questions With Time

    Footer

    SIKSHAPATH

    Helpful Links

    • Contact
    • Disclaimer
    • Privacy Policy Notice
    • TERMS OF USE
    • FAQs
    • Refund/Cancellation Policy
    • Delivery Policy for Sikshapath

    Follow Us

    © 2021-24 Sikshapath. All Rights Reserved