Programming Articles - Page 2363 of 3363

How to get the JsonFactory settings using Jackson in Java?

raja
Updated on 07-Jul-2020 12:12:33

1K+ Views

The JsonFactory class is a thread-safe and responsible for creating instances of writer and reader. The list of settings that can be turned on/off is present in an enumeration JsonFactory.Feature, it contains static method values() that return the enum constant of this type with the specified name.Syntaxpublic static enum JsonFactory.Feature extends EnumExampleimport com.fasterxml.jackson.core.JsonFactory; public class JsonFactorySettingsTest {    public static void main(String[] args) {       JsonFactory jsonFactory = new JsonFactory();       for(JsonFactory.Feature feature : JsonFactory.Feature.values()) {          boolean result = jsonFactory.isEnabled(feature);          System.out.println(feature.name() + ":" + result);       }    } }OutputINTERN_FIELD_NAMES:true ... Read More

Arithmetic Number in C++

sudhir sharma
Updated on 24-Oct-2019 08:31:57

422 Views

The arithmetic number is a number which has the average of all positive divisors is an integer i.e. for a number n if the number of divisors can divide the sum of divisors then n is an arithmetic number.Let’s take an example to understand the concept better, Input : n = 6 Output : YES Explanation : Divisors are 1 , 2 , 3 , 6 Sum = 1+2+3+6 = 12 Number of divisors = 4 Sum of divisors / number of divisor = 12 / 4 = 3AlgorithmStep 1 : Calculate the sum of divisors and store into sum ... Read More

Area of a triangle inside a parallelogram in C++

Ravi Ranjan
Updated on 28-Jul-2025 14:07:59

597 Views

The area of a triangle is given as (base * height) / 2, and the area of a parallelogram is base * height. For calculating the area of the triangle inside the parallelogram, we divide the area of the parallelogram by 2, i.e., (base * height) / 2, where the base and the height of the parallelogram are given. Here are some example scenarios to calculate the area of a triangle inside a parallelogram using the above formula: Scenario 1 Input: base = 10, height = 8 Output: 40 Explanation: Using the formula: Area ... Read More

Area of a square from diagonal length in C++

Ravi Ranjan
Updated on 28-Jul-2025 14:08:37

340 Views

A diagonal of a polygon is the line joining two vertices that are not adjacent to each other. The formula for calculating the area of a square with diagonal length is a2 = d2 / 2, where a and d are the side and diagonal length of the square, respectively. The visual representation of the derivation of the formula is given below: Here are some example scenarios to calculate the area of a square from the diagonal length using the above formula: Scenario 1 Input: d = 10 Output: 50 Explanation: Using the formula: area = ... Read More

Apothem of a n-sided regular polygon in C++

sudhir sharma
Updated on 24-Oct-2019 08:17:10

290 Views

n-sided regular polygon is a closed figure of n sides that has all sides and angles of equal length. The below figure shows a 6 sided regular polygon commonly known as hexagon.Apothem is a line in the polygon that connects the center of the figure to the side. And it is perpendicular to one of its sides that makes it smallest in length.Now, let drive the formula for its length.The angle made by the side of an n sided polygon is 360/n.Now, as in the figure, the angle is equal to (360 / n )/2 = 180 /nNow taking the ... Read More

An Uncommon representation of array elements in C++ program

Farhan Muhamed
Updated on 09-Jun-2025 19:09:03

180 Views

In this article, we will learn an uncommon representation of array elements in both C and C++. Example of Uncommon Representation of Array Elements Consider following code in C/C++, that is trying to print an element from an array. C C++ #include int main() { int arr[2] = {0,1}; printf("First Element = %d",0[arr]); } Output The output of above program will be: First Element = 0 #include using namespace std; int main() { int arr[2] = {0,1}; cout

An interesting time complexity question in C++

sudhir sharma
Updated on 24-Oct-2019 08:09:38

1K+ Views

Time complexity can be defined as the time required by the algorithm to run its average case.Let's see and calculate the time complexity of some of the basic functions.Methodvoid counter(int n){    for(int i = 0 ; i < n ; i++){       for(int j = 1 ; j

An interesting method to print reverse of a linked list in C++

sudhir sharma
Updated on 24-Oct-2019 08:05:25

185 Views

A linked list is a data structure that stores data elements in linked form. Each node of the linked list has a data element and a link.Print reverse of a linked list is a common problem that needs to be addressed in problem solving. So, here we will learn an interesting way to print reverse of a linked list in c++ programming language.Generally print a reverse linked list needs modifications in the list or multiple traversing of the list but this method does not require any such things and also traverses the linked list only once.The logic of this method ... Read More

An Insertion Sort time complexity question in C++

sudhir sharma
Updated on 24-Oct-2019 08:01:24

1K+ Views

What is the time complexity of insertion sort?Time complexity is the amount of time taken by a set of codes or algorithms to process or run as a function of the amount of input.For insertion sort, the time complexity is of the order O(n) i.e. big O of n in best case scenario. And in the average or worst case scenario the complexity is of the order O(n2).What will be the time complexity of sorting when insertion sort algorithm is applied to n sized array of the following form: 6, 5, 8, 7, 10, 9 …… I, i-1The time complexity ... Read More

Amortized analysis for increment in counter in C++

sudhir sharma
Updated on 24-Oct-2019 07:54:31

654 Views

Amortized analysis for a sequence of operations is used to determine the run time, the average time required by the sequence. In cannot be treated as an average-case analysis done on the algorithm as it does not always take the average case scenario. There are cases that occur as a worst-case scenario of analysis. So, amortized analysis can be treated as a worst-case analysis for multiple operations in a sequence. Here, the cost of doing each operations in different and for some its high. This problem is a general view using the binary counter.Let’s see the working and implementation in ... Read More

Advertisements