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
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) :)
# 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)
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 🙂🙂
what if the list have null values. for example lits1= ["apple"," "," ", " ", "bat"," "," ","cat"," "," ","mat"]. Your given binary search will not work here.
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
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❣️
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. :)
@@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.
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)
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)) :)
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))
Amulya madam , Thank you very much. People like you help, helpless people like me
You are literally making a lot conscious efforts for making us understand all these concepts..thanks a lot 🤩
Pleasure 😊
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
Thank you so much 😀
Awesome Undestanding. But Some Qns.
1. If duplicate element in the list.
2. print the index of the element.
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)
:)
@@AmulsAcademy It does not work on the duplicate value
Waw ma'am realy u ar best trainer ever I have attended tutorials.
Thankss, from Ethiopia, Africa
Thank you :)
Madam such a wonderful teaching madam that I never seen before. Heartly congratulations for ur efforts madam❤️❤️
Thank you so much :)
@@AmulsAcademy madam If u take any classes on python In academy pls tell me i will join madam
Mam... Can we use for loop instead of while loop in this program?? What will be the statement for , for loop?
Excellent madam..I saw all videos..very good explanation
Thank you so much :)
ma'am you are like a life saver. I swear i thank you....:) i will continue to use your channel
Didi you are doing a great job . your explanation are very much easily understandable. Thank you so much .
Thank you :)
madam thank u soo much ur explaination is too good ur channel is very helpful for me
Thank you 😊
This is super informative and explained in simple terms. Thank you for sharing your knowledge amulya.
Glad it was helpful! :)
Is there break statement required after if condition?
If we use else then break is not required :)
@@AmulsAcademy ok,thanks
Thnks ma'am!!!!😘
I'm learning a lot from your videos.....
Glad to hear that 😊
Awesome Mam .Love your way of teaching. Great Work
Thanks a lot :)
Mam binary search is applicable for sorted array right
omg thank uuu mam, ur voice makes me listen more like class room tutor , thank uu madamm....👌👌👌👍👍👍👍👍🤞🤞🤞
Thanking you for your efforts madam I got to know this topic much more clear now
It's my pleasure :)
Best teacher ever holyyyyyyyy
Is this one done with the help of recursion logic?
If there is some same numbers in list at that time can we use this program or need to change something?
mam i could not understand the while condition, why low
that is the stopping condition for while loop, when low=high we need to stop.
thanks your videos are the most helpful ones.
My pleasure :)
# 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)
Code is not running showing error as false is not defined
you should write false as False it is a keyword.
Congratulations mam......🥳🥳🥳🥳🥳🥳 for 100k subscribers 🥰🥰🥰🥰🥰🥰🥰🥰
Thank you :)
You make it easier to understand 😀🙏
Thank you 😊
What if we also want to show the index number like (key is found at index ....)
To print its index, when you return mid you can print list1[mid] .
it show error in line 9 elif key > arr[mid]:
TypeError: '>' not supported between instances of 'int' and 'str'
how to fix this error
you need to take integer key, check that.
:)
@@AmulsAcademy thanks
you can use this int(low+high/2) or low+high//2
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 🙂🙂
10:30 how will low become greater than high ? can someone explain ?
Superb... Mam.. 👌👌💯
Mam, can you do more python programming in matrix with examples
I will try :)
how to print the index value of the element mam.
Hello Ma'am , in this question if we have to print the index position of the key what we've to do?
Please help!
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)
:)
If I give a default value for the key then the key is found/not found is not shown.
Is there a way to search for a value thats in the previous dataframe?
can u teach this using recursive functions too?!
Mai aap ki awaj sunne k liye ata
Hu or thoda sikhne ❤I love u mam
5:04 cant we use while loop
Can u please explain this
While low
Found is a variable with Boolean value.
Here we are taking 2 conditions with while loop
first is low
@@AmulsAcademy thq so much
what if the list have null values. for example lits1= ["apple"," "," ", " ", "bat"," "," ","cat"," "," ","mat"]. Your given binary search will not work here.
in the code you also need to mention the position of the key in the list
how to print the index as well plz help
hi ma'am, can you program for duplicate elemens in binary search
thanks ma'am yr explanation is realy good easy to understand
Most welcome 😊
very nice explanation
Thank you :)
you are the best lots of love to you dear:)
Thank you :)
can u teach algorithm based interview programs ?mam
Will try 😊
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
Thank you, I will keep that in mind 😊
mam, it's showing error : IndentationError: expected an indented block
I think you added extra or less space somewhere please check that 😊
mam ur explanation is super mam
Thanks a lot :)
what is the use of key??
Key is the value you want to search 😊
The above program is not working mam..
Give me the program i will check :)
Ma'am please make video on BSF and DFS I just love each on of ur explanation.
Soon 😊
If you want, you can use try and except for catch the error and avoid the program close
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
very well explanation . Thank you
You are welcome! :)
Nice explanation ✌
Mam if the position also founded means it would be very super anyway super mam
Yes you can do that 😊
What if the target/key is repeated?
great jobs, really i enjoyed learning alot
IndexError
When I use list 1,11,14,15,25 and search for 25 then it will give me index error
Can you give me the program, I will check it :)
are you complete masteress in python mam.
Thank you ma'am jii!!😊❤
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❣️
I will try :)
why do you define a variable 'Found=False', i didn't understand that part !! Please explain.
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.
:)
@@AmulsAcademy thanks..it helps
Plzzz mam put a video on palindrome n anagram
Palindrome Program:
ruclips.net/video/UkcfX02_KGo/видео.html
:)
Anagram too mam
Sure :)
@@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.
How to solve typerrror of len() ??
Give me the program please i will check :)
Mam
What code should be add in the program array (list) to find element location?
Try this:
def binarySearch(list1,key):
low = 0
high = len(list1)-1
found = False
while low
maam helped a lot but what if we also had to give index
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
Here we are using recursion :)
Thank so you much!!! Amazing. Please post video on Binary Tree Inorder,Preorder
Pleasure :)
Thank you so much for this video
Thanks a lot for your help, may god bless you
Awesome explain mam
Pls make the video on LCS ALGORITHM
I will try :)
perfect, thank you
Pleasure :)
Please create a video on BST!!!(DATA STRUCTURE)
Sure :)
Please also show how to take input from user , it is showing error in comprehensive method
good one...
Thanks a lot ma'am
Please make tute on radix and count sort very soon
I will try :)
Thank you so much
ma'am a sincere request could you do datastructruces of python please it helps me alot for my placement
I will try :)
Usually, we use binary search to find the index number of the key which you didn't show.
Please make videos BFS, DFS
Noted 😊
@@AmulsAcademy As soon as possible i have paper on friday pleaseeeeeee
Thank you ma'am
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)
Within a week👏🙏🙏
of the element to be found
How to find greatest value in this list
[7,9,[12,5,[30,15],17],7]
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))
:)
thank a lot
👍
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))
What is the order of the input ascending or descending ?
@@AmulsAcademy ascending
Please check else body midpoint
Thank youuu😊
You're welcome 😊
Ma'am Hindi mein rahega toh kafi accha rahega , kyoki Hindi mein koi bhi Indian learn kar sakta hai.
I'm mad at yua voice
Thank you :)
I love you too much
Thanks a lot