Python Tutorials - Binary Search Program

  Рет қаралды 97,408

Amulya's Academy

Amulya's Academy

Күн бұрын

Пікірлер: 170
@vaibhavpatharkar6794
@vaibhavpatharkar6794 2 жыл бұрын
Amulya madam , Thank you very much. People like you help, helpless people like me
@binab3817
@binab3817 5 жыл бұрын
Waw ma'am realy u ar best trainer ever I have attended tutorials. Thankss, from Ethiopia, Africa
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you :)
@akshaykaushik5204
@akshaykaushik5204 5 жыл бұрын
Awesome Undestanding. But Some Qns. 1. If duplicate element in the list. 2. print the index of the element.
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
def binarySearch (list1,key): low=0 high=len(list1)-1 Found = False while lowlist1[mid]: low=mid+1 else: high=mid-1 if Found==True: print("key is found at index:",ind) else: print("key is not found") list1 = [ 2, 3, 4, 10, 40,2 ] list1.sort() print(list1) key = int(input("key:")) binarySearch(list1,key) :)
@MINEDITZZ69
@MINEDITZZ69 4 жыл бұрын
@@AmulsAcademy It does not work on the duplicate value
@sktanweerrahaman9896
@sktanweerrahaman9896 3 жыл бұрын
You are literally making a lot conscious efforts for making us understand all these concepts..thanks a lot 🤩
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure 😊
@souravkr3305
@souravkr3305 4 жыл бұрын
You're too good... I think this was the best tutorial I had Ever seen about binary search... And after seeing yours I'm completely amazed it helped me a lot... Please keep uploading more such videos...💫.. And also make videos about Data file handling
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you so much 😀
@morampalliyeswanthreddy2793
@morampalliyeswanthreddy2793 3 жыл бұрын
Madam such a wonderful teaching madam that I never seen before. Heartly congratulations for ur efforts madam❤️❤️
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you so much :)
@morampalliyeswanthreddy2793
@morampalliyeswanthreddy2793 3 жыл бұрын
@@AmulsAcademy madam If u take any classes on python In academy pls tell me i will join madam
@muhammadjasoor4188
@muhammadjasoor4188 3 жыл бұрын
Didi you are doing a great job . your explanation are very much easily understandable. Thank you so much .
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@failure795
@failure795 Жыл бұрын
ma'am you are like a life saver. I swear i thank you....:) i will continue to use your channel
@sivasurya4149
@sivasurya4149 4 жыл бұрын
Excellent madam..I saw all videos..very good explanation
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you so much :)
@sriraj8392
@sriraj8392 3 жыл бұрын
omg thank uuu mam, ur voice makes me listen more like class room tutor , thank uu madamm....👌👌👌👍👍👍👍👍🤞🤞🤞
@JSONY-ff2ni
@JSONY-ff2ni 3 жыл бұрын
madam thank u soo much ur explaination is too good ur channel is very helpful for me
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@greeshmashetty1724
@greeshmashetty1724 4 жыл бұрын
This is super informative and explained in simple terms. Thank you for sharing your knowledge amulya.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Glad it was helpful! :)
@addankilikhitha4539
@addankilikhitha4539 4 жыл бұрын
Thanking you for your efforts madam I got to know this topic much more clear now
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
It's my pleasure :)
@rakeshpittala8832
@rakeshpittala8832 3 жыл бұрын
Thnks ma'am!!!!😘 I'm learning a lot from your videos.....
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Glad to hear that 😊
@gourangagrawal4186
@gourangagrawal4186 3 жыл бұрын
Absolute best teacher 🙂😇❤.Mam but ye sab toh smj me aajata h par jo company ke competitive wala question rehte h statement wale, wo smjh he nhi aate.please mam ek series statement wale question ki taaki thoda logic aur approach smj aaye, aur company ka written nikal sake, python me he 🙂🙂
@XMarketing580
@XMarketing580 3 жыл бұрын
Best teacher ever holyyyyyyyy
@podishetticharan6013
@podishetticharan6013 3 жыл бұрын
Congratulations mam......🥳🥳🥳🥳🥳🥳 for 100k subscribers 🥰🥰🥰🥰🥰🥰🥰🥰
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@anuradhabalasubramanian9845
@anuradhabalasubramanian9845 4 жыл бұрын
Awesome Mam .Love your way of teaching. Great Work
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thanks a lot :)
@SwapnilBhosale.----
@SwapnilBhosale.---- 11 ай бұрын
Mai aap ki awaj sunne k liye ata Hu or thoda sikhne ❤I love u mam
@ArshadAli-sr2mf
@ArshadAli-sr2mf 3 жыл бұрын
Ma'am please make video on BSF and DFS I just love each on of ur explanation.
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Soon 😊
@greatab2977
@greatab2977 4 жыл бұрын
Is there break statement required after if condition?
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
If we use else then break is not required :)
@greatab2977
@greatab2977 4 жыл бұрын
@@AmulsAcademy ok,thanks
@abdulrahman-hn2nn
@abdulrahman-hn2nn Жыл бұрын
# linear search def search(list1,key): for i in range(len(list1)): if key==list1[i]: print("element found at index",i) break else: print("element is not found") list1=[13,8,90,78,65,43] key=int(input("enter the key element")) search(list1,key)
@mraksh898
@mraksh898 3 жыл бұрын
You make it easier to understand 😀🙏
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@anushkaparashar802
@anushkaparashar802 3 жыл бұрын
Mam... Can we use for loop instead of while loop in this program?? What will be the statement for , for loop?
@prabirmaji185
@prabirmaji185 4 жыл бұрын
in the code you also need to mention the position of the key in the list
@david-komi8
@david-komi8 3 жыл бұрын
If you want, you can use try and except for catch the error and avoid the program close
@obilisamy8930
@obilisamy8930 3 жыл бұрын
Mam if the position also founded means it would be very super anyway super mam
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Yes you can do that 😊
@scikiefact
@scikiefact Жыл бұрын
Thank you ma'am jii!!😊❤
@sailesh2838
@sailesh2838 8 ай бұрын
10:30 how will low become greater than high ? can someone explain ?
@neelanshsharma4203
@neelanshsharma4203 3 жыл бұрын
thanks your videos are the most helpful ones.
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
My pleasure :)
@analyticstamizan677
@analyticstamizan677 5 жыл бұрын
Superb... Mam.. 👌👌💯
@shubhangnichandel3107
@shubhangnichandel3107 4 жыл бұрын
thanks ma'am yr explanation is realy good easy to understand
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Most welcome 😊
@theultimateman7812
@theultimateman7812 6 ай бұрын
Mam binary search is applicable for sorted array right
@nilimathorat4540
@nilimathorat4540 Жыл бұрын
If there is some same numbers in list at that time can we use this program or need to change something?
@usmanimtiaz1519
@usmanimtiaz1519 5 жыл бұрын
it show error in line 9 elif key > arr[mid]: TypeError: '>' not supported between instances of 'int' and 'str' how to fix this error
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
you need to take integer key, check that. :)
@usmanimtiaz1519
@usmanimtiaz1519 5 жыл бұрын
@@AmulsAcademy thanks
@vinoddiwan5792
@vinoddiwan5792 5 жыл бұрын
you can use this int(low+high/2) or low+high//2
@atulgupta9946
@atulgupta9946 5 жыл бұрын
Hey... Can you please complete the class 12 CBSE syllabus... Of python programming.... We will be very thankful to you... Please go for it... By the way... Love you❣️
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
I will try :)
@vns3380
@vns3380 4 жыл бұрын
very nice explanation
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@CSEkotniKanakaRaju
@CSEkotniKanakaRaju 4 жыл бұрын
mam ur explanation is super mam
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thanks a lot :)
@sajidhussain6522
@sajidhussain6522 3 жыл бұрын
Nice explanation ✌
@preethi2434
@preethi2434 5 жыл бұрын
Mam, can you do more python programming in matrix with examples
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
I will try :)
@yasmeenkarachiwala9612
@yasmeenkarachiwala9612 5 жыл бұрын
Thank so you much!!! Amazing. Please post video on Binary Tree Inorder,Preorder
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Pleasure :)
@asmodeus4310
@asmodeus4310 3 жыл бұрын
Here's an advice, I noticed when you make a function, you dont use pascal case, defining a function should always be in pascal case, not camel case
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you, I will keep that in mind 😊
@icebear474
@icebear474 3 жыл бұрын
Is this one done with the help of recursion logic?
@shreyasaxena5160
@shreyasaxena5160 4 жыл бұрын
mam i could not understand the while condition, why low
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
that is the stopping condition for while loop, when low=high we need to stop.
@vaishnavivaishu100
@vaishnavivaishu100 4 жыл бұрын
you are the best lots of love to you dear:)
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@ajayjha1995
@ajayjha1995 5 жыл бұрын
great jobs, really i enjoyed learning alot
@ahmedsarker3555
@ahmedsarker3555 3 жыл бұрын
5:04 cant we use while loop
@abhaymanoharsaxena1174
@abhaymanoharsaxena1174 5 жыл бұрын
Hello Ma'am , in this question if we have to print the index position of the key what we've to do? Please help!
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
def binary_search(list1, key): low = 0 high = len(list1)-1 Found=False while low list1[mid]: low = mid + 1 else: high = mid-1 if Found==True: print("key found at index:",index) else: print("Key not found") list1 = [24,1,4,2,3,1] list1.sort() print("sorted list:",list1) key = int(input("enter key:")) binary_search(list1,key) :)
@Krishnna05
@Krishnna05 Жыл бұрын
can u teach this using recursive functions too?!
@muhammadsohaib3908
@muhammadsohaib3908 4 жыл бұрын
very well explanation . Thank you
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
You are welcome! :)
@chanducam4433
@chanducam4433 5 жыл бұрын
Plzzz mam put a video on palindrome n anagram
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Palindrome Program: kzbin.info/www/bejne/i5zGl4tmZ8R-fdE :)
@chanducam4433
@chanducam4433 5 жыл бұрын
Anagram too mam
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Sure :)
@chanducam4433
@chanducam4433 5 жыл бұрын
@@AmulsAcademy Mam anagram plzzzzz n in palindrome ,I need 1)longest palindrome in file along with the number of words repeated n 2)unique pal in d file along with number of words is repeated.
@entershorts3277
@entershorts3277 3 жыл бұрын
What if we also want to show the index number like (key is found at index ....)
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
To print its index, when you return mid you can print list1[mid] .
@amansagar1041
@amansagar1041 5 жыл бұрын
Code is not running showing error as false is not defined
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
you should write false as False it is a keyword.
@abiii1157
@abiii1157 3 жыл бұрын
can u teach algorithm based interview programs ?mam
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Will try 😊
@sathiyapriyan4969
@sathiyapriyan4969 4 ай бұрын
how to print the index value of the element mam.
@kironpaul7581
@kironpaul7581 4 жыл бұрын
Please create a video on BST!!!(DATA STRUCTURE)
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Sure :)
@Dopeboyz789
@Dopeboyz789 5 жыл бұрын
Is there a way to search for a value thats in the previous dataframe?
@sruthir1236
@sruthir1236 4 жыл бұрын
Can u please explain this While low
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Found is a variable with Boolean value. Here we are taking 2 conditions with while loop first is low
@sruthir1236
@sruthir1236 3 жыл бұрын
@@AmulsAcademy thq so much
@techguru4122
@techguru4122 4 жыл бұрын
Please make tute on radix and count sort very soon
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
I will try :)
@IamHariJags
@IamHariJags 3 жыл бұрын
how to print the index as well plz help
@RuthJames-xh3mk
@RuthJames-xh3mk Жыл бұрын
Thanks a lot for your help, may god bless you
@afnanadit1029
@afnanadit1029 4 жыл бұрын
If I give a default value for the key then the key is found/not found is not shown.
@MyTravelingJourney
@MyTravelingJourney 2 жыл бұрын
what if the list have null values. for example lits1= ["apple"," "," ", " ", "bat"," "," ","cat"," "," ","mat"]. Your given binary search will not work here.
@anubhavsingh8144
@anubhavsingh8144 5 жыл бұрын
Pls make the video on LCS ALGORITHM
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
I will try :)
@praizdev
@praizdev 2 жыл бұрын
Thank you so much for this video
@kashishjain20
@kashishjain20 3 жыл бұрын
what is the use of key??
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Key is the value you want to search 😊
@NewSSS23
@NewSSS23 4 жыл бұрын
Awesome explain mam
@shiva-vz5qf
@shiva-vz5qf 2 жыл бұрын
maam helped a lot but what if we also had to give index
@adityahpatel
@adityahpatel Жыл бұрын
low > high will never happen. So why have u added that condition in the while loop. Can you explain how you came up with that, because the preceding lecture does not explain that piece
@shristisinha7264
@shristisinha7264 3 жыл бұрын
mam, it's showing error : IndentationError: expected an indented block
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
I think you added extra or less space somewhere please check that 😊
@junaidiqbal2321
@junaidiqbal2321 3 жыл бұрын
Please make videos BFS, DFS
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Noted 😊
@junaidiqbal2321
@junaidiqbal2321 3 жыл бұрын
@@AmulsAcademy As soon as possible i have paper on friday pleaseeeeeee
@simplyanup9658
@simplyanup9658 Жыл бұрын
Usually, we use binary search to find the index number of the key which you didn't show.
@hemanthn436
@hemanthn436 5 жыл бұрын
ma'am a sincere request could you do datastructruces of python please it helps me alot for my placement
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
I will try :)
@chaitranaik3673
@chaitranaik3673 2 жыл бұрын
Thanks a lot ma'am
@praveenasurya3211
@praveenasurya3211 2 жыл бұрын
hi ma'am, can you program for duplicate elemens in binary search
@akshaysb526
@akshaysb526 3 жыл бұрын
perfect, thank you
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure :)
@abdulrahman-hn2nn
@abdulrahman-hn2nn Жыл бұрын
def binarysearch(list1,key): low = 0 high = len(list1)-1 Found = False while lowlist1[mid]: low = mid+1 else: high=mid-1 if Found==True: print("key is Found") else: print("key is not Found") list1=[23,1,4,2,3] list1.sort() print(list1) key=int(input("enter the key element")) binarysearch(list1,key)
@sunandamahanta9964
@sunandamahanta9964 4 жыл бұрын
why do you define a variable 'Found=False', i didn't understand that part !! Please explain.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Here we are storing a Boolean value in the variable Found. Initially we will take Found as False means we didn't find key element till now. when we found the key element we will make Found as True. We will do this because we can write separate condition using if else. if Found is True -> key is found. if we can't find key in entire list then Found value remains False if Found is False -> key is not found. :)
@sunandamahanta9964
@sunandamahanta9964 4 жыл бұрын
@@AmulsAcademy thanks..it helps
@RahmanIITDelhi
@RahmanIITDelhi 2 жыл бұрын
good one...
@eeea7226
@eeea7226 4 жыл бұрын
The above program is not working mam..
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Give me the program i will check :)
@debojitmandal8670
@debojitmandal8670 3 жыл бұрын
If you want to repeat the code again and again you need to type while true but you are not doing doing so y is that
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Here we are using recursion :)
@arushpratapsingh5840
@arushpratapsingh5840 3 жыл бұрын
IndexError When I use list 1,11,14,15,25 and search for 25 then it will give me index error
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Can you give me the program, I will check it :)
@CSEkotniKanakaRaju
@CSEkotniKanakaRaju 4 жыл бұрын
are you complete masteress in python mam.
@techguru4122
@techguru4122 4 жыл бұрын
Within a week👏🙏🙏
@kanchann8365
@kanchann8365 4 жыл бұрын
How to solve typerrror of len() ??
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Give me the program please i will check :)
@snex-techprogrammer5110
@snex-techprogrammer5110 2 жыл бұрын
What if the target/key is repeated?
@L-oNhaVan
@L-oNhaVan 3 жыл бұрын
Thank you so much
@tabishnoor8537
@tabishnoor8537 4 жыл бұрын
Please also show how to take input from user , it is showing error in comprehensive method
@ijaspreet
@ijaspreet 4 жыл бұрын
Thank you ma'am
@malikshab832
@malikshab832 5 жыл бұрын
Mam What code should be add in the program array (list) to find element location?
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Try this: def binarySearch(list1,key): low = 0 high = len(list1)-1 found = False while low
@Ironblood108
@Ironblood108 3 жыл бұрын
👍
@shiva-vz5qf
@shiva-vz5qf 2 жыл бұрын
of the element to be found
@omkarsable3624
@omkarsable3624 2 жыл бұрын
Ma'am Hindi mein rahega toh kafi accha rahega , kyoki Hindi mein koi bhi Indian learn kar sakta hai.
@mrs.villager3654
@mrs.villager3654 4 жыл бұрын
thank a lot
@Agyaatr108
@Agyaatr108 5 жыл бұрын
How to find greatest value in this list [7,9,[12,5,[30,15],17],7]
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
To find out the greatest value in nested list, First we need to convert the nested list to list (or we can say flat list). then we can use max() list2 = [] def get_max(list1): for i in list1: if type(i) == list: get_max(i) else: list2.append(i) return max(list2) list1 =[7,9,[12,5,[30,15],17],7] print(get_max(list1)) :)
@MuhammadWaseem-ck5gn
@MuhammadWaseem-ck5gn 4 жыл бұрын
Thank youuu😊
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
You're welcome 😊
@rudrachoudhary936
@rudrachoudhary936 3 жыл бұрын
Mam I wrote a code for the same but when I run this code and try to search for the value at 0 index the program gives the output as not found, please point out where am I going wrong def binary_search(sequence, item): begin_index = 0 end_index = len(sequence) - 1 while begin_index < end_index: midpoint = end_index//2 midpoint_value = sequence[midpoint] if midpoint_value == item: return(f'{item} found at index {midpoint}') break elif midpoint_value < item: end_index = midpoint-1 else: begin_index = midpoint+1 return(f'{item} not found in entered sequence') sequence_a = eval(input("Enter the sequence here: ")) item_a = int(input("Enter the number to be searched: ")) print(binary_search(sequence_a, item_a))
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
What is the order of the input ascending or descending ?
@rudrachoudhary936
@rudrachoudhary936 3 жыл бұрын
@@AmulsAcademy ascending
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Please check else body midpoint
@gamingminaty7538
@gamingminaty7538 2 жыл бұрын
I love you too much
@nagendravarma8495
@nagendravarma8495 5 жыл бұрын
I'm mad at yua voice
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you :)
@cyberenginee
@cyberenginee 3 жыл бұрын
Thanks a lot
Guess The Output | Python Programs and Answers
2:20
Amulya's Academy
Рет қаралды 39 М.
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
Каха и дочка
00:28
К-Media
Рет қаралды 3,2 МЛН
Learn Kubernetes Secrets & ConfigMaps with Real Examples
5:32
DevOps Tips and Tricks
Рет қаралды 2
Binary Search - A Different Perspective | Python Algorithms
8:56
10 Crazy Python Operators That I Rarely Use
11:37
Indently
Рет қаралды 45 М.
File Handling in Python | Python Tutorials for Beginners #lec95
45:32
Jenny's Lectures CS IT
Рет қаралды 112 М.
Binary Search in Java - Full Simple Coding Tutorial
17:48
Coding with John
Рет қаралды 130 М.
Merge Sort in Python Programming | Program | Detailed Explanation
32:42
Amulya's Academy
Рет қаралды 99 М.
Binary Search - Leetcode 704 - Python
9:40
NeetCode
Рет қаралды 174 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
Binary Search - Data Structures & Algorithms Tutorial Python #13
25:15
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41