A stack is a data structure that holds a list of elements. A stack works based on the LIFO principle i.e., Last In, First out, meaning that the most recently added element is the first one to remove.
Operations of stack are:
Insertion (push)
Deletion (Pop)
Traversing
Searching
**Sorting: sort ( ) in use Timsort algorithm. Timsort is a hybrid sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data. It was invented by Tim Peters in 2002 for use in the Python programming language. The algorithm finds subsets of the data that are already ordered, and uses the subsets to sort the data more efficiently. This is done by merging an identified subset, called a run, with existing runs until certain criteria are fulfilled.
** Important question asked in company interview.
Question: What is the time complexity to search a element n from unsorted list L.
Answer: Best Case -O(1)
Worst case- O(n)
The content I have used to make presentation is from various websites including Python 3 documentation.
#datastructure #queue #stack #coding #list #developer #programminglanguage #pythonconcepts #pythonprogramming #code #python #implementation #python3 #timecomplexity #pythonquestion
Sur cette page du site, vous pouvez voir la vidéo en ligne Stack in python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Nishu Singh 04 mars 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 194 fois et il a aimé 22 téléspectateurs. Bon visionnage!