DEV Community

Trees and the Database.

Internet Explorer on March 07, 2020

First of all before we dive in... What are trees? Obviously in computer science. A tree is just a data structure which is composed of nodes. Every ...
Collapse
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

There's this new implementation in C# which allows you to implement a loop in an array from both the front and behind at the same time. That'll mean that for every list of n elements the worst case scenario will occur at n/2.for asymptotic relations these constants don't really matter though but do you think an implementation lik e this ideal. In the case of search for 19 it'll find 19 in the first attempt.

Collapse
 
er_dward profile image
Internet Explorer

Send me the link to this implementation.. will check it

Collapse
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

The section titled indexes and ranges
docs.microsoft.com/en-us/dotnet/cs...

Thread Thread
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє † • Edited

This is how I used I to implement the aforementioned
dev-to-uploads.s3.amazonaws.com/i/...

Thread Thread
 
er_dward profile image
Internet Explorer

Nice! I wrote same to see what was going on, it was what i guessed. Was the numbers intentional? As in repeated in descending order from the number 5? dev-to-uploads.s3.amazonaws.com/i/...

Thread Thread
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

Yes it was. I was just comparing to see opposite ends were the same. Typically in a search like this you will most like have a worst case. The smaller the number the harder to find but the since it's index is far. And the higher the number the higher you are in you array and closer to your destination so the best case scenario mostly be bit so great ever with binary search tree

Thread Thread
 
er_dward profile image
Internet Explorer

Well making double of the numbers means more space will be taken.. So on large datasets it will take more memory. (space complexity). Now lets imagine if the number is not in there... for example looking for 10. You will iterate through the whole numbers. from index 1 to .. arr.Length. Which is what you will likely not prefer.

Thread Thread
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

Oh okay, so that means like nothing will really change in time complexity as opposed to running two different for loops from the opposite ends of the array; the only difference will be in space complexity of the variables that hold the arr.index if either situation, I variable in the first (new implementation) and 2 variables in using traditional method of two loops

Collapse
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

Awesome. Looking forward to experimenting on Postgres and how it can optimize database designs and structure esp handling big data.
Looking forward to your next article

Collapse
 
er_dward profile image
Internet Explorer

Cool seems I should make a post on scaling postgres.

Collapse
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

You definitely should.