Found 33676 Articles for Programming

Break Any Outer Nested Loop by Referencing its Name in Java

Neetika Khandelwal
Updated on 12-Jul-2023 12:44:02

2K+ Views

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

Number of isosceles triangles in a binary tree

Riya Kumari
Updated on 12-Jul-2023 12:42:37

173 Views

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

Number of full binary trees such that each node is product of its children

Riya Kumari
Updated on 12-Jul-2023 12:41:11

143 Views

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

Number of jumps required for a thief to cross walls

Riya Kumari
Updated on 12-Jul-2023 12:39:56

298 Views

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

Number of jumps required of given length to reach a point of (d, 0) from origin in 2D plane

Riya Kumari
Updated on 12-Jul-2023 12:35:08

153 Views

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

Number of integral solutions for equation x = b*(sumofdigits(x) ^ a)+c

Riya Kumari
Updated on 12-Jul-2023 12:33:41

280 Views

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

Number of horizontal or vertical line segments to connect 3 points

Riya Kumari
Updated on 12-Jul-2023 12:31:43

288 Views

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

Number of handshakes such that a person shakes hands only once

Riya Kumari
Updated on 12-Jul-2023 12:29:47

354 Views

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

Difference between Thread ID and Thread Handle

Pradeep Kumar
Updated on 12-Jul-2023 12:21:03

775 Views

In multi−threaded programming, threads are lightweight units of execution that enable concurrent execution within a single process. Threads share the same memory space and resources of the process, allowing for efficient utilization of system resources. To work with threads, developers often need to distinguish between different threads and manage their execution. This is where the concepts of thread ID and thread handle come into play. In a multi−threaded programming environment, threads are independent units of execution within a process. Each thread has its own unique identifier and a corresponding handle that can be used to manipulate and manage the thread. ... Read More

Number of elements greater than K in the range L to R using Fenwick Tree (offline queries)

Riya Kumari
Updated on 12-Jul-2023 12:28:27

395 Views

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

Advertisements