Merge Sort to Recursively Sort an Array in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:11:38

2K+ Views

In this problem statement, our aim is to sort an array recursively using merge sort and implement the code with the help of Javascript. So below we will discuss Merge sort and its implementation. Understanding the problem statement The problem statement is to write a function for merge sort in Javascript that will help to sort the given input array into an ascending or descending order. And we have to create a function which will sort the elements recursively. What is the recursive sorting technique? Recursion is a technique in which a function calls itself to solve a problem. When ... Read More

Split a Range of Number to Specific Number of Intervals in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:08:39

3K+ Views

In this problem statement, our task is to write the function splitting a range of numbers to a specific number of intervals with the help of Javascript. So for doing this task we will have to give start, end and the intervals. Understanding the problem statement The problem statement is saying to create a function which can split a range of numbers into a specific number of intervals. And the inputs will be starting and ending numbers of the range and the desired number of intervals. So the outcome should be the array of subarrays which shows each interval. These ... Read More

Spiraling the Elements of a Square Matrix in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:04:33

280 Views

In this problem statement, our main aim is to spiral the elements of the square matrix with the help of Javascript functionalities. There are several methods that can be used to do this task in Javascript. Understanding the problem statement The problem statement is to write a function in Javascript that will show the output as spiraling the elements of a square matrix. For example, if we have a two dimensional matrix as [1, 2] [3, 4], if we spiral the elements in clockwise direction then the output array will be [1, 2, 4, 3]. Logic for the ... Read More

Special Arrays in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 16:02:38

505 Views

In this problem statement, our task is to show working of some special arrays and their characteristics in Javascript programming. In Javascript a special array can be dependent on the given context. The special arrays can refer to different types of arrays depending on the condition and context. There are some interpretations possible: Typed arrays, Sparse arrays and Array with string keys. What is the Typed Array? In Javascript there are many built-in methods available for typed array objects. These arrays are special in the context that they represent the array of a specific type of data in it. ... Read More

Sorting Strings with Decimal Points in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:59:45

1K+ Views

In this problem statement, our aim is to sort strings with decimal points with the help of Javascript functionalities. So for doing this task we will use the sort and map method of Javascript. Understanding the problem statement The problem statement is to write a function in Javascript by which we can sort the given strings with decimal points. For example if we have an array of strings like [‘3.3’, ‘4.4’, ‘2.3’, ‘1.2’] so our task is to sort the given array of strings. But for sorting these strings first we need to convert it into numbers. After converting ... Read More

Sort Odd and Even Elements Separately in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:56:32

972 Views

In our problem statement we have to sort odd and even elements separately with the help of Javascript functionalities. So for doing this task we will use for loops and bubble sort for sorting odd and even numbers separately. Understanding the problem statement The problem statement is to write a Javascript function that will help to sort odd and even numbers in a given array. For example if we have an array [2, 3, 5, 4] then we will first sort even indexed elements [3, 4] and then sort the odd indexed elements in the array [2, 5]. After sorting ... Read More

Sorting Numbers According to the Digit Root in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:54:54

224 Views

In this problem statement, our task is to sort numbers according to the digit root and implement this problem with the help of Javascript functionalities. So we can solve this problem with the help of loops in Javascript. What is digit root? The digit root of a given number is basically the sum of its digits. Repeat the calculation until the result is not a single digit. Let's take an example for the digit root, calculate the digit root for 1234, 1 + 2 + 3 + 4 = 10 = 1 + 0 = 1. Similarly the digit root ... Read More

Round Number Down to Nearest Power of 10 in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:52:47

968 Views

In the provided problem statement, our task is to write the function for partial sum in an array of arrays with the help of Javascript. So here we will be given a variety of arrays and we need to compute the sum of each row and show the result. Understanding the problem statement The problem statement is asking for creating a function in Javascript which rounds down a given input number to the nearest power of 10. For example if there is an input 1365 so the output should be 1000. That is the nearest power of 10 which is ... Read More

Reversing Words While Keeping Their Order in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:51:03

1K+ Views

In this problem statement, our aim is to reverse the words within keeping their order in the same order with the help of Javascript functionalities. So for solving this problem we can use traditional for loops and also built-in methods or Javascript. Understanding the problem statement The problem statement is aiming for a function which takes a string as input and will return a new string in which the order of the words should remain intact but in reversed direction. For example, we have given a string "Hello World" so the function should return "olleH dlroW", here "Hello" is reversed ... Read More

Reverse Array Without Changing Certain Elements in JavaScript

Nikitasha Shrivastava
Updated on 18-May-2023 15:46:44

564 Views

In this problem statement, our aim is to write the function for reversing the array without changing the position of certain elements with the help of Javascript. So for doing this task we will be keeping track of the indexes of the preserved elements. . Understanding the problem statement The problem is for creating a function to reverse an array in Javascript but with certain elements in the array must not be changed their position. So the positions of these items should be the same in both the original and reversed arrays. For example let's say we have an array ... Read More

Advertisements