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
Programming Articles - Page 2711 of 3366
5K+ Views
What is Expression Tree?An expression tree is a binary tree used to represent expressions. In an expression tree, internal nodes correspond to operators, and each leaf node corresponds to an operand. Let's see an expression and construct a tree for [5 + ((4+3)*2)]. Constructing an Expression TreeOur task is to construct an expression tree from a prefix expression. We have given a character array arr[] representing a prefix expression, so we have to build an expression tree for the expression and then display the infix and postfix expressions of the created tree. Input/Output Scenario Following are the examples to ... Read More
3K+ Views
Array Class In C++, the array class is part of the standard library and is known for its fixed size. The C++ array class, introduced in C++11, offers a better alternative to C-style arrays. The following are the advantages of the array class over a C-style array: Array class knows its size, whereas a C-style array does not have its size. So when passing to functions, we don't need to pass the size of the array as a separate parameter. C-style array there is more risk of array being decayed into ... Read More
24K+ Views
Both vectors and arrays are used to store collections of elements, but they differ significantly in how they manage their memory and flexibility. C++ std::vector A vector is a dynamic array that can be resized automatically when elements are added or removed. It is a part of the C++ STL and provides more flexibility than a static array. Example In the following example, we will demonstrate the usage of the vector in C++ − #include #include using namespace std; int main() { vector > v { { 4, 5, 3}, {2, 7, 6}, {3, 2, 1, 10} }; cout
6K+ Views
In this article, we will see the differences between namespace and class in C++. Namespace and classes are two different concepts, so let's discuss them: Classes are datatypes. It is an expanded version of the structures. Classes can contain data members and functions as members, but namespaces can contain variables and functions by grouping them into one and cannot be created as objects; it is used as additional information to differentiate similar functions, classes, variables, etc. Variables, functions with the same name can be placed in different namespaces. What is Namespace? The namespace is a feature that provides a way ... Read More
2K+ Views
Here we will see what is dynamic memory allocation in C. The C programming language provides several functions for memory allocation and management. These functions can be found in the header file. The following functions for memory allocations.FunctionDescriptionvoid *calloc(int num, int size);This function allocates an array of num elements each of which size in bytes will be size.void free(void *address);This function releases a block of memory block specified by address.void *malloc(int num);This function allocates an array of num bytes and leave them uninitialized.void *realloc(void *address, int newsize);This function re-allocates memory extending it upto newsize.Allocating memory dynamicallyWhile programming, if you ... Read More
544 Views
Gift Wrapping AlgorithmThe Gift Wrapping algorithm is also known as Jarvis's march. It is a method for calculating the convex hull of a set of points in a plane. It is essential to find the smallest convex polygon that encloses all the points. Why We Use Gift Wrapping Algorithm? Below are the following reasons to use this algorithm: Easy to Understand: It work like wrapping a string around points. Good for Small Data Sets: When fewer points make up the convex hull. Accurate: Never misses a point ... Read More
305 Views
In this articles, we implements a C++ Program to check if a point d lies inside or outside a circle defined by points a, b, c in a plane using the following equation: s = (x-xt)^2 + (y-yt)^2 – r*r Where equation contains the following points: x, y: Any point in the plane. xt, yt: Center of the circle. r: Radius of the circle. s: The difference between the squared distance and ( r^2 ). If s is equal to 0, the ... Read More
226 Views
Here is a C++ program to use above below primitive to test whether two lines intersect. It can be used to test whether a line intersects a line segment. It does if and only if one endpoint of the segment is to the left of the line and the other is to the right.AlgorithmBegin For generating equation of the first line, generate random numbers for coefficient of x and y by using rand at every time of compilation. For generating equation of the second line, generate random numbers for coefficient of x and y by using rand at ... Read More
177 Views
In this article, we implement a C++ program to find the area of a polygon using a slicker algorithm that avoids Triangulation to find the area of a polygon. What is Slicker Algorithm The Silcker algorithm is a method for calculating the area of a polygon by performing a series of calculations based on the polygon's vertices. It is an efficient alternative to triangulation, especially for polygons with many sides. How Silcker Algorithm Works? Since slicker is a method used to compute the area of a polygon without triangulation. Instead of breaking the polygon into triangles, it directly computes the ... Read More
576 Views
This is a C++ program to apply Above-Below-on Test to find the position of a point with respect to a Line. For any point t (xt, yt) on the plane, its position with respect to the line L connecting m and n is found by calculating the scalar s −Y = A xt + B yt + CIf Y< 0, t lies in the clockwise halfplane of L; if Y>0, t lies on the counter-clockwise halfplane; if Y= 0, t lies on L.AlgorithmBegin Take the points as input. For generating equation of the line, generate random numbers for ... Read More