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
C++ Articles - Page 176 of 719
198 Views
We are given a cube which can be formed using a 3-D array as cube[length][breadth][height]. The task is to calculate the minimum sum path which will be achieved by traversing the cube and hence print the result.Let us see various input output scenarios for this -In − int cube[length][breadth][height] = { { {2, 4, 1}, {3, 4, 5}, {9, 8, 7}}, { {5, 3, 2}, {7, 6, 5}, {8, 7, 6}}, { {3, 2, 1}, {4, 3, 2}, {5, 4, 3}}}Out − Minimum Sum Path In 3-D Array are: 15Explanation − we are given a cube having length, breadth and height. Now, we ... Read More
252 Views
We are given integer values as a_num that will store the numerator and p_den that will store the denominator which should be a prime number. The task is to check whether the operations performed on a_num after dividing with p_den proves the midy’s theorem or not.Steps to prove Midy’s theorem are-Input numerator as a_num and denominator as p_den which should always be a prime value.Divide the numbers. Check for the repeating decimal values.Store the decimal values until they are not repeating.Check whether the digits are even, if yes, then break them into halvesAdd both the numbers. If the output is ... Read More
312 Views
We are given with an array of integer elements of any given size. The task is to find the maximum sum which will be calculated by forming the subarrays from the given array within the given range which can be started from any possible index value in an array.Let us see various input output scenarios for this -In − int arr[] = { 3, 2, -1, 6, 7, 2 }, int first = 0, int last = 5Out − Maximum Subarray Sum in a given Range is: 19Explanation − we are given with an array containing both positive and negative values and a ... Read More
144 Views
We are given with an array of integer elements representing the coefficient values of a polynomial. The size of an array will be ‘n’ i.e. number of elements in an array. The degree of polynomial always starts with n-1 as there will be one constant value at the end of the polynomial series. The task is to replace the coefficient with other polynomials in such a manner that sum of roots will be minimized.Let us see various input output scenarios for this -In − int arr[] = { 2, -1, 4, 9, -1, 10, -5}Out − Minimize the sum of roots of ... Read More
322 Views
We are given an array string of words of any given size and the task is to break the words in all possible ways such that after the break the string formed should be a valid string and we have to calculate all such minimum word break as per the problem.Let us see various input output scenarios for this -In − string word[] = {"Hello", "Hell", "tell", "well", "bell", "ball", "all" }Out − Minimum Word Break is: 1Explanation − we are given with multiple words. Now we will pass the concatenation of two strings i.e. Hell and all and will break the concatenated ... Read More
4K+ Views
A line connects two points. It is a basic element in graphics. To draw a line, you need two points between which you can draw a line on a screen and in terms of graphics we refer to the points as pixels and every pixel is associated with integer coordinates. We are given integer coordinates in the form of (x1, y1) and (x2, y2) where, x1 < x2 and y1 < y2. The task is to calculate all the mid-points between point 1 i.e. (x1, y1) and point 2 i.e. (x2, y2) using the Midpoint Line Generation Algorithm.There are three ... Read More
307 Views
We are given with an integer array and an integer variable i.e. ‘X’. The task is to firstly form the subarray from the given array and then multiply all the elements of a subarray with an integer X. At last find out the elements that will contribute the maximum sum.Let us see various input output scenarios for this -In − int arr[] = {2, 4, 1, -5, -2}, X = 3Out − Maximize the subarray sum after multiplying all elements of any subarray with X are: 21Explanation − we are given with an array and an integer variable as X. Firstly, ... Read More
307 Views
We are given an integer array and the task is to firstly fetch the prefix of an array and then multiply it with -1, secondly calculate the prefix sum of an array and lastly find the maximum sum from the prefix array generated.Prefix array is generated as −First element of prefixArray[0] = first element of an arraySecond element of prefixArray[1] = prefixArray[0] + arr[1]Third element of prefixArray[2] = prefixArray[1] + arr[2]Fourth element of prefixArray[3] = prefixArray[2] + arr[3] …..etc.Let us see various input output scenarios for this -In − int arr[] = {2, 4, 1, 5, 2}Out − Prefix array is: ... Read More
616 Views
We are given a 2-D array of integer elements forming the matrix. The task is to calculate the count of minimum sum by pulling the submatrix from the matrix so formed.Let us see various input output scenarios for this -In −int matrix[size][size] = { {2, 3, -1, 5}, {-2, 9, -1, 6}, { 5, 6, 9, -9}, { -6, 1, 1, 1} }Out −Minimum sum submatrix in a given 2D array is: -9Explanation −we are given a 2-D array of size 4x4 i.e. 4 rows and 4 columns. Now, we will find out the sub-matrix from the given matrix such ... Read More
816 Views
We are given a tree data structure with ‘n’ number of nodes. The given tree will have a root node and respective children which can be any number and further child can have any number of children. The task is to find the minimum number of iterations required by a root node of a tree to pass the information to all nodes in a tree. At a time, a node can pass information to one of its children and further one of its children can pass information to one of its children and meanwhile root node can pass information to ... Read More