Found 34484 Articles for Programming

Program to print binomial expansion series

Divya Sahni
Updated on 25-Jul-2023 15:08:27

303 Views

Binomial expansion is a mathematical formula used to expand the expressions of the form (a+b)^n, where n is a positive integer and a and b can be any real or complex numbers. The expansion gives the coefficients of the terms in the expansion. A binomial expansion can be represented as $$\mathrm{(a+b)^n= ^nC_0a^nb^0+ ^nC_1a^{n-1}b^1 + ^nCa^{n-2}b^2+...+ ^nC_ra^{n-r}b^r+...+ ^nC_na^0b^n}$$ where $\mathrm{^nC_r}$ are the binomial coefficients and is given by $\mathrm{^nC_r=\frac{n!}{r!\times(n−r)!}}$ where n! is the factorial of n The expansion can be used for calculating all the binomial terms using the formula above and putting it into the expansion equation. Problem ... Read More

Modify array of strings by replacing characters repeating in the same or remaining strings

Divya Sahni
Updated on 25-Jul-2023 13:28:25

132 Views

Modifying an array of strings by replacing characters repeating in the same or remaining strings is a common problem in programming. It can be solved using hash tables, sets, arrays etc. The aim is to improve the time and space requirements while providing the same functionality. This problem can be encountered in many real-life scenarios, such as processing large text or cleaning up datasets with duplicates. Problem Statement Given an input string array arr[] containing lowercase and uppercase characters. The goal is to modify the array by removing characters from the strings which are repeating in the same string or ... Read More

Minimum number of basic logic gates required to realize given Boolean expression`

Divya Sahni
Updated on 25-Jul-2023 13:26:02

479 Views

Logic gates are the basic building block of a digital circuit. They take in one or two binary inputs and return a binary output. Since, using the term binary, the output and input can either be 0 or 1 or it can be said as “false” and “true” or “low” and “high”. There are 3 basic logic gates − AND Gate AND gate has two or more inputs and one output. It produces a high output if all inputs are high. The truth table for a two-input AND gate is given below − Input 1 Input 2 Output ... Read More

Check if it is possible to reach any point on the circumference of a given circle from origin

Divya Sahni
Updated on 25-Jul-2023 13:21:11

44 Views

The circumference of a circle can be defined as the outer boundary of the circle. It is the perimeter of a circle. Each point around a circle follows certain properties as follows − Point (x, y) lying inside the circle such that, $\mathrm{x^2 + y^2 < R^2}$ Point (x, y) lying on the circle such that, $\mathrm{x^2 + y^2 = R^2}$ Point (x, y) lying outside the circle such that, $\mathrm{x^2 + y^2 > R^2}$ where R = radius of the circle. Problem Statement Given a string S representing a sequence of moves (L, R, U, D) and ... Read More

Check if a given string is a comment or not

Divya Sahni
Updated on 25-Jul-2023 12:53:09

1K+ Views

In computer programming, comments are text written with the source code but ignored by the compiler or interpreter. They are used to provide readability of code by describing the code and its functionality for someone who is reading the code other than a compiler or interpreter. They are not executed and do not affect the functionality of the overall program, they are just for programmer guidance. Each programming language has a different syntax to represent comments. Here are a few examples − C/C++ − In C or C++, single-lined comments begin with ‘//’ and multi-liner comments are enclosed in ... Read More

How to Temporarily Suspend a Thread in Java?

Sakhi Bhagwat
Updated on 24-Jul-2023 16:45:39

489 Views

Threads are an important aspect of Java programs. They are also known as lightweight processes. Every program in Java has at least a main thread. They play a very important role to run multiple tasks at the same time. They run in the background and do not affect the execution of the main program. The use of multiple threads simultaneously is called multithreading. States of a Thread A thread can exist in either of the following states. It has a complete lifecycle from its creation to destruction. The thread lifecycle states are- ... Read More

Sum of Pairwise Products

Divya Sahni
Updated on 25-Jul-2023 12:47:33

700 Views

The pairwise product of a set X = {a, b, c} can be defined as the sum of the product of all possible set pairs. The pairs of the set are, Y = {a * a, a * b, a *c, b * b, b * c, c * c}, where the product is commutative. Thus, the pairwise product of set X is the summation of elements of set Y i.e. aa + ab + ac + bb + bc + cc. In mathematical terms, the sum of possible pair products can be depicted as, $$\mathrm{\displaystyle\sum\limits_{i=1, j=i}^{i\leq n, j\leq n}\:(i, ... Read More

How to Take Input from User Separated by Space in Java?

Sakhi Bhagwat
Updated on 24-Jul-2023 16:26:52

3K+ Views

Input and output are the vital components of all the programming languages. Same is the case with Java. User input is very crucial for creating dynamic and interactive applications. Usually the input is a single value but we can also take input from the user separated by space. This article deals with how to take input from the user separated by spaces in Java. Ways to Take Input From User Separated By Space in Java There are 2 ways by which we can take the input from the user separated by space. They are as follows- ... Read More

How to Create a User-Defined Javap Tool?

Sakhi Bhagwat
Updated on 24-Jul-2023 16:17:36

120 Views

At times, we need information related to a class file. In such a case, we can use the javap tool provided by the Java Development Kit (JDK). We can get more information related to the methods, constructors, and fields present in the class. The purpose of the javap tool is to disassemble one or more class files. It is also known as Java Class File Disassembler. Using the javap tool, we can get more information about the bytecode information about that particular class. The output may vary depending on the options used. Syntax The syntax of javap is ... Read More

How to Create a TreeSet with a List in Java?

Sakhi Bhagwat
Updated on 24-Jul-2023 16:11:08

477 Views

A TreeSet in Java stores unique elements in sorted order. It implements the SortedSet interface. The TreeSet interface internally uses a balanced tree called the Red-Black tree. A List in Java is a data structure that is used to store elements in the order in which they were added. We can create a TreeSet with a List in Java in many ways. This article deals with the ways in which a TreeSet can be created using a List in Java. Ways to Create a TreeSet with a List in Java There are 3 ways by which a TreeSet ... Read More

Advertisements