Vipul
Did u even try to write ur code ?
Bro yes i will apply binary search, i will take low=0 and high=n then i will calculate mid=(low+high)/2 But now while comparing if A [mid]=mid+1 then it will be t then now i m struck in next condition that if A[mid]=mid then what to do?
Vipul
#howtoask
Bro the upper is my approach first clear my doubt i know it will be easier for you but not for me where i am struck i have mentioned above
Anonymous
What have you written so far?
I have written it thnks
detergentTikiya
Cool
Francisco
Vipul
We insist on the code, people try to get us to do their assignments and whatnot.
I am not asking for code and this is not my assignment buddy🥺, this question was asked to me in the interview, i am just asking the approach and nothing else i want to learn that thing which i don't know and you guys are thinking that i am making my assignment from you😒.
Vipul
We want code, not an approach. We can't run your approach, but we can run your code
And i am not asking you the code, i am asking you approach nothing else
Box of
haven't you already told us how to approach that problem?
Alvin
🤟
Sid Sun
Humans have arrived
kλletaa
how to quit nano
Stephanos
#howdoiquit
Anonymous
professor
Hey guys , does anyone know dynamic memory?
Stephanos
professor
i am using some right now
Are they work as linked lists always?
Stephanos
what? you mean,... is every heap element part of a linked list?
professor
I am learning internals about heap
Stephanos
ähm
Vladimir
Are they work as linked lists always?
Well, if you're coding in lisp...
professor
Is always dynamic memory behavior as linked list ? Prev - data and next ?
Stephanos
it is totally unordered :D
Stephanos
thats the thing with heap, right
Stephanos
you just want to put something, somewhere
Tom
Can anyone find the error here
Stephanos
Sai Meghana
i want to break an array into 4 parts such that the positive and negative elements are stored in different arrays... say -2 -3 4 0 -3 -4 5 6 7 should be stored as [-2 -3] [4 0] [-3 -4] [5 6 7]
Sai Meghana
i tried to use vectors
Sai Meghana
#include <iostream> #include <vector> using namespace std; int main() { int n,ele; cin>>n; vector<int> array; for(int i=0;i<n;i++) { cin>>ele; array.push_back(ele); } for(int i=0;i<n;i++) { cout<<array[i]<<" "; } vector<int> a; vector<int> b; vector<int> c; vector<int> d; int j=0; while(j<n) { while(array[j]>=0) { a.push_back(array[j]); j++; } while(array[j]<0) { b.push_back(array[j]); j++; } while(array[j]>=0) { c.push_back(array[j]); j++; } while(array[j]<0) { d.push_back(array[j]); j++; } } return 0; }
Sai Meghana
it gives a segmentation error
Stephanos
wt hell is wrong with people
Sai Meghana
:/
professor
For example if I want to add more data in function pointer which call malloc(64), but I send 300 it will break because their size causing an overflow right?
Vladimir
How about warn for no indentation code dear admin fellows?
Stephanos
How about warn for no indentation code dear admin fellows?
how about banning people not reading the rules :)
Stephanos
but what does that have to do with linked lists?
Vladimir
how about banning people not reading the rules :)
Here will be no activity then i suppose
Stephanos
Here will be no activity then i suppose
why then have rules in first place? maybe i am too german to understand that :D
professor
but what does that have to do with linked lists?
I thought it has , but what heap overwrite? The structure, objs, function pointers or a vtable? Is possible to know what is overwritting?
Ravi
In cpp cout object are call any other function?
Stephanos
I thought it has , but what heap overwrite? The structure, objs, function pointers or a vtable? Is possible to know what is overwritting?
well if i understand correctly, the loader gives your program an address to a memorylocation that you can pass data to
Stephanos
if you try to put in more data the OS kills you
Stephanos
overflow is no error
Stephanos
it is defined to break there
professor
In this case, what was overwritten as I know Buffer-Overflow is becuase EIP was taken for someone else?
professor
In debugger matter not at IDE level
Stephanos
what are you talking about. I cant follow you.
professor
I am trying to understand heap overflow internals how they works
Stephanos
a heap overflow, is a message that the OS sends to your shell, shortly after it terminated your process
Stephanos
when working on systems without OS, you can do whatever the hell you want with your memory and corrupt it as bad as you want. no brakes, no safety, no guarantee
professor
it can vary what overwrite instead of a classic one?
Anonymous
Who has programming asyncronous with C++?
Stephanos
of course it can vary what you overwrite, since there is no order in heap.
professor
as it is not static as stack based then it can vary their overwrites
Stephanos
look: you heap is just an unordered location. that looks a little bit regular to you, since most of the time you are dealing with virtual addressing. there is no guarantee about what is beeing put where, do you understand that? it is existential for the heap to be unordered
professor
yeap, I understand that part , but what was overwritten is the issue
professor
I will try to pick a book about advanced debugging
Stephanos
yeap, I understand that part , but what was overwritten is the issue
there are NO guarantees about what will be overwritten. NON
Stephanos
what ever you experience there, its most probably randomness
Mr.Anonymous
Where's practical?
Lelouch
#include<math.h> #include<stdio.h> int main() { double num, result; printf("Enter number : "); scanf("%lf", &num); result = sqrt(num); printf("Square root of %lf is %lf.", num, result); return 0; }
Lelouch
lf means?
Vladimir
a heap overflow, is a message that the OS sends to your shell, shortly after it terminated your process
No, if something gone wrong with memory (overflow, bad access, derefernce 0 after mallocing 0 if you out of memory), kernel sends SIGSEGV signal (means segmentation fault) to you, and then your program goto your signal handler, or to default handler (which quits you program and type "seg fault" message) if you didn't register any.
Vladimir
Uh, didn't know that, how do i define the Signal handler? Is that only linux or General OS behavior?
I think it's unix-like behaviour, don't know about signal behaviour in windows
Vladimir
To define handler use signal func
Vladimir
(man signal)
Stephanos
Okay... I'll Look at that. Thanks!