Tuesday, June 14, 2016

Python linked list

If you are planning to refresh your data structure knowledge, I would recommend this website http://www.geeksforgeeks.org/data-structures/

Tree or Linked list datastructure  programming heavily use the recursion concept ... recursion is something that sometimes cause me brain crash :-)

But once you understand it and learn how to use recursion , then that is where you start mastering datastructure concepts.

If you look at Tree or linked list, it is a repetition of a node or a same structure(http://quiz.geeksforgeeks.org/binary-tree-set-1-introduction/)   .. so when there is repetition of something, then there is always scope for recursion concepts to apply...

Python Linked List:

Python programming language also have OOP concepts. So that means we can define a class http://www.diveintopython.net/object_oriented_framework/defining_classes.html

You can go through the linked list details in the below link
http://quiz.geeksforgeeks.org/linked-list-set-1-introduction/ . You will see two classes they defined for implementing linked list.

I was just trying to build without 2 classes. We can build a linked list, I dont know why they used 2 classes..I am not sure on how python is doing this dynamic memory allocation.



Program:



Strace:


No comments: