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 9213891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:51:15+00:00 2026-06-18T01:51:15+00:00

The method in JavaScript is: findNode: function(root, w, h) { if (root.used) return this.findNode(root.right,

  • 0

The method in JavaScript is:

findNode: function(root, w, h) {
    if (root.used)
        return this.findNode(root.right, w, h) || this.findNode(root.down, w, h);
    else if ((w <= root.w) && (h <= root.h))
        return root;
    else
        return null;
}

this line in particular wont work in C#

return this.findNode(root.right, w, h) || this.findNode(root.down, w, h);

This is my attempt at translating it but I could use a second opinion as to whether this will work or break the algorithm. Is there a better way that I’m missing?

private Node FindNode(Node node, Block block)
{
    Node n;
    if (node.used) // recursive case
    {

        // is this a good translation of the JavaScript one-liner?

        n = FindNode(node.right, block);
        if (n != null)
        {
            return n;
        }
        else
        {
            return FindNode(node.down, block);
        }
    }
    else if ((block.width <= node.width) && (block.height <= node.height)) // Base case
    {
        return node;
    }
    else
    {
        return null;
    }
}

Here is the original algorithm I’m working off of.

  • 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-18T01:51:16+00:00Added an answer on June 18, 2026 at 1:51 am
    n = FindNode(node.right, block);
    return n ?? FindNode(node.down, block);  
    

    would be the only change I would make

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

Sidebar

Related Questions

I have this javascript method that needs to run in the background window.setInterval(function(){ validateCaseStatus();
How on earth I get this Javascript method $('#principal_uid').change(function() { if($(this).val().length > 0){ window.location.href
I have this javascript method: <script type=text/javascript> function MyFunction(sender, eventArgs) { if (someCondition) {
null return by getElementById method in JavaScript <html> <head> <title>test_elementObject</title> <script language=JavaScript type=text/javascript> <!--
This is my javascript method in .aspx file. I want to invoke this method
I have a javascript method looks like this JSMethod(JS_para_1,JS_para_2) { ...... ,,,,, } and
I have the following javascript method: function 123_test_function(){ } The function is generated by
Whenever I use the splice method in Javascript like so: Array.prototype.mymethod = function() {
I have a JavaScript method that call JQuery.get() and i want to return value
I have JavaScript method which acts when a particular class (mcb) of forms are

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.