Radix sort is a sorting technique that sorts the elements based on every digit in every element (or number). Based on the ones place digit (which is also known as least significant digit) and tens place digit (which is also known as most significant digit), hundreds place digit, and so on, the elements are sorted.ExampleFollowing is an example for Radix Sort in Java − Live Demoimport java.util.*; public class my_radix_sorting { static int get_max_val(int my_arr[], int arr_len) { int max_val = my_arr[0]; for (int i = 1; i < arr_len; i++) ... Read More
As we know the stack works on the principle of Last in first out. At first, to insert into another stack you need to pop() all elements from the first stack and push into the second stack.Examplevar myFirstStack=[10, 20, 30, 40, 50, 60, 70]; var mySecondStack=[]; for(;myFirstStack.length;){ mySecondStack.push(myFirstStack.pop()); } console.log("After popping the all elements from the first stack="); console.log(myFirstStack); console.log("After pushing (inserting) all the elements into the second stack="); console.log(mySecondStack);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo189.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo189.js After popping ... Read More
For this, use regular expression with digit along with $.Examplevar groupValues1 = "10 10 10"; var groupValues2 = "10 10 10 10"; var groupValues3 = "10 10"; var regularExpression = /^(\d+)(\s)\1\2\1$/; var isValidGroup1 = regularExpression.test(groupValues1); var isValidGroup2 = regularExpression.test(groupValues2); var isValidGroup3 = regularExpression.test(groupValues3); if(isValidGroup1==true) console.log("This is a valid group="+groupValues1); else console.log("This is not a valid group="+groupValues1); if(isValidGroup2==true) console.log("This is a valid group="+groupValues2); else console.log("This is not a valid group="+groupValues2); if(isValidGroup3==true) console.log("This is a valid group="+groupValues3); else console.log("This is not a valid group="+groupValues3);To run the above program, you need to use the following command −node ... Read More
For this, use the concept of scrollTop and scrollHeight.Example Live Demo Document #scrollDemo { height: 300px; overflow-y: scroll; } #scrollDataFeatures { height: 500px; background-color: skyblue; } See the below Message and Scroll UP var scrollData = document.getElementById("scrollDemo"); scrollData.scrollTop = scrollData.scrollHeight setInterval(() =>{ var heading3Data = document.createElement("h3"); heading3Data.innerHTML = "Scroll Down...Please Scroll UP" scrollData.appendChild(heading3Data); scrollData.scrollTop ... Read More
Use children.length to get the count of child node.Example Live Demo Document List Of Subject Names are as follows: Javascript MySQL MongoDB Java Python var arrayValueOfSubject = document.getElementById('subjectName').parentNode; console.log("The count of child node is="+arrayValueOfSubject.children.length); To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode Editor.OutputThis will produce the following output −
For this, you can use .data(anyArrayObject). Following is the code −Example Live Demo Document const arrayValues = [1000000001,"John","Smith",100, 200, 3000] var originalData = d3.select("body").selectAll("p") .data(arrayValues) .enter() .append("p") .text(function(allValuesOfArray){ console.log(allValuesOfArray+" "); return allValuesOfArray; }) To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS Code editor.OutputThis will produce the following output −
Let’s say the following is our complicated string −var values = 'studentId:"100001",studentName:"John Smith",isTopper:true,uniqueId:10001J-10001,marks:78,newId:"4678"';You can use regular expression to match strings. Following is the code −Examplevar regularExpression = /(? node demo187.js Original Value=studentId:"100001",studentName:"John Smith",isTopper:true,uniqueId:10001J-10001,marks:78,newId:"4678" The string that are not entirely digits= [ '10001J-10001' ]
For this, use jQuery() with id property. Following is the code −Example Live Demo Document .changeColor { color: red }; Javascript MySQL MongoDB Python jQuery("#selectDemo").click(function () { jQuery(this).toggleClass("changeColor"); if (jQuery(this).hasClass("changeColor")) { jQuery(".isSelected").prop("checked", true); jQuery(this).val("Want To UnSelect All Values"); } else ... Read More
For this, use Object.keys() as well as Object.values() and map() for the result.Exampleconst object = { name: 'John', age: 21, countryName: 'US', subjectName: 'JavaScript' } const allKeysOfObject = Object.keys(object); console.log("The all keys are=" + allKeysOfObject); const allValues = Object.values(object); console.log("The all values are=" + allValues); console.log("The use of map is as follows="); allKeysOfObject.map(k => { console.log(object[k]) })To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo185.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo185.js The all keys are=name, age, countryName, subjectName The all values are=John, 21, ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP