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.

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.

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.

30 Days to Build Your Bigger Email List Forever for $15

Now You Can Generate Massive Profits & Sales With Your Own Responsive Email List! Keep Reading to Discover A Simple 30 Day Plan To A Bigger Email List!The number one thing that nearly every successful online entrepreneur has going for them is that they have an email list. This is a list of subscribers that opted in to receive more information from you, to gain access to free training, or people that bought something from you.At one point or another we have all made our way to an email list. From the largest online retailers to the solopreneurs running a business from their living room, email marketing is still the number one way to engage and follow up with your audience.Social media has definitely changed the game a little bit, but email marketing is here to stay. What has changed is how people access their emails. So, don’t let anyone try to fool you into thinking that email marketing is dead.In fact, some companies, even major ones, credit over 75% of their sales directly to email marketing!If you have an email list and you create a product, have a coaching program, service, physical product, or webinar you want to tell people about; then you just send an email to your list for instant results! No more waiting for your paid ads to get approved or relying on affiliates to mail for you.Paid advertising and affiliates are a tremendous way to get traffic, but having your own email list is even better! That is why over the next 30 days this guide will teach you the same steps used by the experts to build an email list that pays you repeatedly!With 30 days to a bigger list you are well on your way to winning big online, and building that asset you need to help keep your income consistent. There has been one constant in the marketing world, and that is email! You must have an email list if you want to make it!

by: adamalsafi
Created: —
Category: eBook
Viewed: 130


Sharepoint Promoted Links – make bigger than default

I am trying to increase the size of my o365 promoted links. I have researched from css options and applied them onto the page using ‘script editor’ and can successfully increase the size of the tile and image.

However – my issue: The title displayed on the tile is longer than the character limit and cannot view it all. Note, I do not have a description underneath the title. Is there a way I can increase the size of the character limit.

My code is;

/* image dimensions */ .ms-tileview-tile-content img { width:160px !important; height:162px !important;

/* Tile and border size. Delta between ms-tileview-tile-root and size of the promoted link tiles is the space between tiles / .ms-tileview-tile-root { width: 200px! important; height: 200px !important; } / size of the promoted link tiles */ .ms-tileview-tile-content, .ms-tileview-tile-detailsBox { width: 200px !important; height: 200px !important; }

/* shadow behind text*/ div.ms-tileview-tile-content, div.ms-tileview-tile-detailsBox, div.ms-tileview-tile-content > a > div > span { height: 200px !important; width: 200px !important; }

/* Changes the Promoted Link Title when you hover over it*/ .ms-tileview-tile-detailsListMedium { font-weight: normal; height: 200px; padding: 8px 14px 14px; font-size: 18px; line-height: 14px; }

/* Adjust the text in the Collapsed Promoted Link / .ms-tileview-tile-titleTextMediumCollapsed { font-weight: normal; width: 180px; height: 200px; position: left; top: -50px; left: 0px; text-align: absolute; vertical-align: middle; font-size: 20px; / If you want to change the font size, change above */ line-height: 15px; word-wrap: break-word; }

Any help is much appreciated!

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.