No one has ever explained to me sorting and search in such a simple way. Thanks a lot for explaining all the concepts in simple ways.
@nikunjlohiya51603 жыл бұрын
Sir i have completed your entire course on python and it is one of the best courses to learn python available on KZbin. Your teaching makes the concepts very easy to understand. It is really commendable that such a quality of content can be accessed for free. Once again hat's off to you sir and your teaching...
@placement36086 жыл бұрын
Accordingly to me u changed my life in programming .u are god sir ...thank u Navin sir .....
@harshaddaingade97844 жыл бұрын
def sort(nums): for i in range(len(nums) - 1, 0, -1): for j in range (i): if nums[j] < nums[j + 1]: continue else: nums[j+1], nums[j] = nums[j], nums[j+1] nums = [5, 8, 9, 71, 10, 2,589,1,0] sort(nums) print(nums)
@hrishikeshhasabnis81114 жыл бұрын
This can be a possible optimization : def selection_sort(list): for i in range(len(list)): for j in range(i+1, len(list)): if list[i] > list[j]: list[i], list[j] = list[j], list[i] Btw, Great video Sir as always! Thank you!!
@kartikkalia014 жыл бұрын
yeah, he taught this in his earlier video
@hrishikeshhasabnis81114 жыл бұрын
@@kartikkalia01 Glad to know that..
@AnkitKumar-gg2zs4 жыл бұрын
It could be simple like list=[10,5,8,2,1] For i in range(len(list)): min_value=min(list[i:]) min_index=list.index(min_value) list[i] , list[min_index]= list[min_index], list[i] Print (list)
@hasibkhan86005 жыл бұрын
for i in range(10): print("At the end to watching all the video, I want to say, take my salam inside my heart. Thank you so much Navin Reddy Sir.God bless you.")
@lsrinivasamurthy4 жыл бұрын
This can be optimized a little bit as below : The code for swapping logic is always getting executed, This can be executed only if we really find the small number , else the existing will be as it is. def sort(my_list): for i in range(5): min = i for j in range(i, 6): if my_list[j] < my_list[min]: min = j if my_list[i] != my_list[min]: print("Swapping Logic") temp = my_list[i] my_list[i] = my_list[min] my_list[min] = temp print(my_list) my_list = [5, 3, 8, 6, 7, 2] print(my_list) sort(my_list) print(my_list)
@guptasubas15303 жыл бұрын
numberList = [23,45,2,3,4,23,1,28,41] def selectionsort(numberlist): for i in range(len(numberlist)): for j in range(i+1,len(numberlist)): if(numberlist[j]
@abhishekjaiswar46695 жыл бұрын
def sort(num): for i in range(len(num)): for j in range(i,len(num)): if num[j]
2 жыл бұрын
Thanks for this great tutorial. I wanna point to something, you've missed an edge case in case this : list=[1,2,6,5,4,3] loop min_index=2 i=2 swap so here we didn't find a less value than min_index=2, so we don't need to do swapping to solve this issue, we need to add a condition : loop min_index=2 i=2 if i != min_index then do swap ===> first case we swap 6 times ===> the second one, we swap 3 times
@FactsDiscoveryyoutube5 жыл бұрын
if you want to clear the video concept look the output of my coding: Thank you Navin Sir def sort(l): n = len(l) for i in range(n): print("The value of i",i) minpos = i for j in range(i+1,n): print("Print the value of j",j) if l[j]< l[minpos]: minpos = j l[i] ,l[minpos] = l[minpos],l[i] list = [2, 5, 6, 7, 4, 3] sort(list) print("Sorted list is") for i in range(len(list)): print(list[i]) o/p: The value of i 0 Print the value of j 1 Print the value of j 2 Print the value of j 3 Print the value of j 4 Print the value of j 5 The value of i 1 Print the value of j 2 Print the value of j 3 Print the value of j 4 Print the value of j 5 The value of i 2 Print the value of j 3 Print the value of j 4 Print the value of j 5 The value of i 3 Print the value of j 4 Print the value of j 5 The value of i 4 Print the value of j 5 The value of i 5 Sorted list is 2 3 4 5 6 7 Process finished with exit code 0
@benerjeverse4 жыл бұрын
for i in range(n) this u can put n-1 in the place of n
@guptasubas15303 жыл бұрын
numberList = [23,45,2,3,4,23,1,28,41] def selectionsort(numberlist): for i in range(len(numberlist)): for j in range(i+1,len(numberlist)): if(numberlist[j]
@jagsexe2 жыл бұрын
@@guptasubas1530 this is bubble sort isnt it ?
@arnavgupta7392 Жыл бұрын
for j in range(i+1,n) change this to for j in range(i,n) otherwise it will through an error of index out of range for the last index of the list
@aakashjana62254 жыл бұрын
In Python you can swap by writing just nums[i], nums[minpos]=nums[minpos], nums[i]
@chinmaydas40536 жыл бұрын
We want these types of indepth, easily discussed great topics videos like data structures, different algorithms writing and analysis techniques.. lots of love and respect for you sir 🙏🙏🙏...
@mdbhardwaj50054 жыл бұрын
analysed the code using debugger and understood the concept. Love your videos, Sir.
@fawadkhan89055 жыл бұрын
Thank you sir so much, now we are able to refined the code up to somehow it' s by watching your videos. So i would like to share the script that took me almost 2 hours and get me succeed in it. def selct(x): for i in range(len(x)): #minIndex=i (No need of this) for k in range(i, len(x)): if x[k] < x[i]: (x[k],x[i])=(x[i],x[k]) print(x) x=[2,4,5,1000,7,8,1,99] selct(x)
@ashmitgajwani60864 жыл бұрын
Dude that was great!!!
@RK_974 жыл бұрын
you are missing the concept of selection sort, that is swap once per iteration. Your solution is more like the bubble sort.
@pranav93392 жыл бұрын
for i in range(len(a)): m=min(a[i:]) u=a.index(m) a[i],a[u]=a[u],a[i] alternate way
@guptasubas15303 жыл бұрын
Simple version : numberList = [23,45,2,3,4,23,1,28,41] def selectionsort(numberlist): for i in range(len(numberlist)): for j in range(i+1,len(numberlist)): if(numberlist[j]
@divyankakanyal680211 ай бұрын
for j in range (i+1 , n) should have been used to make the iteration short. Thank you sir for explaining in such simple way ✨😊
@madhvishrivastava36468 ай бұрын
I never knew that sorting is that simple. Thank you so much sir.
@infotech31804 жыл бұрын
Thanks sir , I completed my whole concept of python from you Love from Pakistan
@thorhilda4 жыл бұрын
Teaching future Python users to use and conceive for..loops as if they similar to other language's loops is instilling bad habits and poor reasoning that will hinder their progress greatly. In Python, for...loops are iterators not counters, and they ought to be understood as "for each_elements in a_set do something on each_elements", not "for index from 0 to len(nums)) do something on nums[index]" as in C language. --------- Python code starts here --------- def selection_sort(unsorted_list): """ A far better way that mimics the actual principle behind 'selection sort', that is sorting by selecting items one after the other according to an ordering function """ # (optional) work on a copy to keep the original list unmodified lst = unsorted_list.copy() while lst: # for as long there are items in the list extracted_value = min(lst) # find the smallest value del lst[lst.index(extracted_value)] # remove it from the list yield extracted_value # outputs it on demand numbers = [5, 3.14159, 8, 6, 7, 2] print(list(selection_sort(numbers))) # [2, 3.14159, 5, 6, 7, 8] # the above function can be easily generalized to use any arbitrary ordering function def extract(n, *, func=min): while n: extracted_value = func(n) del n[n.index(extracted_value)] yield extracted_value # Some examples from functools import partial reverse = partial(extract, func=max) characters = list("Python".upper()) # in reverse alphabetical order print(list(reverse(characters))) # ['Y', 'T', 'P', 'O', 'N', 'H'] import random shuffle = partial(extract, func=random.choice) players = ["Alice", "Bob", "Charles"] print("The first to be randomly chosen is", next(shuffle(players))) print("The second to be chosen is", next(shuffle(players))) print("And the last to be chosen is", next(shuffle(players)))
@arshgupta57374 жыл бұрын
def sort(self): for i in range(a): minpos=i for j in range(i+1): if list[j]
@AlankritIndia4 жыл бұрын
selection sort using maximum element- def ssortmax(l): for i in range(len(l)): maxpos=len(l)-1-i for j in range(len(l)-i-1): if l[j]>l[maxpos]: maxpos=j l[maxpos],l[len(l)-i-1]=l[len(l)-i-1],l[maxpos]
@sampratickroy20556 жыл бұрын
after all u r the best trainer as an indian youtuber
@rohinisingh69162 жыл бұрын
All videos are awesome sir. Outstanding teaching way.
@alhaquekhan9383 жыл бұрын
You should use j in range(i+1,len(arr))
@blackcrocodilehunter2044 жыл бұрын
Liked your video but I wish you made the code completely dynamic, instead of having for i in range(5) have for i in range(len(list))
@LakshmiPR-hp4bp9 ай бұрын
You are great sir. Very good tutorial for python beginners. Thanks a lot
@sarat4chan5 жыл бұрын
Hi Navin, You are a great teacher, I gained lot of knowledge from your python series. Can share us separate series dedicated to algorithm and data structures?
@vinoddiwan57925 жыл бұрын
Agreed with you we need full data structures and algorithm playlist
@swethagopu37084 жыл бұрын
Sir I completed all the videos on python you done an excellent job sir tku soo much for work will u plz tell the address of Ur telusko branch coaching center. U plz tell me in which CLG u studied. Tku soo much sir . I have desire Ur channel go to million subscribers😍😍😍😍😍👏👏👏👏
@syedaquratulain14432 жыл бұрын
best explanation ever
@deepaktiwari385 жыл бұрын
thank you so much ..Can you please upload the data structures like (linked list,stack,queue,tree,graphs) implementation in python as well ..your explanation is always to the point ...You are a great teacher..Respect
@sailapellakuru64885 жыл бұрын
this video made me clear about the topic
@hendroheng9336 Жыл бұрын
def sort(nums): for i in range(5): minpos = 1 for j in range(i,6): if nums[j] < nums[minpos]: minpos = j temp = nums[i] nums[i] = nums[minpos] nums[minpos] = temp nums = [5,3,8,6,7,2] sort(nums) print(nums) The result comes out as below instead. Number 8 is on the second. Does anyone know why? [2, 8, 3, 5, 6, 7]
@RythemOFFICIAL4 жыл бұрын
Is selection sort = insertion sort ?
@lloyd84653 жыл бұрын
list[i], list[pos] = list[pos], list[i] ... This can be also consider as swapping right?
@balajiragu9127 Жыл бұрын
1) May I know why the outer loop runs till 5 and the inner loop runs till 6. 2) In this scenario 2nd, 4th, 5th and 6th iteration is doing nothing. Which sorting will avoid unnecessary actions.
@Rajadahana2 жыл бұрын
At 7:25 - as I have understood, the advantage of Selection sort, over bubble sort, we have to do swapping LESS number of times. Hope I have got it right.
@12josephsaviopereira23 жыл бұрын
PLZ make a viedo on insertion sort....u guys are doing a grt job
@satyaswarupojha2244 жыл бұрын
That was well explained...May i know your qualifications Mr.Reddy!
@kartikkalia014 жыл бұрын
MTech from IITB and Post Doc from Cornell University.
@prathammishra44804 жыл бұрын
@@kartikkalia01 IIT Bangalore ???????????
@kartikkalia014 жыл бұрын
@@prathammishra4480 Bombay
@prathammishra44804 жыл бұрын
@@kartikkalia01 Ohh Ok
@dharma34042 жыл бұрын
BSc from vikas college mumbai and MSC from Vidyalankar School of IT mumbai
@anitgahlot57493 жыл бұрын
thanks bro, u make me fully understand the code
@rezaulhasan27052 жыл бұрын
Awesome sir with full explanation
@akshbansal77156 жыл бұрын
pls continue this series, i really love your python vids
@sauravgarg0015 жыл бұрын
use i+1 to reduce one iteration
@rajmohammed81345 жыл бұрын
Thank you, Sir, you have explained in an easy way.
@zakiasmaa68342 ай бұрын
Thanks a lot Sir Navin
@sampratickroy20556 жыл бұрын
sir full data structure in python
@maedre93303 жыл бұрын
data structures in python is not a good idea. Python is not a good language for data structures as it has several issues
@pavanmaddala16093 жыл бұрын
@@maedre9330 🙄🙄
@vishutiwari996 жыл бұрын
Sir Heap sort also please.🙏🙏🙏
@aswinks2 жыл бұрын
can u please add DS playlist also because we aliens can easily understand those concepts when you teach.
@krishnapawar20562 жыл бұрын
Thank you so much sir i have watched previous all the python videos🙏 and they are great
@KiranA-jw7dy2 жыл бұрын
Sir can you please upload videos on other sorting algorithms
@srinivasaraghavansm43554 жыл бұрын
sir could you make a lecture on insertion sort
@nishantviknis31732 жыл бұрын
Sir, Thank you so much. Very useful
@khabibali49673 жыл бұрын
Sir, you almost cover all searching algorithm techniques but you forgot to make a video on the quick Sort and Insertion Sort algorithm. please make on it.
@amitkumarpradhan98583 жыл бұрын
Hope he was our teacher at college
@khushi_sandhu4 жыл бұрын
isn't this an easier method: and tell me if we can cal it selection sort or not def sort(lst): lst1=[] for i in range(0, len(lst)): mini=min(lst) lst1.append(mini) lst.remove(mini) return lst1 lst=[34,76,23,56,24,3] lst1=sort(lst) print(lst1)
@mistakefftw2 жыл бұрын
Extremely helpful! Thank you!
@jayeshsingh77646 жыл бұрын
Sir, The Videos are Amazing but, Please try to discuss the Time complexity of each algorithm and compare Time Complexitis of different algorithms....
@MarvaDeen6 ай бұрын
It was very useful . Tnk u so much sir
@mdtanzinislam11856 жыл бұрын
I watched your java vedio and python now what should i doshould i start project or start making app
@mathchithra54884 жыл бұрын
Sir one more video for if we get values in while function, then repeat the process with the values we get in while. How to repeat the process.
@punitsehrawat29024 жыл бұрын
Best explanation sir
@anjankumargoud7856 Жыл бұрын
Thanks Alot Sir 💝.
@054_ritesh34 жыл бұрын
Excellence at its top
@anusmitasamanta26085 жыл бұрын
sir you're the best
@mekalapavankumar8343 Жыл бұрын
What if a list have duplicate values?
@sghosh59043 жыл бұрын
very nicely explained
@Alberta_Farmer Жыл бұрын
Such a great lesson!
@TarunKumar-xu1jb3 жыл бұрын
sir can you please explain the range...How we are taking the range in this case
@harshraj62645 жыл бұрын
I had seen all the series of your python.
@piyushbagani92444 жыл бұрын
please upload a video on list comprehension and its use cases....
@autotechtraveller87872 жыл бұрын
In second for loop range (i+1 or i and 6 y we to take)?
@shashanksinghsisodiya5146 жыл бұрын
Hi Sir..your videos made me a good full stack developer..I am understanding the concept very well and rapidly tho ur videos..thank you so much🙂
@dharshanakanniappan9926 Жыл бұрын
Thank you❤
@nandyalanaveenreddy75985 жыл бұрын
You helped me a lot sir
@msprabhu.sudhi526gmail.commsp6 жыл бұрын
Sir, can you please do videos on data structures in python
@vigneshbathini58622 жыл бұрын
Sir, Make videos of sql
@gayathrinallam44874 жыл бұрын
sir please do explain us merge , quick, insertion,heap sort techniques too . please sir!
@Harpreetkaur-fd5fu4 жыл бұрын
Sir also make video on insertion sort
@jawadmuhammadali88316 жыл бұрын
Please upload a lecture on merge sort
@Tanvi2022-hu3st6 ай бұрын
Sir I have a doubt can't we just use the list function sort to get the output as increasing and decreasing order ??
@tushargoyaliit6 жыл бұрын
Please discuss one que of good level like on codechef every week
@harshraj62645 жыл бұрын
Hey in python I think we do not need a temporaray variable to swap Here how it you can do it >> num[¡], num[minpos] = num[minpos], num[¡] If there is something wrong please tell me I am a student of class 11.
@sarat4chan5 жыл бұрын
yes, you can ... but he is explaining using temporary variable so that we understand the algorithm
@dr.sujathaelumalai37 Жыл бұрын
KIndly explain all programs with input variable instead of constants
@christopherverdejo6965 жыл бұрын
Thanks for the video man 👊 i understand how it works but I don't know how it works the swapping
@lohithdonthamshetti79444 жыл бұрын
Sir please teach about the data structures using python
@014_nasreenparween54 жыл бұрын
Great sir 👍👍
@prateekmaurya41873 жыл бұрын
please make series on python turtle
@Seftehandle11 ай бұрын
I love this guy
@johndermon59795 жыл бұрын
Why not in line 6 for j in range(i+1,6): otherwise you always begin each loop by comparing an element to itself
@nandyalanaveenreddy75985 жыл бұрын
J can be in range(i+1,5)
@Its-Not-Funny4 жыл бұрын
We can use i+1 also. But the thing is when we use this, we are not comparing the value it self . But if we use 'i' we are comparing the value itself.
@AnilTikoo6 жыл бұрын
Can we use=> list.sort(reverse=True/False) in order to sort directly in ascending or descending order?
@silverblade416 жыл бұрын
Yes thats a much quicker way of doing it but most cs courses require you to learn this mehtod so that you understand gow the sort function works
@mudassirfarooq3755 жыл бұрын
Very nice bro, I am really impressed...
@heenasharma50763 жыл бұрын
I think there wasn't much diff between selection and bubble sort both were of order of n^2
@Sam-ro3ce6 жыл бұрын
Bro send me pyhthon software link I learned from u more tnks bro, I have basic laptop so I want suggestion from u which python version suit fr me
@swapnil7713 жыл бұрын
Plz try in hindi also
@arushisinghonelove93946 жыл бұрын
thanku...sooo much ...sir ...plz..upload the program of all sorting algo..