Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1702 of 2650
496 Views
In this problem, we are given a binary tree. Our task is to create a program that will convert a binary tree to string with brackets in C++.The values of the binary tree are integers and it will be fed to the program in a preorder traversing way. The string should contain only integers and parentheses (), also it should be optimized i.e. all the empty pairs should be eliminated.Binary Tree is a tree that has a special condition that each node can have a maximum of two children.Example of a binary tree −Preorder traversal : [4, 1, 8, 3, ... Read More
395 Views
Here, we are given an array of size n which initially has all elements 0. And there are some queries that are to be performed on it. There are two types of queries −update(l, r, value) − Add value to the elements of the array that are between index l to r. For example, update(2, 4, 5) will update the array by placing the element 2 at the element at index 4 and 5.getRangeSum(l, r) − Find the sum of elements within the range of elements from l to r. For example, getRangeSum(4, 7) will find the sum of all ... Read More
292 Views
The functions beta(), betaf() and betal() are built-in functions in the standard template library of C++. These functions are used to calculate the beta function of two positive real numbers.The functions beta(), betaf() and betal() are built-in functions in the standard template library of C++. These functions are used to calculate the beta function of two positive real numbers.$B(x, y)=\int_{0}^{1}t^{(x-1)}(1-t)^{(y-1)}dt$beta()The beta() function is used to deal with values of data type double i.e. it accepts the parameter of double type and returns are double value.Syntaxdouble beta(double x, double y)Parametersx is a double value that gives the value of x in ... Read More
203 Views
Bertrand’s postulates is a mathematical showroom which states that for every number n>3, there exists a prime number p which lies between n and 2n-2.The formula for Bertrand's Postulaten < p < 2n -2Where n is a number such that n>3 and p is a prime number.Prime number − A number is a prime number if it's only factors are 1 and itself.A less restrictive formulation of Bertrand’s postulate isn < p < 2n , for all n>1.ExamplesNumber5Output7Explanationprime number in range 5 and 2*5 i.e. prime number between 5 and 10Number11Output13, 17, 19Explanationprime number in range 11 and 2*11 i.e. ... Read More
2K+ Views
Berkeley’s Algorithm is an algorithm that is used for clock Synchronisation in distributed systems. This algorithm is used in cases when some or all systems of the distributed network have one of these issues −A. The machine does not have an accurate time source.B. The network or machine does not have a UTC server.Distributed system contains multiple nodes that are physically separated but are linked together using a network.Berkeley’s AlgorithmIn this algorithm, the system chooses a node as master/ leader node. This is done from pool nodes in the server.The algorithm is −An election process chooses the master node in ... Read More
899 Views
Conditional probability denoted by P(A|B) is the probability of occurrence of an event ‘A’ given that event ‘B’ has already occurred.Formula for conditional probability −P(A|B) = P( A⋂B ) / P(B)Bayes’s TheoremIt is the formula that shows the relation between probabilities of occurrences of mutually dependent events i.e. it given the relation between their conditional probabilities.Given an event A and another event B, according to bayes’ theorem, P(A/B) = {P(B/A) * P(A)} / P(B)Lets derive the formula for Bayes’ theorem, For this we will use the formula for conditional probability, P(A|B) = P( A?B ) / P(B) —— 1 P(B|A) ... Read More
21K+ Views
File Handling is the storing of data in a file using a program. In C programming language, the programs store results, and other data of the program to a file using file handling in C. Also, we can extract/fetch data from a file to work with it in the program.The operations that you can perform on a File in C are −Creating a new fileOpening an existing fileReading data from an existing fileWriting data to a fileMoving data to a specific location on the fileClosing the fileCreating or opening file using fopen()The fopen() function is used to create a new ... Read More
4K+ Views
Attributes are modern ways in C++ to standardize things if their code runs on different compilers. Attributes are used to provide some extra information that is used to enforce conditions (constraints), optimization and do specific code generation if required.These are like an information manual for the compilers to do some enforcing which will improve performance of the code. Attributes were first seen in C++ 11 and are important parts of the programming language since then, Also with every version some revisions are continuously made to make them more powerful and better.Let’s see how we can define attributes in C++For different ... Read More
151 Views
In this problem, we are given an integer n which is the number of elements. Our task is to create a program that counts the number of ways to multiply n elements with the associative operation.Associative operations return the same result irrespective of the manner the numbers are arranged.Let’s take an example to understand the problem, Input3Output12Explanation(x*(y*z)), (x*(z*y)), (y*(x*z)), (y*(z*x)), (z*(x*y)), (z*(y*x)), ((x*y)*z), ((y*x)*z), ((x*z)*y), ((z*x)*y), ((z*y)*x), ((y*z)*x).To solve this problem, we will try to find if there is any relation or any type of series that can be created so that we can generalize our results. Let’s see the ... Read More
250 Views
In this problem, we are given two integers n and m, where n is the number of paintings and m is the number of colors available. Our task is to create a program that will find the total number of ways in which we can paint the paintings in such a way that no to consecutive paintings have the same color.Let’s take an example to understand the problem, Inputn = 3, m =3Output12ExplanationP1 P2 P3 C1 C2 C3 C1 C3 C2 C1 C2 C1 C1 C3 C1 C2 C1 C2 C2 C3 C2 C2 C1 C3 C2 C3 C1 C3 ... Read More