The shell sorting technique is based on the insertion sort. In the insertion sort, sometimes we need to shift a large block to insert an item in the correct position. In shell sort, we avoid large number of shifting. The sorting is done with specific interval. After each pass, the interval is reduced to make smaller interval. We call also say we use gapped insertion sort in shell sort as we compare elements separated by a gap. In this article, we have an unsorted array. Our task is to sort the given unsorted array by implementing the shell sort in ... Read More
The Segmented Sieve algorithm is used to find the prime numbers within a given range. Segmented Sieve first uses the Sieve of Eratosthenes algorithm to find the primes smaller than or equal to √(n). The idea of this algorithm is to divide the range [0 ... n-1] in different segments and compute primes in all segments one by one. In this article, we have a range defined from low to high. Our task is to implement the Segmented Sieve to find the prime numbers within the given range in C++. Example The following example generates all the prime numbers between ... Read More
In this article, we will learn to set a tooltip text for each item of a JList in Java. Tooltips give meaningful information as users hover over UI components. Swing's JList does not support tooltips on a per-item basis, so it will involve some customization. What is JList? A JList is a subclass of the JComponent class, and it can be used to display a list of objects that allows the user to select one or more items. A JList can generate a ListSelectionListener interface and needs to implement the abstract method valueChanged(). Syntax The following is the syntax for ... Read More
In this article, we will learn to write/create a JSON file using Java. JSON has become the standard for data exchange for any kind of application. Java also has a collection of libraries helpful in creating and storing JSON files. JSON JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc. Sample JSON document Below is an example of a JSON file: { "book": [ { ... Read More
A multiset is an associative container that stores data in a sorted order in such a way that it allows duplicate values in the set. In this article, we will learn how to use a multiset from the Standard Template Library (STL) in C++. What is Multiset? Multiset is a sorted associative container that allows storing multiple elements with the same value. The values are automatically arranged in sorted order. This makes it useful in scenarios where you need to keep count of repeated values while maintaining order. For example, we can store the scores of students even ... Read More
A multimap is an associative container that stores elements in a key-value pair format, where multiple values can share the same key. In this article, we will learn how to use a multimap from the Standard Template Library (STL) in C++. What is Multimap? Multimap is a sorted associative container that stores data in key-value pairs, where keys can occur multiple times. Keys are stored in sorted order, and you can insert, access, and remove elements based on the key. For example, in a multimap we can store student names with their scores even if some students have ... Read More
A map is an associative container that stores elements in a key-value pair format. Each element has a unique key and a corresponding mapped value. No two mapped values can have the same key. In this article, we will learn how to use a map from the Standard Template Library (STL) in C++. What is Map? Map is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted automatically, and each key is associated with a value. You can insert, access, and remove elements based on the key. For example, we can store ... Read More
In this chapter, we will understand character classes, how they work. and provide simple examples and programs to explain their usage. One of the main components of regular expressions is character classes or character sets. Character classes help you to define a set of characters that will match in a string. They can be used to define a range of characters or specific characters to consider during a search. Character Classes or Character Sets A "character class, " also known as a "character set, " which helps you inform the regex engine to match only one of numerous characters. Simply ... Read More
The comma-separated values (CSV) is a text format that is used for storing tabular data. In Python, we will come across situations where CSV data is available in string format. For performing operations on this data, we need to convert it into an array. Python provides multiple ways to achieve this conversion. In this article, we are going to learn about converting the CSV string into an array. Using Python split() Method In this approach, we are going to use the Python split() method, which is used to split all the words in a string separated by ... Read More
In this article, we are going to find out how to do string concatenation without the plus operator in Python. Generally, String concatenation is the process of joining two or more strings into one, and the common way to do this is by using the '+' operator. For example, writing "Welcome" + " " + "TP" results in the string "Welcome TP". But here we need to perform the concatenation without the '+' operator. For achieving this, Python provides alternative methods, which we will explore one by one. Using Python join() Method The first approach is ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP