Onur
/get cppbookguide
Pavel
/report scam
Liam
/ban for ad
Pavel
/report the same scam
Liam
/ban for ad
Liam
Aman
Can anyone tell me that where I am getting wrong .Source code to this problem is below
Aman
Aman
Aman
https://hastebin.com/vudeluroro.pl
NB᭄Navin
Hi
Anonymous
Welcome to the group
Aman
@lightness_races_in_orbit thank u for help
Cengizhan
Problem is actually your implementation way as well. Think much smarter than this solution :) How did you find middle element in linked list?
gjgjtuy
thanks a lot👍 you really save my day
Cengizhan
Sorry.
gjgjtuy
Aman
John no my real name is something else
Cengizhan
I would do in that way, define two pointers. One of them traverses the next element one by one. Other one traverses next element two by two. Second pointer reaches to the end, first one should be on the middle one.
Cengizhan
Node *first = head;
Node *second = head;
first = first->next;
second = second->next->next until second != Null.
gjgjtuy
Cengizhan
Why?
Cengizhan
No, if list size is even, first middle should be deleted? If size 5 and next->next will be null already. So no need to go further, still will be deleted first of 2 middle element.
Cengizhan
Then please read this, this is known problem already asked by many companies in different ways..
https://medium.com/@atworksunil/delete-middle-of-linked-list-42994cb5b10c
Anonymous
!report
King
This message is a mistake. There's a bot sending messages automatically
Anonymous
i have a solution similar to the one he is talking about that should work.
increment first pointer once
if first pointer is null -> list is even, delete middle element
increment middle element pointer
increment first pointer again
if first pointer is null -> list is odd, delete middle element
repeat
King
I just signed up on some random link & it sent messages to every platform & contact I have
King
Thanks
Cengizhan
Please read this one, and it works!
https://hastebin.com/gonimuvazi.cpp
Anonymous
1->2->3->4->5
1 and 2
2 and 4
increment -> 4 becomes 5, not null
increment -> 2 becomes 3
increment -> 5 becomes 6, null. delete 3
1->2->3->4
1 and 2
2 and 4
increment -> 4 becomes 5, null. delete 2
Cengizhan
Of course, it was a just pseudocode to explain how to find middle element in the linked list with this trick.
Anonymous
i wasn't debating lol. just found a variation to his original pseudocode, so shared
Wojak
Hello
I want someone to help me with my test on C/C++.
I will pay him for the code.
Ping me if someone is interested.
Shivansh
👍
Prasad
Can anyone slove this pseudo code ?
Artöm
I assume ^ is power here
Prasad
Artöm
Prasad
I don't know the process ??
Artöm
Do you know how to calculate binary representation of a number?
Artöm
Like 5 -> 101
Prasad
Yes
Artöm
Its same with 8 instead of 2
Prasad
Ok
inkfil
Can somebody explain me from line 44 through 48
Cengizhan
Cengizhan
Or sometimes giving name is make them more understandable.
inkfil
I have seen using-declaration on cppreference but here it says that it works with inheritance
inkfil
But this class doesn't inherent
Cengizhan
For e.g;
std::map<int, std::vector>>
Cengizhan
Each time writing this make you annoyed, so giving name as a context phonemap, studentmap for example.
Cengizhan
inkfil
Cengizhan
Okka
Can anyone here give me some advice on how to master DSA
Anonymous
Okka
Data structure and algorithm
Anonymous
It doesn't relate to C++
Okka
inkfil
Thank you!
https://github.com/prakhar1989/awesome-courses
Anonymous
Hi
klimi
Jaen
Anonymous
Hellow world
Anonymous
/get ide
Anonymous
sorry :(
Ashish
Anyone doing hackerearth circuit july
Ashish
3rd problem anyone....
Pradip
OK I understand.... thank you 😊😊
Diego
Ok.
Pavel
I noted that MSVC generates different disassembly for these two cases:
https://godbolt.org/z/bsn93G
As far as I know conditional jumps are bad for branch predictor and unnecessary conditional jumps are better to be avoided.
In this case I expected that the compiler will not do short-circuit evaluation because it's only float comparisons (shouldn't they be simple enough?).
Can someone explain why the compiler didn't get rid of the jumps and didn't make it the same with the second variant? Does the second variant have some disadvantages?