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
Auf dieser Seite können Sie das Online-Video Stack in python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Nishu Singh 04 März 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 194 Mal angesehen und es wurde von 22 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!