Quadtrees are trees implemented to efficiently store data of points on a two-dimensional space. In this tree, each node has maximum four children.We can build a quadtree from a two-dimensional area implementing the following stepsThe current two dimensional space is divided into four boxes.If a box consists of one or more points in it, build a child object, storing in it the two dimensional space of the box.If a box does not contain any points, do not build a child for it.Perform recursion for each of the children.Quadtrees are implemented in image compression, where each node consists of the average ... Read More
The usage of “continue” statement makes the code difficult to understand. In most cases, the usage of continue would mean you have an insufficient condition in your loop. To avoid this, you can add it to the condition itself or use if in a loop.But, “continue” is bad if it is used inconsistently or improperly, else it is a useful statement and saves a lot of memory and lines of code.ExampleLet’s see an example of continue statementLive Demo var x = 1; document.write("Entering the loop "); ... Read More
A range tree is defined as an ordered tree data structure to hold a list of points. It permits all points within a given range to be efficiently retrieved, and is typically implemented in two or higher dimensions. It is same to a kd-tree except with faster query times of O(logd n + k) but worse storage of O(n logd-1 n), with d indicating the dimension of the space, n indicating the number of points in the tree, and k indicating the number of points retrieved for a given query. Range trees may be differentiated with interval trees: instead of ... Read More
The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse.ExampleYou can put your validation, warning etc., against this event type.Live Demo Click the following button and see result
Pascal’s triangle is an array of binomial coefficients. The top row is numbered as n=0, and in each row are numbered from the left beginning with k = 0. Each number is found by adding two numbers which are residing in the previous row and exactly top of the current cell. It is also being formed by finding (𝑛𝑘) for row number n and column number k.Suppose the input is 10, then the output will be like − 1 1 1 ... Read More
IntroductionA HDS for template parameters or halfedge data structure (abbreviated as HalfedgeDS) is defined as an edge-centered data structure capable of maintaining incidence information of vertices, edges and faces, such as for planar maps, polyhedra, or other orientable, two-dimensional surfaces embedded in random dimension. Each edge is broken into two halfedges with opposite orientations. Each halfedge stores one incident face and one incident vertex. One incident halfedge is stored for each face and each vertex. Reduced variants of the halfedge data structure can eliminate some of this information, such as the halfedge pointers in faces or the storage of faces ... Read More
To compare two strings in JavaScript, use the localeCompare() method. The method returns 0 if both the strings are equal, -1 if string 1 is sorted before string 2 and 1 if string 2 is sorted before string 1.ExampleYou can try to run the following code to compare two stringsLive Demo Compare Strings function compareStr() { var string1 = "World"; var string2 = "World"; var result = string1.localeCompare(string2); document.getElementById("test").innerHTML = result; }
JavaScript label statements are used to prefix a label to an identifier. A label can be used with break and continue statement to control the flow more precisely. A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code. We will see two different examples to understand how to use labels with break and continue.ExampleYou can try to run the following code to use labels to control the flow, with break statementLive Demo document.write("Entering the loop! "); ... Read More
The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.ExampleYou can try to run the following code to learn how to use nested while loopLive Demo var height = 2; var width = 8; var col = 0; var row = 0; document.write("Starting Loop "); while (row < height) { col = 0; while(col < width) { document.write("#"); col++; } document.write(""); row++; } document.write("Loop stopped!");
The break statement is used to exit a loop early, breaking out of the enclosing curly braces.ExampleYou can try to run the following code to learn how to use the break statement to come out of a loopLive Demo var x = 1; document.write("Entering the loop "); while (x < 20) { if (x == 5) { break; // breaks out of loop completely } x = x + 1; document.write( x + ""); } document.write("Exiting the loop! ");
 Data Structure
 Networking
 RDBMS
 Operating System
 Java
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP