trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
184.96k stars 29.83k forks source link

Traverse in Reverse is unnecessary complex #1092

Open ivancho-ifa opened 6 months ago

ivancho-ifa commented 6 months ago

The current implementation has time complexity O(n^2). It could be improved to O(n) by using recursion. I think it would be beneficial to have both approaches as it is the classic dilemma time vs. memory optimization.

dahkjh commented 6 months ago

nb

faresh9 commented 5 months ago

@ivancho-ifa which algorithm?

Sanjay10tech commented 5 months ago

which algorithm

leoimewore commented 5 months ago

Guys, I believe this issue is about the reverse traversal of a Linkedlist Datastructure.