programming assignment

myloo93

Well-known member
  • Oct 27, 2012
    1,576
    184
    63
    මෙන්න මේක කාටහරි තේරුම් කරලා දෙන්න පුලුවන්ද ?

    1.3 Define what Big-O notation is and explain its role in evaluating efficiencies of algorithms. Write the Python program code for the above two algorithms and critically evaluate their efficiencies using Big-O notation.

    code : binary search and Linear search
     

    FFAlpha

    Well-known member
  • Jan 11, 2017
    925
    651
    113
    මෙන්න මේක කාටහරි තේරුම් කරලා දෙන්න පුලුවන්ද ?

    1.3 Define what Big-O notation is and explain its role in evaluating efficiencies of algorithms. Write the Python program code for the above two algorithms and critically evaluate their efficiencies using Big-O notation.

    code : binary search and Linear search


    Big O notation eke defination eke liyala ube wisthere karpan eke kohmede wadagath wene algo ekak effiecnecy widihete liyane.Ita passe binary search and linear serach ekte python walin code eke ghala e deke time complexity eke hoyane pen and paper ekeke liyala :P
     

    myloo93

    Well-known member
  • Oct 27, 2012
    1,576
    184
    63
    Big O notation eke defination eke liyala ube wisthere karpan eke kohmede wadagath wene algo ekak effiecnecy widihete liyane.Ita passe binary search and linear serach ekte python walin code eke ghala e deke time complexity eke hoyane pen and paper ekeke liyala :P

    critically evaluate their efficiencies using Big-O notation.

    menna me kalla therenne naththe bro. anith tika kala.
     

    ramishka

    Active member
  • Feb 11, 2007
    440
    188
    43
    critically evaluate their efficiencies using Big-O notation.

    menna me kalla therenne naththe bro. anith tika kala.

    Explain the time complexity and space complexity of each algorithm (best case scenario and worst case scenario of each). Then you can say how each algorithm will perform when the number of elements to search for is small. Similarly explain how each will perform when the searchable space is large. You can mention the best use cases of each algorithm as well.
     
    Last edited:

    හෙනයා

    Well-known member
  • May 23, 2014
    16,729
    16,831
    113
    Kottawa
    critically evaluate their efficiencies using Big-O notation.

    menna me kalla therenne naththe bro. anith tika kala.

    දරුනුවට විශ්ලේශනය කරන්න කියල තියෙන්නේ... :P

    n^2 & n log(n) වෙන්නෙ කොහොමද කියල explain කරන්න.. (time+space) වචනෙන් කියන්න අමාරු නම් හොදම වැඩේ graphically පෙන්නන එක... ඒක මාර effective.. :yes: :yes:

    කලින් recursion කරල තියෙනවනම් BS එකේ iterative & recursion implementation දෙකම පෙන්නන්න... :yes:

    https://www.youtube.com/user/mycodeschool/playlists
     
    Last edited:
    • Like
    Reactions: ForgottenSand

    myloo93

    Well-known member
  • Oct 27, 2012
    1,576
    184
    63
    හෙනයා;24053896 said:
    දරුනුවට විශ්ලේශනය කරන්න කියල තියෙන්නේ... :P

    n^2 & n log(n) වෙන්නෙ කොහොමද කියල explain කරන්න.. (time+space) වචනෙන් කියන්න අමාරු නම් හොදම වැඩේ graphically පෙන්නන එක... ඒක මාර effective.. :yes: :yes:

    කලින් recursion කරල තියෙනවනම් BS එකේ iterative & recursion implementation දෙකම පෙන්නන්න... :yes:

    https://www.youtube.com/user/mycodeschool/playlists

    n^2 & n log(n) වෙන්නෙ කොහොමද කියල explain කරන්න..

    macho start ekak dipanko.
     

    හෙනයා

    Well-known member
  • May 23, 2014
    16,729
    16,831
    113
    Kottawa
    n^2 & n log(n) වෙන්නෙ කොහොමද කියල explain කරන්න..

    macho start ekak dipanko.

    පොඩ්ඩක් වැරදුනා.. sequential search වල (n^2) නෙමෙයි (n)...

    sequential වලදි මුල ඉදන් අගට element එක හම්බ වෙනකන් එකින් එකටනෙහ් search කරන්නෙ... එතකොට worst case එකෙදි හොයන element එක අන්තිමටම තිබ්බොත් element ගානටම search වෙලා.. ඒ කියන්නෙ # of elements = (n) පාරක්ම search වෙලා..

    binary search එකකදි වෙන්නෙ මුලින්ම මැදට පැනල බලනව ඕනෙ element එක තියෙන්නෙ මුල් පැත්තෙද අග පැත්තෙද කියල.. මුල නම් ආයෙ මුල් කෑල්ලෙ මැද්දට පනිනවා. ආයෙ ඒ විදිහටම බලනවා.. ඔහොම ඔහොම හම්බ වෙනකන් මැද්දට පැන පැන යනවා.. එතකොට access ගාන හොයන්නෙ log(n) වලින්..

    කියනවට වඩා තේරෙනව බන් video එකක් බලුවම.. :yes:

     
    Last edited:

    imhotep

    Well-known member
  • Mar 29, 2017
    14,823
    8
    35,324
    113
    Explain the linear search and the binary search in terms of the big O notation. There should be plenty of resources on the net.
    a linear search (assuming a sorted list) is parsing through the list to locate the number you seek - say for a list of n numbers, the worst case is n iterations, and so we can say for the linear search is O(n)
    For a binary search, you start off from the middle element and depending on what we look for is less or greater than this mid element we search through the lower or upper segments using the same technique. This approach takes log(n) iterations and thus has O(log(n))
     
    Last edited:

    myloo93

    Well-known member
  • Oct 27, 2012
    1,576
    184
    63
    හෙනයා;24061821 said:
    පොඩ්ඩක් වැරදුනා.. sequential search වල (n^2) නෙමෙයි (n)...

    sequential වලදි මුල ඉදන් අගට element එක හම්බ වෙනකන් එකින් එකටනෙහ් search කරන්නෙ... එතකොට worst case එකෙදි හොයන element එක අන්තිමටම තිබ්බොත් element ගානටම search වෙලා.. ඒ කියන්නෙ # of elements = (n) පාරක්ම search වෙලා..

    binary search එකකදි වෙන්නෙ මුලින්ම මැදට පැනල බලනව ඕනෙ element එක තියෙන්නෙ මුල් පැත්තෙද අග පැත්තෙද කියල.. මුල නම් ආයෙ මුල් කෑල්ලෙ මැද්දට පනිනවා. ආයෙ ඒ විදිහටම බලනවා.. ඔහොම ඔහොම හම්බ වෙනකන් මැද්දට පැන පැන යනවා.. එතකොට access ගාන හොයන්නෙ n log(n) වලින්..

    කියනවට වඩා තේරෙනව බන් video එකක් බලුවම.. :yes:


    මචෝ linear search / Binary search
    ගැන අහන්නේ.

    මම මේක වෙන විදිහ දන්නවා මචන්. එත් මේ විදිහට explain කරන්නේ කොහොමද කියල හිතාගන්න අමාරු ?
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,823
    8
    35,324
    113
    මචෝ linear search / Binary search
    ගැන අහන්නේ.

    මම මේක වෙන විදිහ දන්නවා මචන්. එත් මේ විදිහට explain කරන්නේ කොහොමද කියල හිතාගන්න අමාරු ?

    You want to know why the binary search is ia O(log(n))? It's mathematics. Bit difficult to post the proof here.
    An easier way to look at it is...
    Each recursion you halve the number of remaining items if you’ve not already found the item you seek for.
    You can only divide a number n recursively into halves at most log(n) times - and it is from this that the term log(n) comes into play.
    Note this is not log to the base 10 we are talking here.. but log to a base of 2.
     
    Last edited:

    හෙනයා

    Well-known member
  • May 23, 2014
    16,729
    16,831
    113
    Kottawa
    You want to know why the binary search is ia O(log(n))? It's mathematics. Bit difficult to post the proof here.
    An easier way to look at it is...
    Each recursion you halve the number of remaining items if you’ve not already found the item you seek for.
    You can only divide a number n recursively into halves at most log(n) times - and it is from this that the term log(n) comes into play.
    Note this is not log to the base 10 we are talking here.. but log to a base of 2.

    :yes: