Maximum Sum SubArray using Divide and Conquer in C++

Ravi Ranjan
Updated on 20-Aug-2025 13:41:56

1K+ Views

In this article, we have an array of integers. Our task is to find the maximum sum of a sub-array using divide and conquer algorithm. A sub-array is a continuous part of an array with consecutive array elements. For example: {2, 3, 4} is sub-array of {1, 2, 3, 4, 5} but {1, 4, 5} is not. What is Divide and Conquer Algorithm? The Divide and Conquer algorithm divides a problem into smaller sub-problems, and then each sub-problem is solved independently. We keep dividing the sub-problems till we reach a stage where no more division ... Read More

Java Program to Access elements from a LinkedList

Aishwarya Naglot
Updated on 20-Aug-2025 12:26:31

455 Views

The Linked List in a Java is a data structure that is used for storing data in linear order. It has a series of node where each node contains two parts: data and a reference to the next node in the list. The first node is called the head and the last node is called the tail. In this article, we will learn how to access elements from a LinkedList in Java. Following are the ways to access elements from a LinkedList in Java: Using get() Method Using getFirst() Methods Using getLast() Method Accessing Elements from a LinkedList ... Read More

How to implement a constructor reference with one or more arguments in Java?

Aishwarya Naglot
Updated on 20-Aug-2025 12:24:21

9K+ Views

In this article, we are going to learn about implementing a constructor reference with an argument or multiple arguments in Java. Constructor references in Java provide us with a concise way of creating new objects via method references. These are going to enable us to reference a constructor without running the constructor itself so the code looks cleaner and it will be more readable. What is a Constructor Reference? A method reference may also be used with Java 8 constructors. A constructor reference may be defined by employing the class name and a new keyword. The constructor reference may be ... Read More

How to create a constructor reference for an array in Java?

Aishwarya Naglot
Updated on 20-Aug-2025 12:22:04

4K+ Views

In Java, a constructor refers to a special method within a class that is always executed automatically while creating an instance of the class using the new keyword. Its main purpose is initializing the object by providing its fields with initial values so that it is ready for use. A constructor shares the name of the class itself, has no return type, and can be overloaded so that there will be different ways of initializing the objects. If you don’t provide one, Java inserts a default no-argument constructor automatically. What is a Constructor Reference in Java? Constructor reference is like ... Read More

Python Program To Find the Smallest and Largest Elements in the Binary Search Tree

Farhan Muhamed
Updated on 19-Aug-2025 17:27:50

427 Views

In this article, we will explain how to find the minimum and maximum values in a binary search tree (BST), with implementation in Python. A binary search tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. So the leftmost node will have the minimum value, and the rightmost node will have the maximum value. Find Minimum and Maximum in a BST Given root node of a binary search tree, ... Read More

Program to convert binary search tree to a singly linked list in C++?

Farhan Muhamed
Updated on 19-Aug-2025 17:27:40

642 Views

A Binary Search Tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. In this article, we will discuss how to convert a Binary Search Tree (BST) into a singly linked list in C++. Flatten Binary Search Tree to Singly Linked List Given a Binary Search Tree, the goal is to convert it into a singly linked list where the linked list nodes are in the same order as the in-order ... Read More

Unique Binary Search Trees in C++

Farhan Muhamed
Updated on 19-Aug-2025 17:27:24

253 Views

The Unique Binary Search Trees problem is a classic dynamic programming problem that counts the number of unique binary search tree (BSTs) that can be formed with a given number of nodes. In this article, we will explain the problem, testcases, its solution, and provide a C++ implementation. Number of Unique BSTs In this problem, we are given an integer n, which represents the number of nodes in a binary search tree. The task is to find the number of different BSTs that can be formed using these n nodes and return the count. To understand the problem better, ... Read More

Check if a given array can represent Preorder Traversal of Binary Search Tree in C++

Ravi Ranjan
Updated on 19-Aug-2025 17:22:30

563 Views

In this article, we have an array of preorder traversal of a binary search tree. Our task is to check if the given array can represent the preorder traversal of the binary search tree. In preorder traversal of tree, the root node is visited first, then the left subtree, and finally the right subtree. What is Binary Search Tree? A binary search tree is a tree data structure and a special type of binary tree that follows the conditions given below: The left child node's value is always less than the parent node. ... Read More

Balance a Binary Search Tree in c++

Ravi Ranjan
Updated on 19-Aug-2025 17:22:10

3K+ Views

In this article, we have a binary search tree and our task is to balance the given binary search tree. A binary search tree is a tree data structure and a special type of binary tree that follows the conditions given below: The left child node's value is always less than the parent node. The right child node has a greater value than the parent node. All the nodes individually form a binary search tree. The inorder traversal of nodes in BST are ... Read More

Binary Tree to Binary Search Tree Conversion in C++

Ravi Ranjan
Updated on 19-Aug-2025 17:21:44

1K+ Views

To convert a binary tree to a binary search tree, use the inorder tree traversal of the tree. In inorder traversal, we first traverse the left subtree, then the root node, and then the right subtree. The nodes in inorder traversal of a binary search tree are in ascending order, so we find the inorder traversal of binary tree, sort it in ascending order, and place the sorted nodes in binary tree using inorder traversal to get the binary search tree. Understanding Binary Tree and Binary Search Tree A binary tree is a special type of tree in which ... Read More

Advertisements