Number of subarrays of size k or less are encountered during Quicksort on average?

I am reading the book Analysis of Algorithms. The focus of chapter 1 is to analyze the running time of the original Quicksort algorithm. The code of this algorithm is given in the book.

public class Quick {    private static int partition(Comparable[] a, int lo, int hi)    {       int i = lo, j = hi+1;       while (true)       {          while (less(a[++i], a[lo])) if (i == hi) break;          while (less(a[lo], a[--j])) if (j == lo) break;          if (i >= j) break;          exch(a, i, j);       }       exch(a, lo, j);       return j;    }     private static void sort(Comparable[] a, int lo, int hi)    {       if (hi <= lo) return;       int j = partition(a, lo, hi);       sort(a, lo, j-1);       sort(a, j+1, hi);    } }  

There is an exercise at the end of chapter 1 asking the number of subarrays with size k or less.

How many subarrays of size k or less (not counting subarrays of size 0 or less) are  encountered, on the average, when sorting a random file of size N with quicksort? 

For simplicity, I will only count the subarrays with the size exactly k. My approach to this problem is building a recurrence equation. Let $ C(n)$ be the average number of subarrays with the size k encountered during quicksort. We have $ C(n) = \frac{2}{n}\sum_{i=1}^{N-1}C(i)$ . Simplify this equation using the same technique in the book, we have $ C(n)=\frac{n+1}{n}C(n-1)$ . Because $ C(n)=0$ with $ n<k$ and $ C(n)=1$ with $ n=k$ . So by expanding the equation and canceling the factor, we have $ C(n)=\frac{n+1}{k+1}$ . So the answer of the original problem is $ (n+1)(\frac{1}{2}+…+\frac{1}{k+1})$ .
Is this a correct way to solve this problem? Did I miss something in my arguments above?

Is CloudFlare full SSL less secure than Cloudflace full (strict) SSL?

I have a Linux shared hosting on Hostgator, and am using a Full SSL from Cloudflare which Encrypts end-to-end, using a self-signed certificate on the server.

  1. How secure is it?

  2. What are different options to enable full security if this method has any drawback?

Cloudflare has a stricter SSL option that is Full (strict) which Encrypts end-to-end, but requires a trusted CA or Cloudflare Origin CA certificate on the server, I’m not using it as of now.

Enjoy the best of adidas for less

Fireworks are a beloved part of Japanese culture, and to many sneakers are too, so adidas has combined the country’s affection for pyrotechnics and footwear to create a brand-new adidas ultra boost women with explosive detailing. The shoe’s clean white Primeknit upper offers a stark background to the bold multi-color firework graphic that graces each foot’s lateral heel, exploding all the way up to the collar and trickling down over the translucent heel clip. Another firework graphic is present on the medial midfoot as well, erupting behind the white leather midfoot cage. Finishing touches of country-specific style are provided by Japanese flag graphics on each tongue and a red Tokyo hit on the insole. A signature white Ultra Boost midsole and Continental rubber outsole then complete the look.
While most of this year’s Black History Month creations have come out of Nike’s camp so far, adidas is ready to toss their hat into the ring by way of an adidas ultra boost uncaged. Devoid of the influential silhouette’s customary midfoot striping, this model comes dressed in an off white hue with varying colors on its medial eyelets ranging from black, to purple, to red. However, the most intriguing part of this new Ultra Boost iteration is its “CBC” logo on its custom insoles anchored by a bright orange basketball with “Celebrate Black Culture” surrounding the emblem in bold purple lettering. While this model is indeed designed for BHM, its inspiration is kept more subtle than most, as it appears to be just another general release UB from the outside. 
Although adidas Originals has been focusing most of their attention on shoes that are slightly newer in their life cycle, the ever-popular adidas nmd r1 mens sale is still chugging along unimpeded, and now it’s appeared in a new makeup that offers glossy pops of metallic gold. A likely homage to the most iconic colorway of the adidas Superstar, these adidas NMDs feature a white base with black accents on the midfoot’s three stripe graphic, the heel piece/tab, and the tongue badge. Bold hits of metallic gold then grace the rear bumper, as well as providing further embellishment on both the tongue and the front bumper. A full-length white Boost footbed provides signature cushioning, while a black outsole finalizes the look. 
Although adidas outlet has mostly been celebrating 30 years of Torsion tech by re-releasing classic models, they’re looking towards the timeless support system’s future as well, and aiming to begin its next chapter in earnest with a new silhouette dubbed the Torsion X. At first glance, the Torsion X certainly cuts a bold figure, one that draws bits and pieces from other Three Stripes lifestyle favorites. Both the tongue and the circular suede eyestays are reminiscent of Kanye West‘s adidas Yeezy 500, while the plastic tube that wraps around the asymmetrical lacing system and heel gives off serious adidas Ozweego vibes. The rest of the upper features a layered combo of synthetics and suede, while a bold branded hit appears on the tongue.

Pushdown Automata for number of a less than 2 times number of b

Suppose we want to design a pushdown automata for $ L=\{x \in \{a,b \}^{*}:|x|_a<2|x|_b \}$ , can anyone check whether my automata works?

we have 4 states $ \{q_0,q_1,q_2,q_3 \}$ , three stack symbols $ \{S,A,B \}$ , start state $ q_0$ , accept state $ q_3$ , we have rules as following: $ q_0$ accepts nothing and push $ S$ onto stack to $ q_1$

$ q_1$ reads $ a$ and pops $ B$ , remain in $ q_1$

$ q_1$ reads $ a$ and pushes $ A$ , remain in $ q_1$

$ q_1$ reads $ b$ and pushes $ BB$ , remain in $ q_1$

$ q_1$ reads $ b$ and pops$ AA$ , remain in $ q_1$

$ q_1$ reads $ b$ and pops$ A$ and pushes $ B$ , remain in $ q_1$

$ q_1$ reads nothing and pops $ B$ , go to $ q_2$

$ q_2$ reads nothing and pops $ B$ , remain in $ q_2$

$ q_2$ reads nothing and pops $ S$ , go to $ p_3$

Given an array of non-negative intergers, find number of sub arrays of all sizes(1,2,..n) with sum less than k

My approach: arr is the input array, ans is the final array, ans[k] denotes number of subarrays of size k+1

int s =0,e=0,count=0,sum=arr[0]; int ans[n]; memset(ans,0,sizeof(ans)); while(s<n && e<n) {     if(sum<=k)     {         e++;                 if(e>=s)         {          ans[e-s-1]+=1;         }          if(e<n)         sum+=arr[e];     }     else     {         sum-=arr[s];         s++;     } }   for(int i=n-2;i>=0;i--)   ans[i] += ans[i+1];  for(int i=0;i<n;i++)  cout << ans[i] << " ";    


I don’t understand what are the cases that I may be missing here.

Less clicks or less choice?

I’m currently working on a new IA for a webshop. I’ve drawn out two examples.

OPT 1 (option 1) (more a flat(ter) hierarchy)

This ‘could’ be our new IA (it’s restructured). More choice (of categories) at the beginning and it takes a maximum of 3 clicks in order to get to the PDP.

OPT 2 (option 2) (more a deep hierarchy)

Our ‘old’ version of the IA. Over-all less choice, but it takes on average one more click in order to get to the PDP.

Main difference between them: OPT 2 has an additional three (generic) main categories at the beginning, that were deleted in OPT 1.

QUESTION: What would be the better solution here: have less clicks but more (specific) choice, or more clicks and less (generic) choices?

Personally I think, OPT 2 starts with three too generic category names that are confusing for clients and they don’t exactly know what to expect. But I’m not sure if starting with 8 specific categories, would be too much for users and impact their cognitive load because it’s too overwhelming.

Sadly we can’t test prototypes with end users at this moment.

Looking forward to your input.

P.S. the arrows stand for navigation possibilities to direct jump to (for example) PLP from the start.

enter image description here

remove the background of your photos in less than 1 day 5 PICTURES for $5

Are you looking for best photo background remover? You are at the right place. I will remove background from images professionally, using manual selection and advance techniques. Also, I will professionally edit, resize, retouch, enhance your products photos to catch the customers and boost up your product sell.

by: iso076
Created: —
Category: Link Building
Viewed: 452

I will remove the background of your photos in less than 1 day 5 PICTURES for $3

Are you looking for best photo background remover? You are at the right place. I will remove background from images professionally, using manual selection and advance techniques. Also, I will professionally edit, resize, retouch, enhance your products photos to catch the customers and boost up your product sell.

by: iso076
Created: —
Category: Link Building
Viewed: 148

Is odd-numbered damage that’s halved then doubled the same value as before, or one less?

Let’s say there’s a Dust Mephit at full health that was hit by the Fireball spell and made the save. The damage on the die is low at 17, so the fire damage is halved. But, Dust Mephits are vulnerable to fire damage, so it’s doubled again. Does the rounding happen after the final total, and it stays at 17? Or does rounding down happen after each step, reducing it to 8, then double to 16?

Does anyone have a good way to allow a Necromancer to summon more powerful undead at the cost of summoning less of them? [on hold]

I have a Necromancer that is starting to get a decent size army of undead going. It works great, he mainly uses his other spells to fill the support/buff/debuff role and uses the undead as his main source of damage. The only downside is it is starting to slow down combat.

Does anyone have any good homebrew/ house-rules they use to let the Necromancer summon stronger undead but less of them to keep combat flowing?