Optimized bubble sort in JavaScript. Cocktail sort
Bubble sort algorithm doesn’t track the current state of the array. Even if it gets the fully sorted array as an input, the runtime will remain of the same O(n^2^) complexity....
Bubble sort algorithm doesn’t track the current state of the array. Even if it gets the fully sorted array as an input, the runtime will remain of the same O(n^2^) complexity....
Sorting is the process of arranging a sequence of objects in a particular order. You can sort any entities that can be compared. Imagine an online store. You enter your query into the search bar and you get a list of results....
All algorithms have 2 main characteristics: Amount of required memory. Execution time. These two are used to compare algorithms with each other. Some algorithms are faster, but require more memory, while others are vice versa....
What will be logged to the console? . . . . . . . . . . . . . . . . . Before we analyze the code snippet, let’s try to simplify it by removing the setTimeout....
To add a comment into an HTML document, there’s a special tag <!-- comment -->. There are times when you need to add comments to an HTML page. Comments are text that will be visible to your colleagues, but not visible to users who browse your website....
In JavaScript there are a couple of ways of rounding a number. The function Math.floor rounds the number down. It accepts a number n and returns the biggest integer that’s less than or equal n....
To insert an image into the HTML document, you can use the tag <image>. This HTML tag has 2 key attributes: src — defines the path to the image file alt — sets the alternative text....
Can you add multiple arrays in JavaScript? What’s the output? . . . . . . . . . . . . . . . . . . The function add(x, y, z) applies the + operator to the provided arguments....
To calculate the square root of the number in JavaScript, you can use the function Math.sqrt(). You pass in a number, and it returns the square root of this number....
JavaScript strings are immutable. This means that once the string was created it can’t be changed. When you need to remove the last character from a string in JavaScript, you should create a new string without this character....