Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Samual Sam
Page 43 of 151
Dynamic Programming in JavaScript
Dynamic programming breaks down complex problems into smaller sub-problems and stores their solutions to avoid redundant calculations. This technique is particularly useful for optimization problems where overlapping sub-problems exist. Dynamic programming is used where we have problems that can be divided into similar sub-problems so that their results can be re-used. Before solving a sub-problem, the algorithm checks if it has already been solved and stored. The solutions of sub-problems are combined to achieve the optimal solution. When to Use Dynamic Programming For a problem to benefit from dynamic programming: The ...
Read MoreDijkstra's algorithm in Javascript
Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a weighted graph. We'll use the new addEdge and addDirectedEdge methods to add weights to the edges when creating a graph. Let us look at how this algorithm works − Create a distance collection and set all vertices distances as infinity except the source node. Enqueue the source node in a min-priority queue with priority 0 as the distance is 0. Start a loop till the priority queue is empty and dequeue the ...
Read MoreKruskal's algorithm in Javascript
Kruskal's algorithm is a greedy algorithm used to find the minimum spanning tree (MST) of a weighted, undirected graph. It works by systematically selecting the smallest weight edges while avoiding cycles. How Kruskal's Algorithm Works The algorithm follows these steps: Create a set of all edges in the graph Sort all edges by weight in ascending order While the set is not empty and not all vertices are covered: Remove the minimum weight edge from the set Check if this edge forms a cycle. If not, ...
Read Moreffmpeg settings for converting to mp4 and ogg for HTML5 video
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. HTML5 video requires specific codecs for cross-browser compatibility. MP4 with H.264/AAC works in most browsers, while OGV with Theora/Vorbis supports Firefox and other open-source browsers. Converting to MP4 Format When converting to MP4, use the H.264 video codec and AAC audio codec for maximum browser compatibility, especially IE11 and earlier versions. ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4 This command converts input.mov to output.mp4 with H.264 video and AAC audio codecs. MP4 with Maximum Compatibility ...
Read MoreWho maintains and governs CSS?
CSS was invented by Håkon Wium Lie on October 10, 1994, and is maintained by a group of people within the W3C called the CSS Working Group. The CSS Working Group creates documents called specifications. When a specification has been discussed and officially ratified by W3C members, it becomes a recommendation. These ratified specifications are called recommendations because the W3C has no control over the actual implementation of the language. Independent companies and organizations create that software. The CSS Working Group The CSS Working Group consists of representatives from major browser vendors (like Google, Mozilla, Apple, and ...
Read MoreHow to clear a chart from HTML5 canvas so that hover events cannot be triggered?
To completely clear a chart from an HTML5 canvas and ensure hover events are no longer triggered, the most effective approach is to remove the canvas element and create a new one. This method guarantees all event listeners and chart data are cleared. Method 1: Remove and Recreate Canvas Element This approach removes the existing canvas and creates a fresh one, eliminating all associated event listeners and chart data. var resetCanvas = function(){ // Remove the existing canvas $('#results-graph').remove(); ...
Read MoreAdding an element in an array using Javascript
Adding an element to an array can be done using different functions for different positions. Adding an element at the end of the array This can be accomplished using the push method. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage"); console.log(veggies); This will give the output − ["Onion", "Raddish", "Cabbage"] You can also use this to push multiple items at the same time as it supports a variable number of arguments. For example, let veggies = ["Onion", "Raddish"]; veggies.push("Cabbage", "Carrot", "Broccoli"); console.log(veggies); This will give the ...
Read MoreDescendent Selectors in CSS
CSS descendant selectors allow you to apply styles to elements that are nested inside other elements. This targeting method helps create specific styling rules without affecting similar elements elsewhere on the page. Syntax ancestor descendant { property: value; } The descendant selector uses a space between two selectors to target elements that are children, grandchildren, or any level deep within the ancestor element. Example: Styling Emphasized Text in Lists Apply yellow color to elements only when they appear inside tags: ul ...
Read MoreHow to define multiple style rules for a single element in CSS?
You may need to define multiple style rules for a single element. You can define these rules to combine multiple properties and corresponding values into a single block as defined in the following example: h1 { color: #36C; font-weight: normal; letter-spacing: .4em; ...
Read MoreHow to save DIV as Image with HTM5 canvas to image with the extension?
Converting HTML DIV content to images is useful for generating reports, creating downloadable content, or saving visual elements. The html2canvas library makes this process straightforward by converting DOM elements into canvas, which can then be saved as images. Installation First, include the html2canvas library in your HTML: Basic HTML Structure Create a DIV with content you want to convert: Welcome to TutorialsPoint! ...
Read More