
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
Found 7197 Articles for C++

2K+ Views
In this article, we will see a C++ program to implement the nearest neighbour algorithm: The nearest neighbour algorithm is a greedy algorithm used to find the approximate solution to the Travelling Salesman Problem (TSP) by computing the minimum cost required to visit all the nodes by traversing across the edges only once. We can implement this algorithm using different data structures like arrays, linked lists, or trees for efficient searching. How Nearest Neighbour Algorithm Works It start at a given point (eg., a city in TSP). Find the nearest unvisited ... Read More

552 Views
An ellipse is the locus on all those points in a plane such that the sum of their distance from two fixed points in the plane is constant. Where the fixed point is known as foci, which are sounded by the curve, the fixed line is a directrix, and the constant ratio is the eccentricity of the ellipse. Area of an Ellipse The area of an ellipse is the region enclosed by the ellipse. Which is computed by the following formula: Area = Π∗a∗b Let's discuss the following key points of an ellipse: ... Read More

903 Views
If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reach-ability matrix is called transitive closure of a graph. Warshall algorithm is commonly used to find the Transitive Closure of a given graph G. Here is a C++ program to implement this algorithm.AlgorithmBegin 1.Take maximum number of nodes as input. 2.For Label the nodes as a, b, c ….. 3.To check if there any edge present between ... Read More

3K+ Views
QueueThe queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations are −EnQueue (int data) − Insertion at rear endint DeQueue()− Deletion from front endThis is a C++ program to implement queue using array.AlgorithmBegin function Enqueue() to insert elements in queue: If queue is completely filled up then print “Overflow”. Otherwise insert element at rear. Update the value of rear End Begin function Dequeue() to delete elements from ... Read More

502 Views
The C/C++ library function size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) reads data from the given stream into the array pointed to, by ptr. Following is the declaration for fread() function.size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)The Following table contains the fread() parameters and description:ParametersDescriptionptrThis is the pointer to a block of memory with a minimum size of size*nmemb bytes.sizeThis is the size in bytes of each element to be read.nmembThis is the number of elements, each one with a size of size bytes.streamThis is the pointer to a FILE object that specifies an input stream.The ... Read More

12K+ Views
A deque is a double-ended queue linear data structure where elements can be added or removed from both the front and rear ends. Unlike a standard queue which is FIFO. A dequeue can function in both FIFO and LIFO modes. Application of Dequeue Deques are useful in a situation where you need to add or remove an element from both ends, such as in buffer implementation managing undo/redo functions or implementing certain algorithms. Deque Operations Deque supports the following operations: insert_at_beg(): inserts an item at the front of Dequeue. insert_at_end(): inserts ... Read More

1K+ Views
Queue The queue is a linear data structure that follows the First-In-First-Out (FIFO) operation. Where insertions are done at one end (rear) and deletions are done from another end (front). The first element that is entered is deleted first. Following are the stack operations: EnQueue (int data): Insertion at rear end int DeQueue(): Deletion from front end Stack The stack is also a linear data structure that follows the Last-In-First-Out (LIFO) operation. Where the element will be added and removed from the top. Following are the stack operations: ... Read More

2K+ Views
Stack The stack is a linear data structure that follows the Last-In-First-Out (LIFO) operation. Where the element will be added and removed from the top. Following are the stack operations: push (int data): Insertion at top int pop(): Deletion from top Queue The queue is also a linear data structure that follows the First-In-First-Out (FIFO) operation. Where insertions are done at one end (rear) and deletions are done from another end (front). The first element that is entered is deleted first. Following are the stack operations: EnQueue (int data): Insertion at rear end int DeQueue(): Deletion from ... Read More

453 Views
Searching for a substring within a short text is a common operation in many C++ programs, like as small-scale text editors, command line utilities, and education projects. So, in this article, we will implement a string search algorithm for short text sizes. Importance of String Search String search algorithms find a substring within another string. While advanced methods like KMP and Boyer-Moore are great for longer texts, a simple method like Naive search works well for short texts without added complexity. Algorithm to Implement String Search Algorithm for Short Text Sizes The Following is a string search algorithm − Begin ... Read More