Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Everything is just a multi-dimensional array in my head. Sometimes associative, sometimes numerically indexed, but always that same multi-dimensional array.
After that it's just syntax. -
@IntrusionCM I'm trying to implement a Stack in Java using classic arrays. Don't worry though, I'm trying to get there on my own.
In the beginning it worked when I expanded the array by creating a new one and switching references, but now it doesn't work anymore when I don't use that system. Right now I'm having issues with using indexes to keep shifting pushed values around. A stack should be: D C B A, not A B C D. Currently have B A A. It's a bug, so yeah, figuring that out. lol. -
@IntrusionCM Okay I solved it.
Problem 1:
For each item on the stack, assign it to item+1 index and then assign index 0 to the newly added item.
This copies item0 to item1 and item1 to item2, but then leaves a bug where item1 and item2 are now the same because item0 didn't change index yet.
Problem 2:
You iterate through the array, but when you reach the end of the array, you get a boundary error because you're trying to assign the item in the next slot, which doesn't exist.
Solution:
Iterate negatively in reverse: keep reassigning indexes in reverse until there are no more items to process. Avoids boundary error. -
@CaptainRant ah.
I like to play with my text markers for stuff like that.
As each text marker has it's own color it's easier to visualize.
Especially when some dumbtard decided nesting ifs 5 level deep and I need to decipher which if does what.
Yellow text marker - first indent
Post it on the text marker with the branching (True - does X, False - does Y)
Green text marker - second indent
Post it on it with the branching....
And so on.
It's a lifesaver for these things and more fun / joyful than e.g. drawing UML -/ VK -/ ... diagrams.
(I just lay down the text markers as building blocks, I don't draw with them... But for algorithms or refactoring it's nice to be able to move stuff around without writing tons of stuff to see the outcome. 🤣) -
dk bout DSA but I learnt this new word
"counterintuitive"
P.S : English is my 3rd speaking language
Related Rants
-
COderGReat26When you go to paste a piece of code with CTRL+V and accidentally press CTRL+C instead so you have to go back ...
-
iammurendeni22"please wait 5 seconds 'till you can continue with the call" *additional charges apply
-
karmak8Dear Websites, If I have to go through a fucking slideshow or even multiple pages to see your content, I won'...
I hate data structures. I try to work out their algorithms in my head but they're completely counterintuitive. lol.
rant
counterintuitive
data structures
annoying