Python Tutorials - Binary Search Program

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 170

  • @vaibhavpatharkar6794
    @vaibhavpatharkar6794 2 года назад +1

    Amulya madam , Thank you very much. People like you help, helpless people like me

  • @sktanweerrahaman9896
    @sktanweerrahaman9896 3 года назад +6

    You are literally making a lot conscious efforts for making us understand all these concepts..thanks a lot 🤩

  • @souravkr3305
    @souravkr3305 4 года назад +11

    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

  • @akshaykaushik5204
    @akshaykaushik5204 5 лет назад +3

    Awesome Undestanding. But Some Qns.
    1. If duplicate element in the list.
    2. print the index of the element.

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      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

  • @binab3817
    @binab3817 5 лет назад +12

    Waw ma'am realy u ar best trainer ever I have attended tutorials.
    Thankss, from Ethiopia, Africa

  • @morampalliyeswanthreddy2793
    @morampalliyeswanthreddy2793 3 года назад +8

    Madam such a wonderful teaching madam that I never seen before. Heartly congratulations for ur efforts madam❤️❤️

  • @anushkaparashar802
    @anushkaparashar802 3 года назад +1

    Mam... Can we use for loop instead of while loop in this program?? What will be the statement for , for loop?

  • @sivasurya4149
    @sivasurya4149 4 года назад +1

    Excellent madam..I saw all videos..very good explanation

  • @failure795
    @failure795 Год назад

    ma'am you are like a life saver. I swear i thank you....:) i will continue to use your channel

  • @muhammadjasoor4188
    @muhammadjasoor4188 3 года назад +1

    Didi you are doing a great job . your explanation are very much easily understandable. Thank you so much .

  • @JSONY-ff2ni
    @JSONY-ff2ni 3 года назад +1

    madam thank u soo much ur explaination is too good ur channel is very helpful for me

  • @greeshmashetty1724
    @greeshmashetty1724 4 года назад +2

    This is super informative and explained in simple terms. Thank you for sharing your knowledge amulya.

  • @greatab2977
    @greatab2977 4 года назад +2

    Is there break statement required after if condition?

    • @AmulsAcademy
      @AmulsAcademy  4 года назад +1

      If we use else then break is not required :)

    • @greatab2977
      @greatab2977 4 года назад +2

      @@AmulsAcademy ok,thanks

  • @rakeshpittala8832
    @rakeshpittala8832 3 года назад +1

    Thnks ma'am!!!!😘
    I'm learning a lot from your videos.....

  • @anuradhabalasubramanian9845
    @anuradhabalasubramanian9845 4 года назад +1

    Awesome Mam .Love your way of teaching. Great Work

  • @theultimateman7812
    @theultimateman7812 6 месяцев назад

    Mam binary search is applicable for sorted array right

  • @sriraj8392
    @sriraj8392 3 года назад

    omg thank uuu mam, ur voice makes me listen more like class room tutor , thank uu madamm....👌👌👌👍👍👍👍👍🤞🤞🤞

  • @addankilikhitha4539
    @addankilikhitha4539 4 года назад +2

    Thanking you for your efforts madam I got to know this topic much more clear now

  • @XMarketing580
    @XMarketing580 3 года назад

    Best teacher ever holyyyyyyyy

  • @icebear474
    @icebear474 3 года назад

    Is this one done with the help of recursion logic?

  • @nilimathorat4540
    @nilimathorat4540 Год назад

    If there is some same numbers in list at that time can we use this program or need to change something?

  • @shreyasaxena5160
    @shreyasaxena5160 4 года назад +1

    mam i could not understand the while condition, why low

    • @AmulsAcademy
      @AmulsAcademy  4 года назад +1

      that is the stopping condition for while loop, when low=high we need to stop.

  • @neelanshsharma4203
    @neelanshsharma4203 3 года назад +2

    thanks your videos are the most helpful ones.

  • @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)

  • @amansagar1041
    @amansagar1041 5 лет назад +2

    Code is not running showing error as false is not defined

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      you should write false as False it is a keyword.

  • @podishetticharan6013
    @podishetticharan6013 3 года назад +1

    Congratulations mam......🥳🥳🥳🥳🥳🥳 for 100k subscribers 🥰🥰🥰🥰🥰🥰🥰🥰

  • @mraksh898
    @mraksh898 3 года назад +1

    You make it easier to understand 😀🙏

  • @entershorts3277
    @entershorts3277 3 года назад +1

    What if we also want to show the index number like (key is found at index ....)

    • @AmulsAcademy
      @AmulsAcademy  3 года назад +1

      To print its index, when you return mid you can print list1[mid] .

  • @usmanimtiaz1519
    @usmanimtiaz1519 5 лет назад +2

    it show error in line 9 elif key > arr[mid]:
    TypeError: '>' not supported between instances of 'int' and 'str'
    how to fix this error

  • @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 🙂🙂

  • @sailesh2838
    @sailesh2838 8 месяцев назад

    10:30 how will low become greater than high ? can someone explain ?

  • @analyticstamizan677
    @analyticstamizan677 5 лет назад +1

    Superb... Mam.. 👌👌💯

  • @preethi2434
    @preethi2434 5 лет назад +3

    Mam, can you do more python programming in matrix with examples

  • @sathiyapriyan4969
    @sathiyapriyan4969 4 месяца назад

    how to print the index value of the element mam.

  • @abhaymanoharsaxena1174
    @abhaymanoharsaxena1174 5 лет назад +1

    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 лет назад +3

      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)
      :)

  • @afnanadit1029
    @afnanadit1029 4 года назад

    If I give a default value for the key then the key is found/not found is not shown.

  • @Dopeboyz789
    @Dopeboyz789 5 лет назад

    Is there a way to search for a value thats in the previous dataframe?

  • @Krishnna05
    @Krishnna05 Год назад

    can u teach this using recursive functions too?!

  • @SwapnilBhosale.----
    @SwapnilBhosale.---- 11 месяцев назад

    Mai aap ki awaj sunne k liye ata
    Hu or thoda sikhne ❤I love u mam

  • @ahmedsarker3555
    @ahmedsarker3555 3 года назад

    5:04 cant we use while loop

  • @sruthir1236
    @sruthir1236 4 года назад +1

    Can u please explain this
    While low

    • @AmulsAcademy
      @AmulsAcademy  3 года назад +1

      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

  • @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.

  • @prabirmaji185
    @prabirmaji185 4 года назад +1

    in the code you also need to mention the position of the key in the list

  • @IamHariJags
    @IamHariJags 3 года назад

    how to print the index as well plz help

  • @praveenasurya3211
    @praveenasurya3211 2 года назад

    hi ma'am, can you program for duplicate elemens in binary search

  • @shubhangnichandel3107
    @shubhangnichandel3107 4 года назад +1

    thanks ma'am yr explanation is realy good easy to understand

  • @vns3380
    @vns3380 4 года назад +1

    very nice explanation

  • @vaishnavivaishu100
    @vaishnavivaishu100 4 года назад +1

    you are the best lots of love to you dear:)

  • @abiii1157
    @abiii1157 3 года назад +1

    can u teach algorithm based interview programs ?mam

  • @asmodeus4310
    @asmodeus4310 3 года назад +1

    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 года назад +1

      Thank you, I will keep that in mind 😊

  • @shristisinha7264
    @shristisinha7264 3 года назад +1

    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 😊

  • @CSEkotniKanakaRaju
    @CSEkotniKanakaRaju 4 года назад +1

    mam ur explanation is super mam

  • @kashishjain20
    @kashishjain20 3 года назад +1

    what is the use of key??

    • @AmulsAcademy
      @AmulsAcademy  3 года назад

      Key is the value you want to search 😊

  • @eeea7226
    @eeea7226 4 года назад +1

    The above program is not working mam..

    • @AmulsAcademy
      @AmulsAcademy  4 года назад

      Give me the program i will check :)

  • @ArshadAli-sr2mf
    @ArshadAli-sr2mf 3 года назад +1

    Ma'am please make video on BSF and DFS I just love each on of ur explanation.

  • @david-komi8
    @david-komi8 3 года назад

    If you want, you can use try and except for catch the error and avoid the program close

  • @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

  • @muhammadsohaib3908
    @muhammadsohaib3908 4 года назад +1

    very well explanation . Thank you

  • @sajidhussain6522
    @sajidhussain6522 3 года назад

    Nice explanation ✌

  • @obilisamy8930
    @obilisamy8930 3 года назад +1

    Mam if the position also founded means it would be very super anyway super mam

  • @snex-techprogrammer5110
    @snex-techprogrammer5110 2 года назад

    What if the target/key is repeated?

  • @ajayjha1995
    @ajayjha1995 5 лет назад +1

    great jobs, really i enjoyed learning alot

  • @arushpratapsingh5840
    @arushpratapsingh5840 3 года назад +1

    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.

  • @scikiefact
    @scikiefact Год назад

    Thank you ma'am jii!!😊❤

  • @atulgupta9946
    @atulgupta9946 5 лет назад +3

    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❣️

  • @sunandamahanta9964
    @sunandamahanta9964 4 года назад

    why do you define a variable 'Found=False', i didn't understand that part !! Please explain.

    • @AmulsAcademy
      @AmulsAcademy  4 года назад +1

      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

  • @chanducam4433
    @chanducam4433 5 лет назад +3

    Plzzz mam put a video on palindrome n anagram

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      Palindrome Program:
      ruclips.net/video/UkcfX02_KGo/видео.html
      :)

    • @chanducam4433
      @chanducam4433 5 лет назад +1

      Anagram too mam

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +1

      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.

  • @kanchann8365
    @kanchann8365 4 года назад +1

    How to solve typerrror of len() ??

    • @AmulsAcademy
      @AmulsAcademy  4 года назад

      Give me the program please i will check :)

  • @malikshab832
    @malikshab832 5 лет назад +1

    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

  • @shiva-vz5qf
    @shiva-vz5qf 2 года назад

    maam helped a lot but what if we also had to give index

  • @debojitmandal8670
    @debojitmandal8670 3 года назад +1

    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

  • @yasmeenkarachiwala9612
    @yasmeenkarachiwala9612 5 лет назад +1

    Thank so you much!!! Amazing. Please post video on Binary Tree Inorder,Preorder

  • @praizdev
    @praizdev 2 года назад

    Thank you so much for this video

  • @RuthJames-xh3mk
    @RuthJames-xh3mk Год назад

    Thanks a lot for your help, may god bless you

  • @NewSSS23
    @NewSSS23 4 года назад

    Awesome explain mam

  • @anubhavsingh8144
    @anubhavsingh8144 5 лет назад +1

    Pls make the video on LCS ALGORITHM

  • @akshaysb526
    @akshaysb526 3 года назад +2

    perfect, thank you

  • @kironpaul7581
    @kironpaul7581 4 года назад +1

    Please create a video on BST!!!(DATA STRUCTURE)

  • @tabishnoor8537
    @tabishnoor8537 4 года назад

    Please also show how to take input from user , it is showing error in comprehensive method

  • @RahmanIITDelhi
    @RahmanIITDelhi 2 года назад

    good one...

  • @chaitranaik3673
    @chaitranaik3673 2 года назад

    Thanks a lot ma'am

  • @techguru4122
    @techguru4122 4 года назад +1

    Please make tute on radix and count sort very soon

  • @L-oNhaVan
    @L-oNhaVan 3 года назад

    Thank you so much

  • @hemanthn436
    @hemanthn436 5 лет назад +1

    ma'am a sincere request could you do datastructruces of python please it helps me alot for my placement

  • @simplyanup9658
    @simplyanup9658 Год назад

    Usually, we use binary search to find the index number of the key which you didn't show.

  • @junaidiqbal2321
    @junaidiqbal2321 3 года назад +1

    Please make videos BFS, DFS

    • @AmulsAcademy
      @AmulsAcademy  3 года назад

      Noted 😊

    • @junaidiqbal2321
      @junaidiqbal2321 3 года назад

      @@AmulsAcademy As soon as possible i have paper on friday pleaseeeeeee

  • @ijaspreet
    @ijaspreet 4 года назад

    Thank you ma'am

  • @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)

  • @techguru4122
    @techguru4122 4 года назад

    Within a week👏🙏🙏

  • @shiva-vz5qf
    @shiva-vz5qf 2 года назад

    of the element to be found

  • @Agyaatr108
    @Agyaatr108 5 лет назад +1

    How to find greatest value in this list
    [7,9,[12,5,[30,15],17],7]

    • @AmulsAcademy
      @AmulsAcademy  5 лет назад +2

      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))
      :)

  • @mrs.villager3654
    @mrs.villager3654 4 года назад

    thank a lot

  • @Ironblood108
    @Ironblood108 3 года назад +1

    👍

  • @rudrachoudhary936
    @rudrachoudhary936 3 года назад +1

    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))

  • @MuhammadWaseem-ck5gn
    @MuhammadWaseem-ck5gn 4 года назад +1

    Thank youuu😊

  • @omkarsable3624
    @omkarsable3624 2 года назад

    Ma'am Hindi mein rahega toh kafi accha rahega , kyoki Hindi mein koi bhi Indian learn kar sakta hai.

  • @nagendravarma8495
    @nagendravarma8495 5 лет назад +1

    I'm mad at yua voice

  • @gamingminaty7538
    @gamingminaty7538 2 года назад

    I love you too much

  • @cyberenginee
    @cyberenginee 3 года назад

    Thanks a lot