Check Connectivity of Directed Graph Using BFS in C++

Farhan Muhamed
Updated on 15-Apr-2025 18:14:46

830 Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a directed graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ... Read More

Check Connectivity of Undirected Graph Using DFS in C++

Jennifer Nicholas
Updated on 15-Apr-2025 18:12:55

4K+ Views

The Depth-First Search (DFS) is a graph traversal algorithm that starts at root node and explores as far as possible along each branch before moving to next branch. In this article, we will discuss how to check the connectivity of a graph using DFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then ... Read More

Represent Immutable Vectors in Python

Sindhura Repala
Updated on 15-Apr-2025 18:06:22

309 Views

Immutable Vector in Python An immutable vector in Python is a fixed, ordered collection of numerical values that cannot be changed after creation. These are implemented using a tuple or libraries like immutable arrays, which specify data consistency, preventing modifications during computations. Representing Immutable Vectors Immutable vectors can be represented using tuples, which define ordered and unchangeable values. Alternatively, libraries like NumPy allow the creation of arrays with writable=False, making them immutable. This ensures that the vector values remain constant. Here are the methods to represent immutable vectors in Python. ... Read More

What is Tilde Operator in Python

Akshitha Mote
Updated on 15-Apr-2025 17:47:07

8K+ Views

In Python, the bitwise operator ~ (pronounced as tilde) is a complement operator. It takes one bit operand and returns its complement. If the operand is 1, it returns 0, and if it is 0, it returns 1. For example, consider the 4-bit binary number (1100)2. By performing the tilde operation, each bit is flipped and results in (0011)2. Tilde Operation on Decimal Numbers When we perform a tilde operation on decimal numbers, the following steps are involved: Convert the decimal number to binary, including the sign. If the number is positive, place 0 in ... Read More

What Does the b Character Do in Front of a String Literal in Python

Yaswanth Varma
Updated on 15-Apr-2025 17:41:59

11K+ Views

A string is a collection of characters that can represent a single word or a complete phrase. Since you can directly assign strings in Python to a literal (unlike other technologies) it is easy to use them. The string literals are typically enclosed in quotes (' ' or " ") and they represent a sequences of characters. However, in some scenarios we will encounter a string that starts with a lowercase b for example,  b'WELCOME', Where the b prefix stands for bytes literal. Bytes literals are useful when dealing with binary data, where data is transmitted or ... Read More

Why is the Size of an Empty Class Not Zero in C++

Ravi Ranjan
Updated on 15-Apr-2025 17:31:12

2K+ Views

The size of an empty class is not zero in C++ as it allocates one unique address to the object in the memory. The size can not be 0, because the two classes can not have the same memory address. So, the size of an empty class is 1 byte which does not hold any data, it is just for memory allocation. In this article, we will see an example of checking the size of an object of an empty class in C++. Demonstrating Size of an Empty Class In this approach, we have two C++ classes. One class ... Read More

Impact of Quick Commerce on Grocery Stores

Hornet dynamics
Updated on 15-Apr-2025 15:52:46

164 Views

In today's digital era, Quick Commerce has become the fastest process of delivering groceries in just 10 to 30 minutes; growing demand for convenience and speed has wholly transformed the retail industry. But how? This article explores the impact of Q-commerce on traditional grocery retail and what it means for the future of shopping. What is Quick Commerce? The word quick refers to instant commerce, where customers can find products or services instantly within 10-20 minutes. The Impact of Quick Commerce on Traditional Grocery Stores Quick Commerce has several impacts on traditional grocery stores − Consumer expectations Change Quick commerce ... Read More

Find Minimum Element in an Array Using Linear Search in C++

Ravi Ranjan
Updated on 15-Apr-2025 15:28:30

996 Views

Linear search is a sequential searching algorithm where we traverse every element within the input array and compare it with the key element to be found. The minimum element refers to the smallest element in the array. In this article, we have an array of integers. Our task is to find the minimum element in that array using linear search. Here are the three approaches you can use to find the minimum element: Using Value Using Index Using Pointer Using Value In this approach, ... Read More

Print Numbers from 1 to N Without Using Semicolon in C

Ravi Ranjan
Updated on 15-Apr-2025 15:27:59

2K+ Views

Printing numbers from 1 to N is an easy task that can be achieved using loops, but to print numbers from one to N without using a semicolon is a tricky question. We will discuss two different methods to solve this question using iteration and recursion approaches. In this article, our task is to print numbers from 1 to 'n' and we don't have to use a semicolon. The approaches are listed below: Using Iteration Using Recursion Using Iteration This approach uses the iterative approach, where we have used the while loop to print the numbers from 1 to N. The num

Sum the Digits of a Given Number in C

Ravi Ranjan
Updated on 15-Apr-2025 15:27:34

589 Views

The calculation of the sum of the digits of a number in a single statement means that only one line of code will be doing the addition operation. The addition operation should not extend more than one statement. In this article, we have a number and our task is to calculate the sum of the digits of the number in a single statement in c. Here is a list of approaches: Using for Loop Using Recursive Function Using for Loop This approach uses a for loop to calculate the ... Read More

Advertisements