Python : Flatten a Nested List Using Recursive Function & While Loop

preview_player
Показать описание
Video 27: This video shows how to convert a nested list into a simple flatten list using recursive function and also in simple WHILE loop

Few terminologies here:
1. Nested List: A nested list is a list that contains other lists as its element. Basically its a list within a list, allowing for a hierarchical or multi-dimensional structure to store data
2. Recursive Function: A recursive function calls itself during its execution. The well known example of recursive function is to calculate the factorial of a number, which we can discuss in the future videos

In this example of flatten a nested list, we discussed two options
1. While Loop: This is a simple WHILE loop, where we pop() each element in the list, check if the data type of that element is a list. If its a list, append that list to the current variable and go for the next loop till you clear the variable without any value in it.

2. Recursive Function: we loop in thru the list and check the data type of the element. If its a integer, store it in the output variable. if not, call the same function again and loop through it. Its called the recursive function.

Follow me on,

#recursive #countingalgorithm #list #looping #listmanipulation #uniquesubstring #longestsubstring #slicing #lineartimecomplexity #python #pythonquestions #pythontest #pythonprogramming #pythontutorial #python3 #pythonforbeginners #interviewquestions #interview #dataengineers #deinterview #pythoninterview #interviewquestions #leetcode #placementpreparation #meta #google #facebook #apple #netflix #amazon #google #faang #maanga #dataengineers #alphanumeric #nonalphanumeric #growwithdata
Рекомендации по теме