Programming Articles - Page 2709 of 3366

C++ Program to find Median of Elements where Elements are stored in 2 different arrays

Aman Kumar
Updated on 15-May-2025 18:47:19

214 Views

The median is defined as the middle value of a sorted list of numbers, and the middle value is found by ordering the numbers in ascending order. Once the numbers are ordered, the middle value is called the median of the given data set. Here, in this article, we have two different sorted arrays and need to find the median of the array that is formed after merging of two given arrays. Median depends on the sorted merged array. So, the following cases may occur: If the length of the merged array is odd, then ... Read More

C++ Program to Implement B Tree

Aman Kumar
Updated on 30-Jun-2025 11:24:55

7K+ Views

In C++, a Binary tree is a generalization of the Binary Search Tree (BST). A B-tree can have more than two children. It is also known as a balanced tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. It is optimized for a system that reads and writes large blocks of data. Properties of B-tree As we discussed in the introduction B-tree is self-balanced tree where a node can have multiple children. It maintains the balance by making sure that all leaf nodes are at the same level. Following is the properties ... Read More

C++ Program to Implement a Binary Search Tree using Linked Lists

Aman Kumar
Updated on 15-May-2025 15:32:02

3K+ Views

A linked list is a linear data structure in which we store a sequence of elements, where each element is called a node that contains data and a pointer (or link) to the next element in the sequence. In this C++ article, we will implement a Binary search tree using a linked list. Binary Search Tree A binary search tree is a hierarchical data structure that is constructed by nodes. Each node contains a value and its reference to the left and right child nodes. So the value in the left child node is less than the parent node, and ... Read More

C++ Program to Count Inversion in an Array

Aman Kumar
Updated on 15-May-2025 15:36:22

833 Views

The inverse count of an array indicates how far or how close the array is from being sorted. If the array is already sorted, then the inverse count is zero, but if the array is sorted in reverse order, then the inverse count is maximum. Here we have given an integer array of size n and need to find the inversions in the array. If two array elements arr[i] and arr[j] form an inversion if arr[i]>arr[j] and i

How do exceptions work in C++

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

248 Views

In C++, Exception Handling is a process to handle runtime errors. Exception is an event which is thrown at runtime in C++. All exceptions are derived from std::exception class. It is a runtime error which can be handled. It prints exception message and terminates the program, if we don't handle the exception.Exceptions are defined in C++ standard as class that we can use inside our programs. The arrangement of parent-child class hierarchy has been shown below −Common exception classes in C++ are −Sr.No.Exception & Description1std::exceptionThis is an exception and parent class of all the standard C++ exceptions.2std::bad_castIt is an ... Read More

Chrono library in C++

Aman Kumar
Updated on 15-May-2025 15:38:25

791 Views

; is a C++ header that is included in C++11 or later versions and states the collection of types and functions to work with time. It is a part of the C++ Standard Template Library (STL). Why We Need It provides a precision-neutral concept by separating the durations and points of time. So, if we want to improve time over precision, we can use this library. provides three primary types of clocks: system_clock, steady_clock, and high_resolution_clock. These clocks are used to measure time in various ways: system_clock: It represents the system-wide real-time wall ... Read More

RTTI (Run-time type Information) in C++

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

662 Views

In this section we will see what is the RTTI (Runtime Type Information) in C++. In C++ the RTTI is a mechanism, that exposes information about an object’s datatype during runtime. This feature can be available only when the class has at least one virtual function. It allows the type of an object to be determined when the program is executing.In the following example the first code will not work. It will generate an error like “cannot dynamic_cast base_ptr (of type Base*) to type ‘class Derived*’ (Source type is not polymorphic)”. This error comes because there is no virtual function ... Read More

Calculation in parent and child process using fork() in C++

Aman Kumar
Updated on 15-May-2025 15:44:05

2K+ Views

The fork() function creates a new process by duplicating the current one. It allows developers to perform parallel tasks and manage resources efficiently. When fork() is called, it returns a value. If the value is greater than 0, then it is in the parent process. Otherwise, it is in the child process. In this C++ article, we will learn how to use the fork() system call to perform calculations in parent and child processes.According to the problem statement, we will do calculations. So, in our parent process, we will find the sum of all even numbers in an array, and ... Read More

Creating multiple process using fork() in C

Nitya Raut
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section we will see how to use the fork() to make child process in C. We also do some different tasks in each process. So in our parent process we will print different values.When fork() is called, it returns a value. If the value is greater than 0, then currently it is in parent process, otherwise it is in child process. So using this we can distinguish between the processes.Example Code#include #include int main() {    int n = fork(); //subdivide process    if (n > 0) { //when n is not 0, then it is ... Read More

How to update the column of a row in a CachedRowSet object in JDBC?

Samual Sam
Updated on 30-Jul-2019 22:30:25

693 Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.You can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Updating a Particular column of a rowThe updateXXX() methods of the CachedRowSet interface allows you to update column values of a particular row in a RowSet object.Get the required row and update the desired column ... Read More

Advertisements