Time Complexity of Super Simple GCD
When I need to calculate the greatest common divisor of two integers, instead of using Euclid’s algorithm or the binary GCD algorithm, I will sometimes use this super-simple algorithm:
Heavy-light decomposition algorithm modification
Let the weights in the tree be not on the vertices, but on the edges. Show how you can solve problems using HLD in this case
.
Maximum valued expression of operands and operators, where expression respects order
Operands and Operators are arrays containing a sequence of numbers and a sequence of
mathematical operations such as addition, multiplication. Expressions are formed by using
all operators and required amount of numbers, in their original order. They are evaluated
by bracketing from the right end.
Example expression: (3*(5+9)) which evaluates to 42. Invalid
expressions: (3+(5×9)), ((3×5)+9), (1x(3+5)) .
Is there an efficient algorithm for this problem? If yes then what is it?
Smaller exicographically sequence of advertisement that can be formed from given pairs of advertisements
Recently I gave Flipkart Online assessment and I was stuck at a question for a very long time. The question goes like this. An advertisement company has array of pairs of advertisements and each advertisement should be played one after another. It will be beneficial for the company to start from “ABC” advertisement if given. We have to find the sequence in which all the advertisements should be played for once. If multiple such ways are possible give Lexicographically smaller one.
Algorithm to distribute text
Im trying to replicate a algorithm of a game, basically the method should take a text and a number. The method is expected to return an integer array with the number of elements specified by the second argument. The sum of all elements in the integer array should exactly match the length of the text string argument. The challenge lies in the logic, as each element in the array represents a portion of the text string, and the sum of these portions should equal the length of the text string but not orderly.
Lay out paper as square as possible
Given a sheet size, say 210×197 and a number of sheets to lay out, let’s say 12 what is the algorithm that would lay them out in a way that the total width and height are as close as possible? in other words so that the sheets form a shape that is as square as possible?
What ist the difference between n and n-1 in algorithms?
enter image description here
I need help coming up with an algorithm for this problem
You are given 4 parameters
Algorithm Divide and Conquer Maximum Subarray
An IT company wants to perform an analysis of revenues and expenses
of in a period of n months. The information is given in a list A[1], . . . , A[n] with
integer values. In month i the company had a deficit or surplus which corresponds to someone
positive or negative integer in position A[i]. The goal is to find a continuous interval
months with the maximum total profit for the company. Here are three examples:
(aʹ) A = [30, −50, 20, −50], where the interval with maximum total profit is from month
1 until month 1, with a profit of 30,
(bʹ) A = [30, −5, 20, −50], where the interval with maximum total profit is from month
1 until month 3 with a total profit equal to 45,
(cʹ) A = [30, −50, 20, −5, 40], where the interval with maximum total profit is from
month 3 up to month 5 with a total profit equal to 55.
Design an efficient divide and conquer algorithm. To
analyze for correctness and complexity, describing and solving the retro-
bit relation that expresses the time complexity of your algorithm.
What is a good algorithm for placement of text labels near objects?
I have a rectangular map filled with objects of different sizes which each have a corresponding text label that must be placed as close to them as possible while not overlapping with any text labels or objects. The text can also be rotated 90 degrees if needed.
The specific case involves placement of text on a pcb board, where the objects are components and the text labels are there names.