Mini steps to learning data structure and algorithm with PowerShell

I have been reading and learning on the data structure and a little bit of algorithm since PowerShell Summit 2018. I chatted with phenomenal folks at the Summit and that experience really deepen my attention to PowerShell's language implementation. Now I am so curious on why hash table is preferable, why list is more recommended than array and why performance varies....so many why.

I decided to build my Computer Science fundamentals to help answering some of these questions. The first few chapters of the data structure book I am reading talks about the sequential list, linked list, double linked list, circular list, stack, and queue. Amazing to see how the great minds in Computer Science solved hard challenges like finding the correct value in the memory.

Today, the stack section talked about the Fibonacci number. I wondered how I would calculate the series using PowerShell.... Below are my initial attempts. One using recursion and the other with iteration. Interesting that iteration approach is at least 1000 times faster the the recursion approach. There is likely something I can optimize with my recursion "algorithm". Do you see the same result? Any thought or recommendation? I am in all ears.

Result



Fibonacci number with recursion

Fibonacci number with iteration
.

Comments

Popular posts from this blog

PowerShell Universal Dashboard and AWS Elastic Beanstalk

Quick review on my career after learning PowerShell

The next chapter... or rather next page. :)