Found 34494 Articles for Programming

Find Index of Cells Containing My String in MATLAB

Manish Kumar Saini
Updated on 07-Sep-2023 12:11:01

72 Views

In MATLAB, a cell array is a type of data structure used to hold data of different data types and sizes. In short, a cell array allows us to store different types of data like numbers, characters, strings, arrays, and more. In a cell array, each cell can contain a specific type of data. Cell array is a powerful tool to handle heterogeneous data. In MATLAB, the curly braces '{}' are used to create a cell array, i.e. CellArray = {10, 'TutorialsPoint', [2 3 4]}; Hence, cell arrays play a vital role, when we need to store different types ... Read More

Exercism Alternatives

Shirjeel Yunus
Updated on 07-Sep-2023 11:07:51

125 Views

What is Exercism? Exercism is a platform where you can learn around, 67 programming languages for free. The platform consists of tutorials for these languages. Some tutorials are short and some are long. Each lesson consists of theory along with examples. Learning is not stressful and you can develop your programming skills easily. Price Plans of Exorcism Learn programming languages on Exercism for free. There are no price plans or subscriptions. Top 10 Exercism Alternatives There are many alternatives to Exercism and some of them have been discussed here in detail. Alternative 1 − FreeCodeCamp FreeCodeCamp is a platform where ... Read More

Extract Subsets of Consecutive Entries in a Matrix in MATLAB

Manish Kumar Saini
Updated on 07-Sep-2023 10:51:31

48 Views

MATLAB is a powerful tool to manipulate matrices. In this article, we will explore how to extract subsets of consecutive entries in a matrix using MATLAB. But before that let's first get an overview of subsets of consecutive entries in a matrix. In a matrix, a set of elements that located in either rows or columns, or both in a sequence is referred to as a subset of consecutive entries in the matrix. The subsets of consecutive entries in a matrix can be extracted by specifying a range of columns and rows. The subsets of consecutive entries in a matrix ... Read More

Double Interpolation using Lookup Tables in MATLAB

Manish Kumar Saini
Updated on 07-Sep-2023 10:38:10

123 Views

Double Interpolation is a mathematical method used to calculate values within a set of data points. It is basically an advanced version of interpolation, as it is used to interpolate a function that depends on two variables. In other words, the double interpolation is a method of estimating value of a function within a set of a data points by combining two distinct interpolation processes. In this tutorial, I will explain how to calculate double interpolation using lookup table in MATLAB. But before let's get a basic overview of terms "interpolation", "double interpolation", and "lookup table". What is Interpolation? ... Read More

Sum of an array using pthreads

Divya Sahni
Updated on 28-Sep-2023 15:20:41

678 Views

Pthreads is an execution model that helps use multiple processors to work at the same time for solving a problem. It is independent of the programming language. Problem Statement Given an array of integers. Find the sum of all the elements of the array using pthreads. Need for Multithreading for Calculating sum The problem is to add the elements in an array. Although it is a simple problem where a linear traversal of the array can do the work very easily with a time complexity of O(n) where n is the number of elements in the array. But if we ... Read More

Print numbers in the range 1 to n having bits in an alternate pattern

Divya Sahni
Updated on 28-Sep-2023 14:26:29

66 Views

Alternate bit pattern implies the positioning of 0’s and 1’s in a number at an alternate position i.e. no two 0s or 1’s are together. For example, 10 in binary representation is (1010)2 which has an alternate bit pattern as 0’s and 1’s are separated by each other. Problem Statement Given an integer, N. Find all the integers in the range 1 to N where the bit pattern of the integer is alternating. Example 1 Input: 10 Output: 1, 2, 5, 10 Explanation $\mathrm{(1)_{10} = (1)_2, (2)_{10} = (10)_2, (5)_{10} = (101)_2, (10)_{10} = (1010)_2}$ Example 2 Input: ... Read More

Jacobsthal and Jacobsthal-Lucas Numbers

Divya Sahni
Updated on 28-Sep-2023 14:19:17

168 Views

Jacobsthal Numbers Lucas sequence 𝑈𝑛(𝑃, 𝑄) where P = 1 and Q = -2 are called Jacobsthal numbers. The recurrence relation for Jacobsthal numbers is, $$\mathrm{𝐽_𝑛 = 0\: 𝑓𝑜𝑟 \: 𝑛 = 0}$$ $$\mathrm{𝐽_𝑛 = 1\: 𝑓𝑜𝑟 \: 𝑛 = 1}$$ $$\mathrm{𝐽_𝑛 = 𝐽_𝑛−1 + 2𝐽_{𝑛−2}\: 𝑓𝑜𝑟 \: 𝑛 > 1}$$ Following are the Jacobsthal numbers − 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, …. Jacobsthal-Lucas Numbers Complementary Lucas sequence $\mathrm{𝑉_𝑛(𝑃, 𝑄)}$ where P = 1 and Q = -2 are called JacobsthalLucas numbers. The recurrence relation for Jacobsthal-Lucas numbers is, $\mathrm{𝐽_𝑛}$ = ... Read More

Increment a number by 1 by manipulating the bits

Divya Sahni
Updated on 28-Sep-2023 14:03:06

519 Views

Bit manipulation applies logical operations on a bit stream using bitwise operators like AND(&), OR(|), NOT(~), XOR(^), Left Shift() to get a required result. Using bitwise operators is beneficial as we can manipulate individual bits and they are faster than other operators. Problem Statement Given a number. Increment or add the number by 1 using bitwise operators only. (Don’t use arithmetic operators like ‘+’ , ‘-’, ‘*’ or’/’ ) Approach 1: Using One’s Complement / NOT Operator Bitwise complement / One’s complement is implemented using the NOT(~) Operator. For a number n, a bitwise complement of n i.e. ~n = ... Read More

Sum of Fourth Powers of first N natural numbers

Divya Sahni
Updated on 28-Sep-2023 12:07:35

331 Views

The fourth power of a number x is x raised to the power 4 or x4. Natural numbers are all positive integers excluding zero. Thus, the sum of the fourth powers of the first N natural numbers is − $\mathrm{Sum = 1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$ This article describes some approaches for finding the sum using minimum time and space complexity. Problem Statement Given the number N, find the sum $\mathrm{1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$. Example 1 Input: 3 Output: 98 Explanation $\mathrm{Sum = 1^4 + ... Read More

How to create HTTPS Server with Node.js?

Aayush Mohan Sinha
Updated on 07-Sep-2023 17:08:35

751 Views

As the consumption of the cyberspace and cloud-dependent applications proliferates, the gravity of safeguarding online data and transactions becomes more apparent. One of the most commonly employed methodologies for securing online communications is HTTPS, which provides an assurance that the information conveyed between the server and clients is ciphered and cannot be effortlessly intercepted by malevolent third parties. In this manuscript, we will probe into the process of building an HTTPS server with Node.js, an influential and adaptable platform for developing server-side applications using JavaScript. We will go over the fundamentals of SSL certificates, the essential components of an HTTPS ... Read More

Advertisements