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
На этой странице сайта вы можете посмотреть видео онлайн Stack in python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Nishu Singh 04 Март 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 194 раз и оно понравилось 22 зрителям. Приятного просмотра!