## A linear time algorithm to find the array of indices of bigger numbers

Suppose you have an array nums of integers, unsorted, containing the values from 1 to n. You have a second array, call it firstBigger, initially empty, which you want to populate with integers such that firstBigger[i] contains j if j is the least index such that i < j and nums[j] > nums[i]. A brute force search of nums runs in n^2 time. I need to find a linear time search.

For example, if nums = [4,6,3,2,1,7,5] and we use 1-indexing, then firstBiggest = [2,6,6,6,6,None,None].

I have considered first computing the array of differences in linear time. Certainly anywhere in the array of differences with a positive value, this indicates a place in firstBigger where it should store i+1. But I’m not seeing how to fill any other coordinates efficiently.

I might have gotten close when I started thinking of analyzing the array end-to-start. The last nth coordinate of firstBigger is going to be None, the n-1th has to be directly compared to the nth. As we proceed backward, if the number at i is smaller than at i+1 we make this assignment. Otherwise we look up the first number bigger than the one at i+1. If that’s still too small, again look up the first number bigger than that.

On average this does better than the naive algorithm, but in the worst case it’s still n^2. I can’t see any room to optimize this.

Posted on Categories proxies

## Find a threshold such that one function is always bigger than the other

Given the recursively defined function $$c$$, which I believe is a variant of the Péter-Ackermann function: $$c(m,n)=\begin{cases}0&\text{for }m=0\ n^2+n+1&\text{for }m = 1\text{ and }n\ge 0\ c(m-1, 1)&\text{for }m>1\text{ and }n=0\ c(m-1,c(m,n-1))&\text{for }m>1\text{ and }n>0\ \end{cases}$$

and the function $$d$$ that builds a “tower” of powers of $$2$$ of size $$n+2$$:

$$d(n) = \underbrace{2^{2^{.^{.^{.^{.^{2}}}}}}}_{\text{ n+2 }}$$

The inputs $$m$$ and $$n$$ are both natural numbers. I’m asked to find an $$x$$, such that for all numbers $$y \ge x$$, $$c(y,y) > d(y)$$.

I rewrote the two functions using Python in order to calculate some values:

 c(m, n):     if m == 0:         return 0     else if m == 1 and n >= 0:         return n**2+n+1              # return n^2+n+1     else if m > 1 and n == 0:         return c(m-1, 1)     else if m > 1 and n > 0:         return c(m-1, c(m, n-1))  
 d(n):     exp_num = n-1     result = 2     while exp_num != -1:         result = result**2           # result = result^2         exp_num = exp_num - 1     final_result = 2**result         # final_result = 2^result     return final_result  

Some inputs and outputs:

c(1, 1) = 3

c(2, 2) = 183

d(1) = 16

d(2) = 65536

d(3) = 115792089237316195423570985008687907853269984665640564039457584007913129639936

I believe the threshold is $$3$$, as c(3, 3) doesn’t seem to be realistically computable considering there are over 19K digit in A(4, 2) (where A is the Péter-Ackermann function). Unfortunately I have no idea how to prove this. Any help would be much appreciated.

Posted on Categories proxies

## Given two functions, find a threshold such that one is always bigger than the other

I’ve written the following two functions in Python (they should also be fairly easy to understand as Pseudo):

 c(m, n):     if m == 0:         return 0     else if m == 1 and n >= 0:         return n**2+n+1              # return n^2+n+1     else if m > 1 and n == 0:         return c(m-1, 1)     else if m > 1 and n > 0:         return c(m-1, c(m, n-1))  
 d(n):     exp_num = n-1     result = 2     while exp_num != -1:         result = result**2           # result = result^2         exp_num -= 1     final_result = 2**result         # final_result = 2^result     return final_result  

Where the inputs m and n are both natural numbers. I’m asked to find an x, such that for all numbers y >= x, c(y,y) > d(y).

Some inputs and outputs:

c(1, 1) = 3

c(2, 2) = 183

d(1) = 16

d(2) = 65536

d(3) = 115792089237316195423570985008687907853269984665640564039457584007913129639936

As you can see d grows extremely faster than c, which I believe is a variant of the Péter-Ackermann function. How can I approach this problem? Any help would be much appreciated.

Posted on Categories proxies

## How to Make boot directory bigger?

I have plenty space on my HD 420 GB but very little for boot directory & i can’t upgrade to ubuntu 16.04 what is the eseyist way to inlarge the boot directory?

Created: —
Category: eBook
Viewed: 130

## product image getting bigger as the gallery image number increases magento 2 and vise versa

product image getting bigger as the gallery image number increases magento 2 and vise Versa How to make the product image load in big size no matter what number is the product gallery number??

enter image description here Posted on Categories buy best proxies

## Copy an OS drive with all it’s partitions, to a bigger hard drive

I have a windows machine, and it’s OS is alingside with the a few more partitions on one hard drive.

I want to use Ubuntu live cd, in Order to copy that OS drive to another, bigger hard drive and utilize that space.

I managed to copy the drive using ddrescue and it works fine, but then I have a lot of un utilized space on the new bigger drive.

I would like to os partition To use all the extra space

I tried to copy the partitions using Gparted and resize the OS partition, the system did not boot afterwords

I tried to use ddrescue to copy the drive, and then Gparted to change the partition’s size, But it’s not the last partition on the disk, so I could not, When I tried to resize the other later partitions and then “make room” for that partition and then resizing it, the machine did not boot afterwords.

How can I copy the drive, and keep it bootable, allowing one partition use all the extra space I have on the larger disk?

Thanks

## (JAVA) Bigger number than allowed as “int”. No error message

I´ve written the following code to test the limits of an int variable:

package com.company;

public class Main {

public static void main(String[] args) {      //minimun int value     int minValue = -2_147_483_648;       //2 times minimum int value     int doubleMinValue = 2*minValue;      //print both     System.out.println(minValue);     System.out.println((2*minValue));  } 

}

And I got the following result:

-2147483648

0

Process finished with exit code 0

I was expecting to receive a ERROR MESSAGE, but I received a WRONG ANSWER. What is the Java logic in this case ?

Thanks.