Stack in python

Pubblicato il: 04 marzo 2021
sul canale di: Nishu Singh
194
22

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


In questa pagina del sito puoi guardare il video online Stack in python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Nishu Singh 04 marzo 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 194 volte e gli è piaciuto 22 spettatori. Buona visione!