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

  • SEARCH
  • Home
  • 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 4110298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:54:58+00:00 2026-05-20T21:54:58+00:00

Say I have the following: bool signal(QtreeNode * & orig, QtreeNode * & n,

  • 0

Say I have the following:

bool signal(QtreeNode * & orig, QtreeNode * & n, int tolerance) {

    bool signal1= false, signal2= false, signal3= false, signal4= false;
    if(n->isLeaf()){
        if(totalDiff>tolerance) //suppose these were defined
            return true;
        else return false;
    }
    signal1=signal(orig, n->neChild, tolerance); 
    signal2=signal(orig, n->nwChild, tolerance);
    signal3=signal(orig, n->swChild, tolerance);
    signal4=signal(orig, n->seChild, tolerance);

    if(signal1 || signal2 || signal3 || signal4)
        return true;
    else return false;
}

And say I call that method from some wrapper method like this:

signal1=signal(orig, n, tolerance);
    if(signal1)
        //do something

So what I’m doing here is traversing an entire quad-tree looking for just one case where I get true. All I need for this function to do is to return true in one case where totalDiff is greater than tolerance. I’m afraid that what I have isn’t doing what I hoped it would do. Looking at function, does it seem like, when I set signal1 in my wrapper method, that I will get true back if it finds just 1 case of that condition? Or am I doing it wrong?

  • 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-05-20T21:54:58+00:00Added an answer on May 20, 2026 at 9:54 pm

    You’ll hit every leaf in your quadtree this way. Instead you want to break as soon as you’ve found it. To do that you need to change

    signal1=signal(orig, n->neChild, tolerance); 
    signal2=signal(orig, n->nwChild, tolerance);
    signal3=signal(orig, n->swChild, tolerance);
    signal4=signal(orig, n->seChild, tolerance);
    
    if(signal1 || signal2 || signal3 || signal4)
        return true;
    else return false;
    

    to

    return signal(orig, n->neChild, tolerance) || 
           signal(orig, n->nwChild, tolerance) ||
           signal(orig, n->swChild, tolerance) ||
           signal(orig, n->seChild, tolerance);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following function: bool foo (int a); // This method declaration
Say I have the following code: public static Client Connect(string hostname, int port, bool
Say I have the following data IEnumerable<IEnumerable<int>> items = new IEnumerable<int>[] { new int[]
I have the following situation bool user_set_flag; getFlagFromUser(&user_set_flag); while(1){ if(user_set_flag){ //do some computation and
Let's say I have the following class: class MyClass { private: int Data; public:
Say I have the following code snippet in c# static const bool DO_PERFORMANCE_CODE =
Lets say we have following models. class User(db.Model): username=db.StringProperty() avatar=db.ReferenceProperty() class User(db.Model): username=db.StringProperty() avatar=db.StringProperty()
Let's say I have following table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
Let's say we have following this: <p class=first>This is paragraph 1.</p> <p class=second>This is
Let's say we have following code: struct A{ virtual ~A(){} void f(){ p =

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.