The major differences between the trial balance and balance sheet are as follows −Trail balanceBalance sheetOpening stock is considered.Debit and credit.Doesn’t take part in financial statement.Contains nominal, real and personal accounts.Internal useCan be prepared monthly, quarterly, half-yearly and financial period.Prepared in column format.Audit is not necessary.Information of loss or profit is not provided.Not necessary to prepared by law.Prepared before adjustments.Can’t tell true financial position of the firm.General ledger is the source.No thumb rule.Closing stock is considered.Assets and liabilities.Will take part in financial statement.Contains real and personal accounts.External use.Prepared in financial period.Prepared in T-Format.Audit is necessary.Information on loss/profit is provided.Prepared by ... Read More
ConceptWith respect of a given array of integers, our task is to determine an integer B which isthe divisor of all except for exactly one element in the given array.It should be noted that the GCD of all the elements is not 1.Input arr[] = {8, 16, 4, 24}Output 8 8 is the divisor of all except 4.Input arr[] = {50, 15, 40, 41}Output 5 5 is the divisor of all except 41.MethodWe create a prefix array A such that position or index i contains the GCD of all the elements from 1 to i. In the similar way, create a suffix array C ... Read More
ConceptWith respect of a given set of elements, determine which permutation of these elements would result in worst case of Merge Sort?We know, asymptotically, merge sort always consumes O(n log n) time, but the cases that need more comparisons generally consume more time in practice. Now we basically require determining a permutation of input elements that would lead to largest number of comparisons when sorted implementing a typical Merge Sort algorithm.Example Consider the below set of elements as Sorted array 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26Resultant input array that will result ... Read More
ConceptWith respect of a given Balanced Binary Search Tree and a target sum, we write a function that returns true if there is a pair with sum equals to target sum, otherwise return false. In this case, expected time complexity is O(n) and only O(Logn) extra space can beimplemented. Here, any modification to Binary Search Tree is not permitted.We have to note that height of a Balanced BST is always O(Logn).ExampleMethodAccording to the Brute Force Solution, we consider each pair in BST and verify whether the sum equals to X. The time complexity of this solution will be O(n^2).Now a ... Read More
ConceptWith respect of given array Arr[] of non-negative integers, the task is to determine an integer X such that (Arr[0] XOR X) + (Arr[1] XOR X) + … + Arr[n – 1] XOR X is minimum possible.Input Arr[] = {3, 4, 5, 6, 7}Output X = 7, Sum = 10ApproachSo we will verify ‘i’th bit of every number of array in binary representation and consider and count those numbers containing that ‘i’th bit set to ‘1’ because these set bits will contribute to maximize the sum instead of minimize. As a result of this, we have to build this set ‘i’th bit ... Read More
ConceptNow the header file graphics.h contains fillpoly() function which is implemented to draw and fill a polygon such as triangle, rectangle, pentagon, hexagon etc. So this function require same arguments as drawpoly().Syntaxvoid fillpoly( int number, int *polypoints );In this case, number indicates (n + 1) number of points where, n is the number of vertices in a polygon and polypoints points to a sequence of (n*2) integers.Input arr[] = {320, 150, 400, 250, 250, 350, 320, 150};Output Explanation So the declaration of fillpoly() contains two arguments: number specifies (n + 1) number of points where n is indicated as the number of vertices ... Read More
ConceptWith respect of given positive number n, the task is to verify if n is a primorial prime number or not. We have to print ‘YES’ if n is a primorial prime number otherwise print ‘NO.Primorial Prime − With respect of Mathematics, a Primorial prime is defined as a prime number of the form pN# + 1 or pN# – 1 , where pN# is the primorial of pN such that the product of first N prime numbers.Input − n = 7Output − YES7 is Primorial prime of the form pN + 1 for N=2, Primorial is 2*3 = 6 ... Read More
ConceptWith respect of given positive integer n, the task is to verify if n is an Achilles number or not. We have to print 'YES' if N is treated as an Achilles number else print 'NO'.Achilles number: With respect of Mathematics, an Achilles number is defined as a number that is powerful (A number N is said to be Powerful Number if it has been noted that for every prime factor p of it, p^2 also divides it) but not a perfect power.In following, the first few Achilles number are displayed72, 108, 200, 288, 392, 432, 500, 648, 675, 800, ... Read More
ConceptWith respect of given number n, the task is to verify whether n is a Trojan Number or not. Trojan Number is defined as a number that is a strong number without a perfect power. We can say that a number n is treated as a strong number if, for every prime divisor or factor p of n, p^2 is also a divisor. We can say in another way, every prime factor appears at least twice. We should remember that all Trojan numbers are strong. But it is not true for vice-versa that means, not all strong numbers are Trojan ... Read More
ConceptWith respect of given infinite chessboard with the same rules as that of chess and given N knights coordinates on the infinite chessboard (-10^9 {3, 4}Output NoThe king can be able to make valid moves.MethodHere, the knight’s move is unusual among chess pieces. Its movement is towards a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. So, the complete move looks like the letter “L” in every shape possible (8 possible moves). As a result of this, apply a hash map of pairs to mark all possible coordinates where ... Read More