Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Yesterday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Python Bootcamp 100 Days of Code
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MihiCherub" data-source="post: 26611350" data-attributes="member: 238676"><p>මම මේකට තව ටිකක් එකතු කරන්නම්. තාම Day 14 කරල නැති අය නම් මේව බලන්නවත් එපා තේරුමක් නෑ. demotivate වෙනව. අනික මේ problem එකට දෙන solution එක පට්ටම complex solution එකක්. interview එකේදි කියනව එච්චර දෙයක් බලාපොරොත්තු උනෙත් නෑ කියල. අඩුම ගානෙ මම වත් try කලේ නෑ. ඒතරමට අමාරුයි. එතකොට මේ [USER=119642]@hancok[/USER] 10min වලින්හැදුව කියන්නෙ මොකද්ද?</p><p></p><p>ඒ ප්රශ්නෙ හරියට තේරුම් නොගැනීම. මෙතන අපිට output එක කොහොමහරි ගන්න එක නෙමේ challenge එක. algorithm එකක් ලියල output එක ගන්න එකයි challenge එක. ඒකට මම වෙන ප්රශ්නෙකින් පැහැදිලි කරන්නම්</p><p></p><p>දැන් අපිට list එකක තියෙන value එකක index එක හොයන්න කියල code challenge එකක් interview එකකදි දෙනව.</p><p>example</p><p>[CODE=python]search_item = 33</p><p>items = [10, 14, 19, 26, 27, 31, 33, 35, 42, 44][/CODE]</p><p>candidateල තුන් දෙනෙක් සහභාගි වෙනව.</p><p></p><p>1st candidate [USER=119642]@hancok[/USER] වගේ කෙනා මෙහෙම ලියනව. ලියල කියනව තත්පර 10වත් ගියෙ නෑ කියල.</p><p>[CODE=python]print(items.index(search_item))[/CODE]</p><p></p><p>2nd candidate මෙහෙම algorithm එකක් ලියනව.</p><p>[CODE=python]def linear_search(ar, search):</p><p> for index in range(len(ar)):</p><p> if ar[index] == search:</p><p> return index</p><p> return 'Trace Error'</p><p></p><p>print(linear_search(items, search_item))[/CODE]</p><p></p><p>3rd candidate මෙහෙම algorithm එකක් ලියනව.</p><p>[CODE=python]def binary_search(ar, search):</p><p> low = 0</p><p> high = len(ar) - 1</p><p></p><p> while True:</p><p> # search not found</p><p> if high < low:</p><p> return 'Trace Error'</p><p> mid = low + (high - low) // 2</p><p></p><p> if ar[mid] == search:</p><p> return mid</p><p></p><p> elif ar[mid] < search:</p><p> # upper bound</p><p> low = mid + 1</p><p> else:</p><p> # lower bound</p><p> high = mid - 1</p><p></p><p>print(binary_search(items, search_item))[/CODE]</p><p></p><p>දැන් interview එක අවසානෙදි තෝරගන්න කවුද. අනිවාර්යෙන්ම candidate 3. ඒකට හේතුව එයා තමා #හොදටම_කරල_තියෙන්නෙ.</p><p>එහෙම වෙන්න හේතුව මෙතන ඉල්ලන්නෙ algorithm එකක් මිසක් කොහොමහරි output එක print කරන එක නෙමේ. ඒ නිසා candidate 1 [USER=119642]@hancok[/USER] පයින් ගහල එලවන්නෙ.</p><p></p><p>2nd, 3rd candidate අතරෙන් 3rd එක්කෙනා හොද වෙන්න හේතුව මොකද්ද? ඒකට Big 'O' notation කියල එකක් තියෙනව. ඒකෙ සරල තේරුම අපි ප්රශ්නයකට විසදුමක් ලබා දීමේදි විසදුම ලැබෙන්න steps කීයක් යනවද කියන එක. ඒ කියන්නෙ ලියපු code lines ගාන නෙමේ. අවාසාන පිලිතුර ලැබෙන්න යන steps ගානයි. worst case scenario (දරුණුම දේ තමා) Big 'O' notation එකෙන් බලන්නෙ.</p><p></p><p>2nd candidate ලියපු පිලිතුරේ කරන්නෙ list එකේ මුල ඉදන් අගට loop කරල බලනව index value එක search value එකත් එක්ක match වෙනවද කියල match වෙනව නම් index එක return කරනව.</p><p></p><p><img src="https://www.tutorialspoint.com/data_structures_algorithms/images/linear_search.gif" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>දැන් මේ solution එකේ ප්රශ්නයක් තියෙනව. අපිට දෙන list එක එන්න එන්න ලොකු වැඩි වෙනකොට අපිට ඕනෙ value එක හොයන්න යන කාලය එන්න එන්න වැඩි වෙනව. ලොකු වට ප්රමානයක් ඕනෙ වෙනව. ඒකියන්නෙ ලොකු steps ප්රමානයක් ඕනෙ වෙනව. හිතන්න items 1000ක් තියෙන list එකක 998වෙනි index එකේ තමා අපි හොයන value එක තියෙන්නෙ . දැන් මේ search algorithm එක පාවිච්චි කලොත් loop එක වට 998ක් ගියාම තමා අපිට ඕනෙ index එක return වෙන්නෙ.</p><p>Big 'O' notation එක බැලුවොත් O ( N )</p><p><a href="https://www.tutorialspoint.com/data_structures_algorithms/linear_search_algorithm.htm" target="_blank">https://www.tutorialspoint.com/data_structures_algorithms/linear_search_algorithm.htm</a></p><p></p><p><img src="https://www.101computing.net/wp/wp-content/uploads/Big-O-Notation-Linear-Algorithm.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>3rd candidate ලියපු පිලිතුරේ කරන්නෙ Divide and conquer approach එක. main problem එක sub problem වලට divide කරගෙන ඒ පොඩි sub problems වෙන වෙනම විසදන එක,</p><p></p><p><img src="https://www.tutorialspoint.com/data_structures_algorithms/images/divide_and_conquer.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="width: 461px" /></p><p></p><p>මේ algorithm එකේදි list එකේ මුල ඉදන් අගට බලන්නෙ නෑ. මුලින්ම list එකේ මැද්දෙන් පටන් අරන් search value එක තියෙන්න පුලුවන් පැත්ත හදුනාගෙන ඒ පැත්ත ආයිත් මැද්ද අරන් ඉස්සරහට යන algorithm එකක් තියෙන්නෙ.</p><p></p><p><img src="https://www.tutorialspoint.com/data_structures_algorithms/images/binary_search_1.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>Big 'O' notation එක බැලුවොත් O(log n)</p><p><a href="https://www.tutorialspoint.com/data_structures_algorithms/binary_search_algorithm.htm" target="_blank">https://www.tutorialspoint.com/data_structures_algorithms/binary_search_algorithm.htm</a></p><p></p><p></p><p><img src="https://www.101computing.net/wp/wp-content/uploads/Big-O-Notation-Logarithmic-Algorithm.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>දැන් එතකොට 3rd candidate ගෙ algorithm එක තමා හොදම.</p><p>තව search algorithm වර්ග තියෙනව. දැන් තාම course එකේ මුල් දවස් වල ඉන්න අය මේක කියවල demotivate වෙන්න එපා. මේව ටිකක් programming ඇඟට සෙට් උනාම කරල බලන්න ඕනෙ වැඩ. දැන්ම මේව කරන්න ගිහින් මේව නම් බෑ කියල ඔක්කොම අතාරින්න එපා.</p><p></p><p>දවස් 14 complete අයට try කරල බලන්න හොද මේ වගේ තවත් problem එකක් තමා Largest prime factor problem එක.</p><p><a href="https://projecteuler.net/problem=3" target="_blank">https://projecteuler.net/problem=3</a></p><p></p><p></p><p>example දීල තියෙන 13195 number එකට algorithm code එකක් ලියාගන්න පුලුවන් උනත් අන්තිමට අහන number එකට algorithm එක වැඩ කරන්නෙ නැ කියල ඔයාලටම තේරෙයි. Big 'O' notation</p></blockquote><p></p>
[QUOTE="MihiCherub, post: 26611350, member: 238676"] මම මේකට තව ටිකක් එකතු කරන්නම්. තාම Day 14 කරල නැති අය නම් මේව බලන්නවත් එපා තේරුමක් නෑ. demotivate වෙනව. අනික මේ problem එකට දෙන solution එක පට්ටම complex solution එකක්. interview එකේදි කියනව එච්චර දෙයක් බලාපොරොත්තු උනෙත් නෑ කියල. අඩුම ගානෙ මම වත් try කලේ නෑ. ඒතරමට අමාරුයි. එතකොට මේ [USER=119642]@hancok[/USER] 10min වලින්හැදුව කියන්නෙ මොකද්ද? ඒ ප්රශ්නෙ හරියට තේරුම් නොගැනීම. මෙතන අපිට output එක කොහොමහරි ගන්න එක නෙමේ challenge එක. algorithm එකක් ලියල output එක ගන්න එකයි challenge එක. ඒකට මම වෙන ප්රශ්නෙකින් පැහැදිලි කරන්නම් දැන් අපිට list එකක තියෙන value එකක index එක හොයන්න කියල code challenge එකක් interview එකකදි දෙනව. example [CODE=python]search_item = 33 items = [10, 14, 19, 26, 27, 31, 33, 35, 42, 44][/CODE] candidateල තුන් දෙනෙක් සහභාගි වෙනව. 1st candidate [USER=119642]@hancok[/USER] වගේ කෙනා මෙහෙම ලියනව. ලියල කියනව තත්පර 10වත් ගියෙ නෑ කියල. [CODE=python]print(items.index(search_item))[/CODE] 2nd candidate මෙහෙම algorithm එකක් ලියනව. [CODE=python]def linear_search(ar, search): for index in range(len(ar)): if ar[index] == search: return index return 'Trace Error' print(linear_search(items, search_item))[/CODE] 3rd candidate මෙහෙම algorithm එකක් ලියනව. [CODE=python]def binary_search(ar, search): low = 0 high = len(ar) - 1 while True: # search not found if high < low: return 'Trace Error' mid = low + (high - low) // 2 if ar[mid] == search: return mid elif ar[mid] < search: # upper bound low = mid + 1 else: # lower bound high = mid - 1 print(binary_search(items, search_item))[/CODE] දැන් interview එක අවසානෙදි තෝරගන්න කවුද. අනිවාර්යෙන්ම candidate 3. ඒකට හේතුව එයා තමා #හොදටම_කරල_තියෙන්නෙ. එහෙම වෙන්න හේතුව මෙතන ඉල්ලන්නෙ algorithm එකක් මිසක් කොහොමහරි output එක print කරන එක නෙමේ. ඒ නිසා candidate 1 [USER=119642]@hancok[/USER] පයින් ගහල එලවන්නෙ. 2nd, 3rd candidate අතරෙන් 3rd එක්කෙනා හොද වෙන්න හේතුව මොකද්ද? ඒකට Big 'O' notation කියල එකක් තියෙනව. ඒකෙ සරල තේරුම අපි ප්රශ්නයකට විසදුමක් ලබා දීමේදි විසදුම ලැබෙන්න steps කීයක් යනවද කියන එක. ඒ කියන්නෙ ලියපු code lines ගාන නෙමේ. අවාසාන පිලිතුර ලැබෙන්න යන steps ගානයි. worst case scenario (දරුණුම දේ තමා) Big 'O' notation එකෙන් බලන්නෙ. 2nd candidate ලියපු පිලිතුරේ කරන්නෙ list එකේ මුල ඉදන් අගට loop කරල බලනව index value එක search value එකත් එක්ක match වෙනවද කියල match වෙනව නම් index එක return කරනව. [IMG]https://www.tutorialspoint.com/data_structures_algorithms/images/linear_search.gif[/IMG] දැන් මේ solution එකේ ප්රශ්නයක් තියෙනව. අපිට දෙන list එක එන්න එන්න ලොකු වැඩි වෙනකොට අපිට ඕනෙ value එක හොයන්න යන කාලය එන්න එන්න වැඩි වෙනව. ලොකු වට ප්රමානයක් ඕනෙ වෙනව. ඒකියන්නෙ ලොකු steps ප්රමානයක් ඕනෙ වෙනව. හිතන්න items 1000ක් තියෙන list එකක 998වෙනි index එකේ තමා අපි හොයන value එක තියෙන්නෙ . දැන් මේ search algorithm එක පාවිච්චි කලොත් loop එක වට 998ක් ගියාම තමා අපිට ඕනෙ index එක return වෙන්නෙ. Big 'O' notation එක බැලුවොත් O ( N ) [URL]https://www.tutorialspoint.com/data_structures_algorithms/linear_search_algorithm.htm[/URL] [IMG]https://www.101computing.net/wp/wp-content/uploads/Big-O-Notation-Linear-Algorithm.png[/IMG] 3rd candidate ලියපු පිලිතුරේ කරන්නෙ Divide and conquer approach එක. main problem එක sub problem වලට divide කරගෙන ඒ පොඩි sub problems වෙන වෙනම විසදන එක, [IMG width="461px"]https://www.tutorialspoint.com/data_structures_algorithms/images/divide_and_conquer.jpg[/IMG] මේ algorithm එකේදි list එකේ මුල ඉදන් අගට බලන්නෙ නෑ. මුලින්ම list එකේ මැද්දෙන් පටන් අරන් search value එක තියෙන්න පුලුවන් පැත්ත හදුනාගෙන ඒ පැත්ත ආයිත් මැද්ද අරන් ඉස්සරහට යන algorithm එකක් තියෙන්නෙ. [IMG]https://www.tutorialspoint.com/data_structures_algorithms/images/binary_search_1.jpg[/IMG] Big 'O' notation එක බැලුවොත් O(log n) [URL]https://www.tutorialspoint.com/data_structures_algorithms/binary_search_algorithm.htm[/URL] [IMG]https://www.101computing.net/wp/wp-content/uploads/Big-O-Notation-Logarithmic-Algorithm.png[/IMG] දැන් එතකොට 3rd candidate ගෙ algorithm එක තමා හොදම. තව search algorithm වර්ග තියෙනව. දැන් තාම course එකේ මුල් දවස් වල ඉන්න අය මේක කියවල demotivate වෙන්න එපා. මේව ටිකක් programming ඇඟට සෙට් උනාම කරල බලන්න ඕනෙ වැඩ. දැන්ම මේව කරන්න ගිහින් මේව නම් බෑ කියල ඔක්කොම අතාරින්න එපා. දවස් 14 complete අයට try කරල බලන්න හොද මේ වගේ තවත් problem එකක් තමා Largest prime factor problem එක. [URL]https://projecteuler.net/problem=3[/URL] example දීල තියෙන 13195 number එකට algorithm code එකක් ලියාගන්න පුලුවන් උනත් අන්තිමට අහන number එකට algorithm එක වැඩ කරන්නෙ නැ කියල ඔයාලටම තේරෙයි. Big 'O' notation [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom