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
Programming Articles
Page 1012 of 2544
Delete a node in a Doubly Linked List in C++
In this tutorial, we are going to learn how to delete a node in the doubly linked list. Approach Let's see the steps to solve the problem. Write struct with data, prev, and next pointers. Write a function to insert the node into the doubly linked list. Initialize the doubly ...
Read MoreRead whole ASCII file into C++ std::string
This is a simple way to read whole ASCII file into std::string in C++ − Algorithm Here is the algorithm we will follow to Read the whole ASCII file into C++ std::string. Begin Declare a file a.txt using file object f of ifstream type to perform a read operation. Declare a variable str of string type. If(f) Declare another variable ss of ostringstream type. Call rdbuf() function to read the data of the file object. Put the ...
Read MoreMatrix Chain Multiplication (A O(N^3) Solution) in C++
If a chain of matrices is given, we have to find a minimum number of correct sequences of matrices to multiply. We know that the matrix multiplication is associative, so for four matrices ABCD, we can multiply A(BCD), (AB)(CD), (ABC)D, and A(BC)D, in these sequences. Like these sequences, our task is to find which ordering is efficient to multiply.ExampleIn the given input there is an array say arr, which contains arr[] = {1, 2, 3, 4}. It means the matrices are of the order (1 x 2), (2 x 3), (3 x 4). Input − The ...
Read MoreWhat are the differences between bitwise and logical AND operators in C/C++
As we know the bit-wise AND is represented as ‘&’ and the logical operator is represented as ‘&&’. There are some fundamental differences between them. These are as follows − bitwise AND operator The bitwise AND (&) operator performs a bit-by-bit AND operation between two integers. The bitwise AND operator works on integer, short int, long, unsigned int type data, and also returns that type of data. Here, Each bit should be 1 to give the result as 1, else it will result in 0, 1 & 1 = 11 & 0 = 00 & 1 = 00 & 0 ...
Read MoreProgram for Point of Intersection of Two Lines in C++
Given points A and B corresponding to line AB and points P and Q corresponding to line PQ; the task is to find the point of intersection between these two lines. Note − The points are given in 2D plane on X and Y coordinates. Here A(a1, a2), B(b1, b2) and C(c1, c2), D(d1, d2) are the coordinates which are forming two distinct lines and P(p1, p2) is the point of intersection. (just for a diagrammatic explanation of the point of intersection) How to find the point of intersection − Let’s take the above figure as − Example So ...
Read MoreJava program to sort string stream with reversed comparator
In this article, we will learn how to sort a stream of strings using a reversed comparator in Java. Java 8 introduced the Stream API, which allows powerful operations like sorting using custom comparators. Java Comparator A Comparator is a functional interface in Java that defines custom sorting logic. It compares two objects and returns a result based on the comparison. Java Stream A Stream is a sequence of elements that can be processed in parallel or sequentially, supporting methods like sorting, filtering, and mapping. Sorting string stream with a reversed comparator The following are the steps for sorting a ...
Read MoreJava Program to Represent Linear Equations in Matrix Form
In this segment of Java programming, we are going to learn and discover certain programs by which we can represent linear equations in Matrix form. To do these programs, we first have to learn about linear equations and Matrix forms, their types, and how they are solved by simple mathematical methods. We will learn how to integrate a scanner class of java.util package to take input from the user using Java build code. The array will initialize to store some variables as input for the problem matrix. Then, it will be converted into a loop by which the problem equation will ...
Read MoreJava program to remove duplicate elements from a List
In this article, we will learn to remove duplicate elements from a List in Java. We will be using two methods: LinkedHashSet and the Stream API. First, we'll create a list with duplicate values and use LinkedHashSet to remove them while maintaining the order. Then, we’ll use the Stream API to filter out duplicates using distinct(). By the end, you’ll see how both methods work to clean up the list while keeping the original order. List in Java The List interface in Java, part of the Collection framework, represents an ordered collection of elements that allows duplicates and provides index-based ...
Read MoreJava program to merge contents of all the files in a directory
In this article, we will learn how to merge the contents of all the text files in a directory into a single file using Java. It reads the data from each file and writes it into a new file while ensuring all data is stored in an organized manner. You’ll see how to handle files, read their content, and merge them programmatically. File class The java.io package contains the Java File class, which provides an abstract representation of file and directory pathnames. It is commonly used for creating files and directories, searching for files, deleting files, and performing other file-related operations. File ...
Read MorePass by reference vs value in Python
In Python Call by Value and Call by Reference are two types of generic methods to pass parameters to a function. In the Call-by-value method, the original value cannot be changed, whereas in Call-by-reference, the original value can bechanged. Call by Value in Python When we pass an argument to a function, it is stored locally (in the stack memory), i.e the scope of these variables lies with in the function and these will not have effect the values of the golbal variables (variables outside function). In Python, "passing by value" is possible only with the immutable types such as integers, floats, strings, ...
Read More