DEV Community

Cover image for Introduction to Data Structures and Algorithms With Python

Introduction to Data Structures and Algorithms With Python

Jeff Odhiambo on February 18, 2022

This article is a continuation of Python 101: Introduction to Modern Python where we introduced, set up and gave some basic understanding of the py...
Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I'm kind of confused; why do you list linked lists as non-linear, but then you have trees and graphs as examples for non-linear structures? Also, by your definitions, maps wouldn't fall into either category.


 The costly operation is inserting or deleting the element from the beginning of the List

In the ages of CPU cache, this needs lots of asterisks and disclaimers

Collapse
 
smartjeff profile image
Jeff Odhiambo • Edited

linked list is linear and I listed it as linear, and explained that in linear data structures are data structures structures where data are accessed siquentially. kindly check again.

About insertion and deletion operation, they are expensive in the sence that much time can be taken as it may involve shifting of elements where a certain order is to be maintained

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

yes but linked lists are trees though (and, by extension, graphs)

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

That's... factually incorrect. Have you even looked up the definition of trees before writing an article on them?

Thread Thread
 
smartjeff profile image
Jeff Odhiambo • Edited

hope this will help in understanding why one is linear and why the other is non linear
dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
rothman857 profile image
rothman857

FYI python has a built in package called Queue. No need to implement queues and stacks with lists. Queue supports LIFO, FIFO, and priority.

Collapse
 
smartjeff profile image
Jeff Odhiambo

Agreed, but was just showing how to implement a queen with a list, thanks

Collapse
 
rothman857 profile image
rothman857

Also, you should mention Dataclasses and NamedTuples. Both are very useful built-in packages for storing data.

Collapse
 
smartjeff profile image
Jeff Odhiambo

am going to consider them in my next article which will be a continuation of this

Collapse
 
brayan_kai profile image
Brayan Kai

Great article here 👏👏🥳 Keep the good work up

Collapse
 
smartjeff profile image
Jeff Odhiambo

Thanks Kai 🤝🏻

Collapse
 
owino profile image
Owino

Great article.

Collapse
 
smartjeff profile image
Jeff Odhiambo

Thanks @owino