## performance – Writing a stable sorting algorithm that can sort a binary array in O(n) time complexity and O(1) auxiliary space complexity

So I was able to write a stable sorting algorithm that can sort a binary array in O(n) time complexity and O(1) space complexity, but it works only if we assume that our array can store integers that are not only 0, 1.

Here is the algorithm:

``````#include <stdio.h>
void binarySort(int arr(), int arr_length)
{
int i, count=1;
for(i=0 ; i<arr_length ; i++) // counting number of 1's in array and ordering them.
{
if(arr(i)==1)
{
arr(i)=count;
count++;
}
}
int num0s=arr_length-count+1; // number of 0's in array
int j=0;
int k=0;
while(j<num0s) // bringing the 0's to the front of the array by swapping them with the 1's
{
if(arr(k)==0)
{
int temp=arr(k);
arr(k)=arr(j);
arr(j)=temp;
j++;
}
k++;
}
int a;
for(a=0 ; a<arr_length-num0s ; ) // sorting the 1's to make the overall sort stable.
{
if(arr(num0s+a)!=a+1)
{
int temp=arr(num0s+a);
arr(num0s+a)=arr(num0s+temp-1);
arr(num0s+temp-1)=temp;
}
else
{
arr(num0s+a)=1;
a++;
}
}
}

void main() // example of algorithm working
{
int arr()={1, 0, 0, 1, 0, 1, 1, 0, 0, 1};
int i;
for(i=0 ; i<10 ; i++)
{
printf("%d ", arr(i));
}
printf("n");
binarySort(arr, 10);
for(i=0 ; i<10 ; i++)
{
printf("%d ", arr(i));
}
}
``````

Now if we consider that our array cannot store any other values other than 0, 1, can we make a sorting algorithm that is stable while preserving its O(n) time complexity and O(1) auxiliary space complexity? No matter what I try in this case, it always seems like at least one of these properties cannot be satisfied.

A little context as to why I want to find an algorithm with these properties is that I want to make a binary radix sort algorithm using the stable binary sort algorithm as a subroutine.

## output formatting – Writing mathematical expression in a file

I am trying to write a mathematical expression as `variable = expression` in the output file.

The current method that I am doing is through `WriteString` as

``````expr = -((a*b*y^2*(-1 + z)*z*(1 + a*b + z))/(1 + a*b)^2) +
(z*(1 + a*b - a*b*z + (z + a*b*z)^2))/(1 + a*b)^2 -
(y*z*((-1 + z)^2 + a*b*(2 - 3*z + z^2) + a^2*b^2*(1 - z + z^2)))/(1 + a*b)^2
expression = CForm(expr) /. {Power->pow};
(*expression = CForm(HornerForm(expr)) /. {Power->pow};*)
str=OpenWrite("output.hh");
WriteString(str," double variable = ", expression,";");
(*WriteString(str," double variable = ", ExportString(expression,"Text"));*)
Close(str);
``````

The output is

`````` cat output.hh
double variable = -(a*b*(-1 + z)*z*(1 + a*b + z)*pow(1 + a*b,-2)*pow(y,2)) - y*z*pow(1 + a*b,-2)*(pow(-1 + z,2) + a*b*(2 - 3*z + pow(z,2)) + pow(a,2)*pow(b,2)*(1 - z + pow(z,2))) + z*pow(1 + a*b,-2)*(1 + a*b - a*b*z + pow(z + a*b*z,2));
``````

I want to break the line as the original `expr` (or after some user-specified column say 80) i.e.

`````` double variable = -(a*b*(-1 + z)*z*(1 + a*b + z)*pow(1 + a*b,-2)*pow(y,2)) -
y*z*pow(1 + a*b,-2)*(pow(-1 + z,2) + a*b*(2 - 3*z + pow(z,2)) + pow(a,2)*pow(b,2)*(1 - z + pow(z,2))) +
z*pow(1 + a*b,-2)*(1 + a*b - a*b*z + pow(z + a*b*z,2));
``````

Although this might not lead to optimized expression for numerical evaluation, however it is wanted as beautification.
Also how should one optimize expression for further processing to other languages. Any suggestion? `Experimental`OptimizeExpression` and `HornerForm` are some options. Any other recommendation? `MathCode` is much costly ðŸ˜€

## Get 3 exclusive original articles for your blog or website for \$10

#### Get 3 exclusive original articles for your blog or website

• If you are looking for unique and exclusive articles for your blog or for your site … then you are in the right place .. I will provide you with an exclusive article 100% original and free of plagiarism..you can use it anywhere and at any time this article is exclusive I write with my hand …

Professional writer with a prestigious university degree .. In addition to my 5 years of experience in this field … I can provide you with articles, blogs and website writing services for high-quality SEO ..

What you will get 3 unique and exclusive articles I write with my own hands … on any topic you want, and 1 article consisting of 700 to 100 words

Specifications Original content Outstanding quality Not plagiarism Exclusively written by me Unlimited reviews

.

## 1000+ words SEO Friendly Unique Content Writing/Blogs Post/Articles Writing for \$5

#### 1000+ words SEO Friendly Unique Content Writing/Blogs Post/Articles Writing

CONTENT is the SOUL of all types of Business, If you need a Unique Plagiarism free and 100% Grammarly error free Article for your website or blog. Are you looking for a multi-talented SEO friendly content writer to handle your multiple niches and write impeccable articles, blog posts, or content on any topic? You are landing right Place.

When you order from me, you can expect content that is:

• 100% original – A unique, compelling piece.
• Engaging & accurate â€“ Capture readers’ attention & prompt conversions.
• SEO-friendly â€“ Reach your audience and get web traffic.
• On-time â€“Delivering early is a top priority.
• Proofed â€“All content is proofed more times before delivery.
• Exciting- Content is designed to share your message effectively.

I have experience in Writing:

• Content writing
• Keyword Analysis
• Keyword search volume Analysis
• Keyword CPA ratio Analysis
• Competitor Analysis
• Web post Writing
• Digital Marketing
• Social Media Marketing
• Search Engine Optimization
• Technology Product Marketing
• Beauty and Fashion Product Marketing
• 100%CustomerSatisfaction Guarantee, or Money Back Guarantee

Why hire me:

• Fluent in English & Bengali
• Well-optimized content
• 100% Effective Result
• 100% customer satisfaction
• Unlimited Revisions

I mean your problem is solved? So, why you are waiting for? Simply Inbox me
Thank you very much

.

## Drive huge traffic to your business by effective articles for \$5

Looking to skyrocket your traffic business or start your new online business ,in either case you find the suitable article/script you need.with Sherifbenaziz articles/scripts you will start an endless stream of visitors from all around the world.it is just a matter of seconds.

So please hiting START & letting it RUN.

.

## Best practice for writing data in Python / Pandas

I need some general advise regarding best practice for writing data into my MongoDB –

My project is the following:

• Read some 3 very large CSV files 300K records each

• Clean up the data

• Perform data wrangling and join the data and load into a data frame

• Perform analysis

• Application must maintain state of data on Exit

• The application must be run in Jupyter notebook but have a Tkinter GUI for loading the files and data clean up buttons.

• GUI must be able to request data stats and correlation graphs etc.

Is the following design okay?

Data:

• Convert the data to JSON as soon as read from CSV, check for duplicates in database and insert if unique

• Load data into data frame from Database,

• Perform clean up ,

• Amend database record at the end

Sorry if these are basic questions I am quite new to doing real python work and don’t want to go down the wrong path

## 1000 Words Article Writing, SEO Writing, Contents Writing, Blog Writing in Any topic for \$5

#### 1000 Words Article Writing, SEO Writing, Contents Writing, Blog Writing in Any topic

Hi,

I am a Professional content writer for the last 7 Years. I have writing articles on different platforms like a writer, Medicine, Finance, Sport, health and etc

All my contents area unit partaking enough to urge the eye of the social media community and additionally rank well on search engines. What you get SEO articles, journal writing and blog writing and content writing.

Some highlights are:

100% Original Content!

No plagiarism!

High Quality and Well Researched

Ghost Written, you’ll receive the ownership

SEO Optimization via LSI, no keyword stuffing

No Spelling/Grammar Mistakes

Why me?

Who will give you more? I am a fluent English Speaker and Writer. I have over 5 years of writing experience. When you place an order with me, you will get top Quality SEO Articles of 1000 words in length with free revisions if needed.

I like writing and it will be a pure pleasure to work for you.

.

## HDD Raid 0 frozen for writing for ~30 seconds on big files

I have a several raids: RAID 0 SAS HDDs (each connected via 6Gb — SAS-2).
And 5+0 raid of SATA HDDs.

Both raids provide good read performance, but when I write to them, they start at insanely high speed (~1GB per second!). After some time, they become stuck for ~30 seconds. And then continue.

Write buffer is enabled.

Raids are from different vendors (Adaptec and IBM).

I believe they write data to the buffer and then need some time to flush it.
It is reproducible only on huge (~ 20GB) files

Question 1: is it true? How can I profile/proof that fact?

I tried both: local access (copying from one raid to another and vice versa) and network access (via 10Gb network).

Effect is the same:

• 1GB/s
• After some time 0B/s
• After some time ~600MB/s
• And again.

I limited my network speed to 1Gb and got stable performance, although not very fast.

Users are angry when copying process is frozen, so my question is does it work as it should?
If so, what can we do except migrating to SDDs (30TB of SSDs are expensive) or limiting my network speed?

We spent some time improving our network performance (by enabling RSS, jumbo frames, migrating to latest SMB version that supports multiple threads etc) and we now have ~9.7Gb/s with `iperf3` between client and server.

Question 2: Is it possible to have at least 300/400 megabytes per second for writing with 10 or 50 on HDDs? Shouldn’t we have ~150MB/s for each disk, 300MB for 2 HDDs in RAID0? Big files utilize sequental access, aren’t they?

Question 3: RAIDs have huge stripe size (about 1MB). I heard that some vendors optimize their controllers for the default stripe size only. Is it true?

## How are writing shaders different in Unity’s scriptable render pipeline vs the standard pipeline?

So I want to start learning how to write shaders because the shadergraph seems very limited at the moment. I’ve done some research and it seems that I should learn the HLSL language which is used by Unity. I’m becoming confused though how this will carry over between pipelines. I read that standard pipeline shaders aren’t supported in URP so I’m confused how the shader language is different in URP if they both use the HLSL language. I was wondering if someone with a better grasp on this could explain the difference between them and if the skills carry over, as most tutorials online seem to be for writing shaders in the standard pipeline. Thanks.