Aman Kumar has Published 37 Articles

C++ Program to Implement Queue Using Two Stacks

Aman Kumar

Aman Kumar

Updated on 21-May-2025 14:27:32

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 ... Read More

C++ Program to Implement Nearest Neighbour Algorithm

Aman Kumar

Aman Kumar

Updated on 21-May-2025 14:25:59

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 ... Read More

What is a virtual base class in C++?

Aman Kumar

Aman Kumar

Updated on 20-May-2025 19:30:46

2K+ Views

Virtual Base ClassVirtual base classes are used in virtual inheritance. It is a way of preventing multiple instances of given classes occurs in the inheritance hierarchy when using multiple inheritance. Why We Use Virtual Base Class? The use of a virtual base class ensures that ... Read More

C++ Program to Implement Bitap Algorithm for String Matching

Aman Kumar

Aman Kumar

Updated on 20-May-2025 19:24:35

428 Views

The bitap algorithm is fuzzy string matching algorithm that is used to find approximate matches between a pattern and a text. The algorithm determines whether a given text contains a substring that is "approximately equal" to a given pattern, where approximate equality is defined in terms of Levenshtein distance (or number ... Read More

cout << endl vs cout << \\"\\" in C++

Aman Kumar

Aman Kumar

Updated on 20-May-2025 18:50:02

1K+ Views

In C++, both count

C++ Program to find kth Smallest Element by the Method of Partitioning the Array

Aman Kumar

Aman Kumar

Updated on 20-May-2025 18:48:23

285 Views

In this articles we will find the kth Smallest Element by Partitioning the Array in C++, let's see input/output scenario: Input / Output Scenario Following is the input-output scenario: Input: arr[] = {7, 2, 1, 6, 8, 5, 3, 4} Output: 3 In the above scenario, after sorting the ... Read More

C++ Program to find the maximum subarray sum O(n^2) time (naive method)

Aman Kumar

Aman Kumar

Updated on 20-May-2025 18:47:14

319 Views

A subarray is a contiguous slice of an array, and maintains the order of elements naturally. (i.e., the elements of the subarray occupy consecutive positions). For example, the subarrays of an array {1, 2, 3} are {1}, {1, 2}, {1, 2, 3}, {2}, {2, 3}, and {3}. Input / Output ... Read More

C++ Program to Implement B+ Tree

Aman Kumar

Aman Kumar

Updated on 16-May-2025 17:14:30

3K+ Views

A B+ tree is an m-tree that consists of a root, internal nodes, and leaves. The root may be a leaf or a node with two or more children. A B+ tree is an advanced data structure that extends the B-tree by adding a linked list of leaf nodes. A ... Read More

Why is a C++ pure virtual function initialized by 0?

Aman Kumar

Aman Kumar

Updated on 16-May-2025 17:10:40

3K+ Views

In C++, the pure virtual function is initialized with = 0 to indicate that it must be overridden by the derived class and has no implementation in the base class. A pure virtual function is a virtual function in C++ declared in a base class that has no implementation within ... Read More

Why do we need a pure virtual destructor in C++?

Aman Kumar

Aman Kumar

Updated on 16-May-2025 17:09:11

856 Views

Need a pure virtual destructor in C++In C++, the main factor where a pure virtual destructor is needed are with abstract classes and polymorphism. It make sure proper clean-up and avoids memory leaks when working with objects of derived classes through base class pointers. If a class has a virtual ... Read More

Advertisements