Java is a well−known programming language that is used to create a variety of applications. The user experience could be harmed by performance issues that can be caused by poorly optimized Java code. In this blog post, you will come across 12 techniques for improving the performance of Java programming. Techniques to Optimize Java Code Use Efficient Data Structures The choice of a suitable data structure has a significant impact on the effectiveness and speed of Java programming. For instance, choosing a LinkedList over an ArrayList can be advantageous if you frequently add or delete entries from a list because ... Read More
Programming is all about coming up with the best and most efficient ways to solve the real−world problems. There are situations when you want to exit multiple loops simultaneously. This can be accomplished in Java by simply referencing the name of the loop you want to exit. In this tutorial, we'll look at how to break any outer nested loop in Java by referencing its name. Referencing Loop Names in Java You can break out of the Java nested loop by labelling the outer loop. This can be accomplished by using a label before the outer loop followed by a ... Read More
A binary tree is a data structure in which each node can have two children (at most). These children are known as left and right child respectively. Suppose we are given a parent array representation using which you have to a create a binary tree. The binary tree may have several isosceles triangles. We have to find the total number of possible isosceles triangles in that binary tree. In this article, we will explore several techniques in C++ to solve this problem. Understanding the Problem You are given a parent array. You have to represent it in the form ... Read More
A full binary tree is a special type of binary tree in which all the parent nodes either have two or no children. In data structures, these kinds of trees are considered as balanced and organized representation. Full binary trees may have a unique feature where each of the parent node is a product of its children. In this article, we will discuss about different methods for counting the number of full binary trees such that each node is product of its children using C++. Input Output Scenarios For example, in the array {1, 5, 3, 4}, we have ... Read More
Imagine a prisoner (or thief) wants to escape from a jail. In order to do so, he needs to cross N number of walls of varying lengths. He can climb X feet for each jump. But, since the walls are slippery, he falls down by Y feet after each jump. So, we need to calculate number of jumps required to cross all the walls. In this article, we will explore different C++ techniques to find the number of jumps required to escape the jail. Input Output Scenarios We have different heights of the N walls in the form of ... Read More
In this article, we will discuss the possible solution of an exciting analytical question of how many jumps are required to reach a point (d, 0) from the origin in a 2D plane where you have been specified fixed length of jumps. We will use the fixed length of jumps and the target coordinates to find the minimum number of jumps required. Input Output Scenarios Suppose jump length can be a or b while the target point is (d, 0). Then, the given output is the minimum number of jumps required to reach target. Input: a = 7, b ... Read More
Suppose you are given three integral numbers a, b and c and you have an equation x = b* (sumofdigits(x)^a) +c. Here, sumofdigits(x) is the total sum of all the digits in x. To find all the possible integral solutions which satisfy the equation, we will explore various approaches in C++. Input Output Scenarios Given below are values of a, b and c. Different integral solution which satisfies the equation x = b* (sumofdigits(x)^a) +c is given as output. Input: a = 2, b = 2, c = -3 Output: 125, 447, 575 In the above scenario the ... Read More
Suppose you are given three different points (or coordinates) and you want to find out number of horizontal or vertical line segments which can be made by connecting those three points. Such line segments together are also known as polyline. You need concepts of computational geometry in order to solve this problem. In this article, we will discuss various approaches in C++ to tackle this problem. Input Output Scenarios Suppose c1, c2 and c3 are coordinates of 3 points in a cartesian plane. The number of horizontal or vertical line segments to connect these 3 points will be given as ... Read More
Suppose you are in a social gathering. Can you calculate how many handshakes you can do if you were to shakes only once? This question might sound intriguing to you. This can be solved mathematically by using permutations and combinations. However, the mathematical operation might be time-consuming. In this article, we will discuss how to solve such problem using C++. We will explore different approaches which ranges from mathematical formulas, to recursion, and other combinatorial techniques. Input Output Scenarios Suppose you have N number of people in a gathering. You want to calculate the number of handshakes possible ... Read More
In the field of computer science, we have to process large datasets which includes query selection and update operations. It is a challenging task for the developers to execute these operations in real-time with less time complexity. Using Fenwick tree is an efficient way to tackle these range-based query problems. Fenwick Tree is a data structure which updates elements and calculates the prefix sums of the numbers in a table efficiently. It is also known as Binary Indexed Tree. In this article, we will discuss how to use Fenwick Trees for finding the number of elements greater ... Read More