Find Array Elements with At Least One Smaller Element in Java

Mr. Satyabrata
Updated on 31-Jan-2023 15:28:10

244 Views

An array is a linear data structure in which elements are stored in contiguous memory locations. As per problem statement, we need to print all elements that have at least one smaller element. In simple terms we can say printing all elements of the array except the smallest one as the smallest one does not have any smaller element than this. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose we have the below array [10, 2, 3, -5, 99, 12, 0, -1] Now all elements ... Read More

Check if One Array is a Subset of Another Array in Java

Mr. Satyabrata
Updated on 31-Jan-2023 15:23:01

5K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to check whether one array is subset of another array. An array is a subset of another array if all the elements of subarray is present in the given array. Let’s explore the article to see how it can be done by using Java programming language. To Show you Some Instances Instance-1 Suppose the original array is array1 {33, 51, 5, 31, 9, 4, 3} The sub array is array2 {51, 9, 33, 3} ... Read More

Sort Matrix Row-wise and Column-wise Using Python

Vikram Chiluka
Updated on 31-Jan-2023 13:52:02

2K+ Views

In this article, we will learn a python program to sort the matrix row-wise and column-wise. Assume we have taken an input MxM matrix. We will now sort the given input matrix row-wise and column-wise using the nested for loop. Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Create a function sortingMatrixByRow() to sort each row of matrix i.e, row-wise by accepting input matrix, m(no of rows) as arguments. Inside the function, use the for loop to traverse through the rows of a matrix. Use Another nested for loop to traverse ... Read More

Remove List Elements Larger Than a Specific Value Using Python

Vikram Chiluka
Updated on 31-Jan-2023 13:49:54

8K+ Views

In this article, we will learn how to remove elements larger than a specific value from a list in Python. Methods Used The following are the various methods used to accomplish this task − Using remove() Method Using List Comprehension Using the filter() method & lambda function Method 1: Using remove() Method remove() function(removes the first occurrence of the element from the list) Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Create a variable to store the input list. Create another variable to store another input value. Use the for ... Read More

Remove Leading Zeros from a Number Given as a String in Python

Vikram Chiluka
Updated on 31-Jan-2023 13:46:49

12K+ Views

In this article, we will learn a python program to remove leading zeros from a number given as a string. Assume we have taken a number in string format. We will now remove all the leading zeros(zeros present at the beginning of a number) using the below-given methods. Methods Used The following are the various methods used to accomplish this task − Using For Loop and remove() function Using Regex Using int() Function Method 1: Using For Loop and remove() function Algorithm (Steps) Following are the Algorithms/steps to be followed to perform the desired task. − Create ... Read More

Print Matrix in a Snake Pattern using Python

Vikram Chiluka
Updated on 31-Jan-2023 13:45:34

2K+ Views

In this article, we will learn a python program to print a matrix in a snake pattern. Assume we have taken the n x n matrix. We will now print the input matrix in a snake pattern using the below-mentioned methods. Methods Used The following are the various methods used to accomplish this task − Using the nested for loop Reversing Alternate Rows Using Slicing Intuition  We will iterate through all the rows of a matrix. For each row, we will now check whether it is even or odd. If the row is even, then will print the ... Read More

Find Sum of a Sublist in Python

Vikram Chiluka
Updated on 31-Jan-2023 13:44:19

3K+ Views

In this article, we will learn a python program to find the sum of a sublist. Methods Used The following are the various methods to accomplish this task − Using For Loop(Brute Code) Using Cumulative Sum Method Using sum() Function Using math.fsum() Function Using For Loop (Brute Code) Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task. − Create a variable to store the input list. Create two separate variables for storing the start and the end indices. Initialize a variable resultSum to 0 for storing the resultant sum of a sublist. ... Read More

Check Involutory Matrix in Python

Vikram Chiluka
Updated on 31-Jan-2023 13:42:45

163 Views

In this article, we will learn a python program to check Involutory Matrix. Assume we have taken an input matrix. We will now check whether the input matrix is an Involutory Matrix using the below methods. Methos Used The following are the various methods to accomplish this task − Using Nested For Loop Using NumPy module What is an Involutory Matrix? If a matrix multiplies by itself and gives the identity matrix, it is said to be an involutory matrix. The matrix that is its inverse is the involutory matrix. If A * A = I, matrix A ... Read More

Number of Local Extrema in an Array using Python

Vikram Chiluka
Updated on 31-Jan-2023 13:40:39

456 Views

In this article, we will learn a python program for a number of local extrema in an array. An extrema is an element that is either greater than or less than both of its neighbors. Assume we have taken an array containing n elements. We will now find the count of a number of local extrema in a specified input array. Note The first and last elements are not extrema. Using For loop NOTE Both array[0] and array[n-1] have only one neighbor each, hence they are neither minima nor maxima. len() − The number of items in an ... Read More

Administrative Distance (AD) and Autonomous System (AS)

Satish Kumar
Updated on 31-Jan-2023 13:39:44

498 Views

Administrative Distance (AD) and Autonomous System (AS) are two important concepts in the field of computer networking. These concepts are used to determine the trustworthiness and reliability of routing information that is received from different sources. Understanding these concepts is crucial for network administrators as they are responsible for maintaining the integrity of the network and ensuring that data is transmitted efficiently. What is Administrative Distance (AD)? Administrative Distance (AD) is a metric that is used to determine the trustworthiness of routing information that is received from different sources. It is a value that is assigned to each routing protocol, ... Read More

Advertisements