Quadtrees in Data Structure

Arnab Chakraborty
Updated on 08-Jan-2020 10:21:11

4K+ Views

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

Why Continue Statements Are Bad in JavaScript

Sravani S
Updated on 08-Jan-2020 10:20:39

752 Views

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

Range Trees in Data Structure

Arnab Chakraborty
Updated on 08-Jan-2020 10:20:27

4K+ Views

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

What is Onclick Event in JavaScript

vanithasree
Updated on 08-Jan-2020 10:19:53

597 Views

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 in C++

AmitDiwan
Updated on 08-Jan-2020 10:15:49

6K+ Views

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

Halfedge Data Structure

Arnab Chakraborty
Updated on 08-Jan-2020 10:13:08

757 Views

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

Best Way to Compare Two Strings in JavaScript

Fendadis John
Updated on 08-Jan-2020 09:40:36

11K+ Views

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;          }          

What are Label Statements in JavaScript

karthikeya Boyini
Updated on 08-Jan-2020 09:16:48

4K+ Views

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

Use Nested While Loop in JavaScript

Swarali Sree
Updated on 08-Jan-2020 09:15:17

2K+ Views

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!");          

Use Break Statement to Exit Loop in JavaScript

karthikeya Boyini
Updated on 08-Jan-2020 08:34:34

207 Views

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! ");          

Advertisements