iswalpha Function in C++ STL

Farhan Muhamed
Updated on 12-Aug-2025 17:16:47

208 Views

The iswalpha() function is an extension of the isalpha() function, which supports character identification of all languages. In this article, we will learn how to use the iswalpha() function from the Standard Template Library (STL) in C++. What is iswalpha()? The iswalpha() function is used to check whether a given wide character is an alphabetic character. Wide character means the larger set of characters, which includes the characters from all languages. The iswalpha() function returns true if the input character is a letter, such as from English, Hindi, Chinese, etc. The regular isalpha() function will only work with alphabets ... Read More

Print All Even Nodes of Binary Search Tree in C++

Farhan Muhamed
Updated on 12-Aug-2025 17:00:45

372 Views

A Binary Search Tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. In this article, we will find all even nodes of a binary search tree using C++. Find Even-Valued Nodes in BST You are given a binary search tree (BST) as input, and your task is to write a program that finds all the nodes with even values and returns them as output. To understand better, let's consider the ... Read More

Optimal Binary Search Tree

Farhan Muhamed
Updated on 12-Aug-2025 16:23:36

8K+ Views

In this article, we will discuss a classic Dynamic Programming problem that involves constructing an optimal binary search tree for a given set of keys with their search probabilities. Before diving into the problem, let us understand what are Binary Search Trees and Dynamic Programming. Optimal Binary Search Tree Problem In this problem, you are given: A sorted array of keys[] of size n that contains the keys to make the binary search tree. An array freq[] of size n, where freq[i] is how many times keys[i] is searched. ... Read More

Split Array and Add First Part to the End in Java

Alshifa Hasnain
Updated on 12-Aug-2025 15:11:14

327 Views

Our task is to write a Java program to split the array and add the first part to the end. Here, the value of k=2, which means we need to keep 2 elements at the end of the array. Input: 67, 45, 78, 90, 12, 102, 34 Output: 78, 90, 12, 102, 34, 67, 45 Split the Java Array, Add the First Part to the End The following are the approaches to split the array and add the first part to the end: By shifting elements Using the reversal method ... Read More

Check If Array Can Be Sorted with One Swap in Python

Yaswanth Varma
Updated on 08-Aug-2025 17:10:14

308 Views

Sorting is a task used to organize the numbers in increasing order. Usually, we use the sorting algorithms to do this, but in most cases, the array is almost sorted, with two or three numbers in the wrong position. In such scenarios, instead of sorting the entire array, we can check if swapping just one pair of elements will make the entire array sorted. Checking if Array can be Sorted with One Swap The given task is to check if an array can be sorted with one swap in Python. i.e., given an array with distinct integers, we need ... Read More

Check if Square with One Colored Cell Can be Divided into Two Equal Parts in Python

Yaswanth Varma
Updated on 08-Aug-2025 16:17:50

172 Views

Dividing a Square into two Equal Parts In this article, we are given a square of size n*n with exactly one cell coloured. The task is to determine whether this square can be divided into two equal splits by making a single straight cut along the square, ensuring that the coloured cell lies entirely within one of the splits. Two equal splits here indicate that both parts must contain the same number of cells, which is possible if the square side length is even. In this article we are not only checking whether the split is possible but also whether the ... Read More

Can an Anonymous Class Have Constructors in Java

Aishwarya Naglot
Updated on 08-Aug-2025 15:39:51

2K+ Views

Anonymous Classes in Java are classes that do not have a name. They are typically used to extend a class or implement an interface without the need for a separate named class. The following are the common uses of anonymous classes:Implementing event listeners.Creating Runnable objects for threads.Providing custom implementations for abstract methods of an abstract class. Constructors in an Anonymous class Anonymous classes cannot have a constructor, but the compiler provides a default constructor for them. This means that when you create an instance of an anonymous class, it will call the constructor of the superclass or the interface it ... Read More

Class with a Constructor to Initialize Instance Variables in Java

Aishwarya Naglot
Updated on 08-Aug-2025 15:09:08

12K+ Views

Constructors are special methods in Java that are invoked when an object is instantiated. They are typically used to initialize instance variables of a class. In this article, we will explore how to create a class with a constructor to initialize instance variables in Java. Creating a Class with a Constructor To create a class with a constructor, you define the class and then create a constructor that has the same name as the class. The constructor accepts parameters to initialize instance variables. Example In the example below, we have a class named 'Car' with three instance variables: 'model', 'year', ... Read More

Binary Search on Singly Linked List in C++

Ravi Ranjan
Updated on 08-Aug-2025 14:40:31

2K+ Views

In this article, we are given a sorted singly linked list, and our task is to search for a given node using a binary search algorithm. The binary search algorithm works on the divide-and-conquer principle as it keeps dividing the list in half before searching. To search for an element in the linked list using binary search, it should be sorted. In the sorted linked list, we find the middle node using two pointers (slow and fast) and compare it with the target node, and based on the comparison, we either search in the left or right sub-list or return ... Read More

Binary Search in C++

Ravi Ranjan
Updated on 08-Aug-2025 14:26:16

19K+ Views

The binary search algorithm works as per the divide-and-conquer principle, as it keeps dividing the array in half before searching. To search for an element in an array using binary search, it should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left or right sub-array or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element using the binary search ... Read More

1 2 3 4 5 ... 7806 Next
Advertisements