Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 631 of 719
196 Views
According to the problem statement, we have a directed graph and two vertices that are source s and destination/target t. Our task is to determine the maximum number of edge-disjoint paths that can be found from vertex s to vertex t. If two paths do not share any edge, then it is known as an edge-disjoint. A directed graph is a digraph where edges have a specific direction. They point from one vertex to another. There can be a maximum two-edge disjoint path from source 0 to destination 7 in the above graph. ... Read More
843 Views
Here is a C++ Program to Perform Greedy ColoringAlgorithm:Begin Take the number of vertices and edges as input. Create function greedyColoring() to assign color to vertices: A) Assign the first color to first vertex. B) Initialize the remaining vertices. C) Declare a temporary array to store the available colors. D) Assign color to the remaining vertices. Print the solution. EndExample Code#include #include using namespace std; int n,e,i,j; vector g; vector col; bool visit[1001]; void greedyColoring() { col[0] = 0; for (i=1;i
644 Views
This is a C++ Program to Implement Dijkstra’s Algorithm using Set. Here we need to have two sets. We generate a shortest path tree with given source node as root. One set contains vertices included in shortest path tree and other set includes vertices not yet included in shortest path tree. At every step, we find a vertex which is in the other set (set of not yet included) and has minimum distance from source.Algorithm:Begin function dijkstra() to find minimum distance: 1) Create a set Set that keeps track of vertices included in shortest path tree, Initially, ... Read More
738 Views
In both languages, exception handling is used to identify errors using the try, catch, and throw keywords. Exception handling is a programming mechanism that works with errors and unexpected events that occur during program execution. Exception Handling in C++ C++ provides an inbuilt feature for handling exceptions using try and catch block. It is an exception-handling mechanism; the code that has an exception is placed inside the try block, and the code that handles the exception is placed inside the catch block. Visit here to learn more about C++ Exception. Syntax Following is the syntax of C++ Exceptions: try { ... Read More
4K+ Views
The setg() function sets the position of the file pointer in the file. C++ seekg() Function The seekg() is a function in the iostream library that allows us to seek an arbitrary position in a file. It is mainly used to set the position of the next character to be extracted from the input stream from a given file in C++ file handling. Syntax There are two types of syntax of seekg() function: istream&seekg(streampos position); Or, istream&seekg(streamoff offset, ios_base::seekdir dir); Parameters Following is the parameter of the seekg(): position: It is the new ... Read More
3K+ Views
Splay Tree Splay tree is a self-balanced binary searched tree. The idea of implementing the splay tree is to bring the most recently inserted element to the root of the tree by performing a sequence of tree rotations, called splaying. Following are the basic operation on AVL: Insertion Searching Deletion Rotation: There are two types of rotation in splay tree (zig rotation and zag rotation). Let's see the code snippet of the above operation: Insertion Efficiently inserts a new key into the ... Read More
2K+ Views
Self Balancing Binary Search tree A self-balancing binary search tree (BST) is a height-balanced binary search tree that automatically keeps its height (the maximum number of levels below the root) as small as possible when insertion and deletion operations are performed on the tree. In the self-balancing binary search tree, the height is maintained in the order of O(logn), so that all operations take O(logn) time on average. Common examples of self-balancing binary search trees are: AVL Tree RED Black Tree Splay Tree AVL Tree An ... Read More
734 Views
A Randomized Binary Search Tree (RBST) is a variation of a Binary Search Tree (BST) that contains randomization to maintain balance and improve efficiency. One common implementation of an RBST is a Treap, which combines BST properties with heap properties. Why We Use Random Binary Tree Random binary trees are used for analyzing the average-case complexity of data structure based on the binary trees. Features of RBST Following are the features of the randomized binary tree: BST Properties: The left subtree contains smaller value, right subtree contains larger value. Randomization: ... Read More
883 Views
What is an Interval Tree? An interval tree is a tree data structure that stores intervals. It helps us to efficiently find all intervals that overlap with a specific interval or point. The purpose is to enhance a self-balancing Binary Search Tree (BST) known as Interval Tree, which is similar to Red Black Tree, AVL Tree, and so on, with a set of intervals so that all operations can be performed in O(log n) time. Every node of interval trees stores the following details: i: An interval which is represented as a pair [start, end]. ... Read More
673 Views
A fusion tree is a tree data structure that implements an associative array on w-bit integers. Here, W is the number of bits in the integer. A fusion tree is used to maintain the ordered set of elements. It uses a combination of a B-tree and a hash table that helps reduce the time complexity of the operations like insertion, deletion, and searching in the tree. How Fusion Tree Works? The following are the factors that should be considered while implementing the fusion tree: Bit manipulation: The tree extracts specific bits from stored integers and ... Read More