Anonymous
Ah, ok. Too complicated for me
So, you got it or still you're in doubt?
Pavel
So, you got it or still you're in doubt?
I found an answer but it rather disappointing, because I don't see anything in the description about it. They want your sort to be stable (to keep the order for the elements with the same solved value).
Pavel
So in other words just use stable_sort
Anonymous
So in other words just use stable_sort
I think you can change the code inside the "cmp" function to make it stable.
Anonymous
And that's what I am looking for.
Anonymous
Is there any way to modify the cmp function to make the sort a stable one?
Anonymous
Or you use sort to make the array in increasing order and print it in reverse manner? But, I don't know why this idea of mine didn't work.
Pavel
Is there any way to modify the cmp function to make the sort a stable one?
I don't think so, If the algorithm itself is unstable then it won't help. I guess it's not 100% of time true, but as far as I know it's the case of std::sort and std::stable_sort
Anonymous
I hope that the "cmp" inside the sort() works in the way that it lets greater element go before the smaller element and if they are equal then it doesn't change the order.
Anonymous
@gameraccoon I hope this is true. or else you can correct me.
Anonymous
because on being equal it returns false.
Anonymous
I read that returns ​true if the first argument is less than (i.e. is ordered before) the second. Does that mean that the first argument is always to the left in the original array and 2nd agument to the right side in the array ?
Anonymous
Which one is faster and why? 1. Accessing a globally declared array. OR 2. Accessing an array through pointer passed as a function parameter.
Pavel
Can you tell how does the std::sort() work when it returns false?
You mean if cmp returns false? To know that we need to know the exact algorithm used in your compiler implementation. https://stackoverflow.com/questions/5038895/does-stdsort-implement-quicksort Let's guess that it uses quicksort. https://en.m.wikipedia.org/wiki/Quicksort You can see that the algorithm decides whether the element goes to one block or stays in another. If the element is equal to the "pivot" it doesn't check for the equality (for the efficiency). So all equal to the pivot values will go either to the right or to the left (depending on your comparator I think). This way the order of equal elements can't be preserved without adding more logic to the algorithm (so making it slower)
Pavel
Yep
Anonymous
👍
Anonymous
@gameraccoon BTW, Below is the classic way to make the sort stable or unstable by making changes in the cmp function https://pastebin.com/P1cDNgwx
Anonymous
But, it isn't allowed in that problem bcz then I'll be adding a line there.
Pavel
@gameraccoon BTW, Below is the classic way to make the sort stable or unstable by making changes in the cmp function https://pastebin.com/P1cDNgwx
Well, this more than changing the comparison function alone, you adding new data so you don't have equal elements anymore.
Pavel
I mean second. But I think I understood what you wanted to achieve there. You probably could do comparison like a.solved == b.solved ? a.idx > b.idx : a.solved > b.solved; Or something like this
Pavel
This way it should be allowed by the rules I think
Anonymous
/rules
Ghost🔥
Hey does anyone here know how to load Pyth0n trained ml models into c++? I've looked it up on the internet and it's said to be possible but I haven't found any implementations is there anyone here who can help?
rex
rex
give the logic
I_Interface
give the logic
It's easy, use 2 arrays or 2 string.
Dima
/ban Free ban for you
rex
ya but i get 5 twice in the output
Anonymous
Hello
german oak
german oak
german oak
algorithm
Can c++ be used to make android apps 😁
Droid
Yes
how
algorithm
Yes
Effectively??
Anonymous
how
#googleit
Nameful
how
I'm not sure everything can be done in C++, but I was able to run C++ code in the Android emulator that Android Studio provides
Nameful
The Android API might not be available for C++ wtihout a wrapper
Nameful
I would suggest using Java or Kotlin for Android development unless you're making a game
Droid
if it was java fine but c++ these two things have difrent rullings maybe a call can be done anyway its a research to try out
Nameful
Yeah, that works too
Nameful
if you use Flutter anyway
Nameful
I believe Kotlin and Java are more performant however
Anonymous
I use C++ for everything, even for Android development with NDK
algorithm
Yeah, that works too
Between java/kotlin/Dart... Which one is the best?
Droid
I believe Kotlin and Java are more performant however
if u knw what to do u can play around with anything just knw to me c++ looks like is a mother to all languages and it btw gives a basic knowledge on how to implement other things in any language so i think it can be done
Nameful
Between java/kotlin/Dart... Which one is the best?
Kotlin is a neater version of Java. Both run on the Java Virtual Machine. Dart is a language that compiles to JavaScript.
Deleted
can someone help me on this problem...this is past final test...i am newbie on using array
Anonymous
and it has been always the mother
Anonymous
C++ was born in 83 I think. C was born in 72 but assembly, no one knows the birth day
Anonymous
?
Anonymous
well, I know. I just said that just for fun :D
Anonymous
It was something in the fifties
Vikky
In c main function called every function but who called main() ?
Anonymous
the Operating System calls it when load the program in memory
Anonymous
when you run the program, it automatically loads the program into main memory, then, it calls the main function because is the only one that cannot be declared
Anonymous
there are a lot of steps
Anonymous
linker, loader, scheduler, ...
Vikky
Ok it means kernel or anything else!
Anonymous
yes, the kernel mainly
Vikky
I am beginner in programing field how I can improve my skills plz guide
Anonymous
read books and practice
Anonymous
the best books for C++ are from Stroustrup