A circular singly linked list is a type of data structure that is made up of nodes that are created using self-referential structures. Each node contains two components, namely the data element and the reference to the next node in the list. Only the reference to the head node is required to access the whole linked list. The last node of the list points to the head node, which makes it a circular linked list. Let's see a diagram of circular linked list. Circular linked lists are mainly useful for scheduling tasks and managing playlists, enabling smooth navigation. ... Read More
A pure virtual function is a function that has no implementation in the base class and must be overridden by any derived class. It is declared using = 0 in the base class. Pure Virtual Destructor When we want the base class to be abstract then we declare a pure virtual Destructor. A pure virtual Destructor can be declared in C++ after a destructor has been created as a pure virtual object. One of the most important things is that if a class contains a pure virtual destructor, it must provide a function body for the pure virtual destructor. ... Read More
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
A virtual destructor is a destructor declared within the base class with a virtual keyword. In C++, destructors are special members of a class that frees memory occupied by an object when a memory leak occurs. Deleting a derived class object using a pointer to a base class, the base class should be defined with a virtual destructor. When to Use Virtual Destructor? Virtual destructorsare needed in scenarios where polymorphism and inheritance are involved, and instances of derived classes are managed by pointers to base classes. If our class has one or more virtual functions that are inherited from child ... Read More
In C++, we cannot create a virtual constructor, this is because C++ is a statically typed language and the constructor is responsible for creating an object. So, the compiler needs to know the exact type of object at compile time. The virtual mechanism works only when we have a base class pointer to a derived class object. The constructor cannot be virtual, because when a constructor of a class is executed there is no virtual table in the memory, means no virtual pointer defined yet. So, the constructor should always be non-virtual. Implementation of Constructor & Destructor In the following ... Read More
This article will use an anonymous class to create a Thread in Java. An Anonymous class is a class that does not have a name. Thread in Java In Java, a Thread is a part of a program that can be executed independently. All Java programs have at least one thread, known as the main thread, which is created by the Java Virtual Machine (JVM), when the main() method is invoked. Creating a Thread by Using Anonymous Class In Java, the basic way to create a thread is to either extend the Thread class or implement the Runnable interface. However, we ... Read More
The article will explain the use of object cloning in Java and provide an appropriate example to clarify the problem. What is the Object Cloning in Java? In Java, object cloning is a way to create an exact copy of an object. We can use the clone() method provided by the Object class to create a clone of an object. When an object is cloned, a new instance of the same class is created, and the fields of the original object are copied to the new object. The Cloneable interface must be implemented by a class whose object is ... Read More
This article explains the different ways of calling the garbage collector (GC) in Java. It also includes a brief introduction to garbage collection, various calling approaches, and relevant examples. Garbage Collection (GC) in Java In Java, the garbage collection is carried out by a daemon thread called the Garbage Collector (GC). Instead of waiting until the Java Virtual Machine (JVM) runs a garbage collector, we can request the JVM to run the garbage collector. There is no guarantee that the JVM will accept our request. In Java, we can call the garbage collector (GC) manually in "two ways", which ... Read More
In Java, overriding is a technique used to provide a specific implementation of a method that is already defined in a superclass (i.e., parent class), allowing a subclass (i.e., child class) to modify or extend the behavior of that method. Purpose of Overriding the finalize() Method The purpose of a finalize() method can be overridden for an object to include the cleanup code or to dispose of the system resources that can be done before the object is garbage collected. If we are overriding this method, then we need to call the finalize() method explicitly. The finalize() method can be ... Read More
In Java, a List is an interface that represents an ordered collection of elements of the same type. You cannot directly create an object of the List interface, instead, you need to instantiate an ArrayList class or another class that implements the List interface.An array is a container that holds a fixed size of similar types of data. As the size is fixed, it can not be changed once created.The conversion between List and array is important because array provides faster access to the elements than List interface (faster in case of searching elements), and provides a fixed size of ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP