tag:blogger.com,1999:blog-49671425484578937212017-08-17T17:54:58.851-07:00Learn AlgorithmAuthornoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4967142548457893721.post-48224422911567931802017-07-22T17:55:00.007-07:002017-08-14T20:59:40.294-07:00Why Algorithm <div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;">Problem solving is not all about getting the right result, writing an algorithm that solves a problem but requires a year is hardly of any use, likewise, an algorithm that requires several gigabytes go main memory is not (currently) useful on most machine. When solving a problem we need to consider several resources such as time and memory space before choosing the logic to use, this is where knowing the exact algorithm to use come in.</div><div style="text-align: justify;"><br /></div><div><div style="text-align: justify;">There have been several arguments on which to learn first, algorithms (and data structure) or programming languages or is there even a need to learn/study algorithm at all. This write up will cover why you should study algorithm and data structure .</div><div style="text-align: justify;"><br /></div></div><div><div style="text-align: justify;"><br /></div><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: justify;"><tbody><tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/-HLl6VeawiHk/WXPykrmJjbI/AAAAAAAACmw/fWlkQ2_Mz5IOub4BVEJVziUlMQ0xi1pVgCLcBGAs/s1600/image145%2B%25281%2529.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://4.bp.blogspot.com/-HLl6VeawiHk/WXPykrmJjbI/AAAAAAAACmw/fWlkQ2_Mz5IOub4BVEJVziUlMQ0xi1pVgCLcBGAs/s320/image145%2B%25281%2529.jpg" width="316" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Network connectivity problem:-</td></tr></tbody></table><div class="separator" style="clear: both; text-align: justify;"><br /></div><div style="text-align: justify;">“ Given a large set of items that are connected to another pair wise is there a way to get from one part to another. as you can see from the diagram above its not clear if there is a solution or not” </div></div><div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Most self learnt programmer jump straight into development without having the fundamental knowledge of how exactly some logic works. Programming is all about applying logic to solving problems. An algorithm represents your solution to a programming problem, algorithm which are methods for solving problems. While you may not implements some of the algorithm everyday, the knowledge will sharpen your approach to problem solving. Apart from learning algorithm for fundamentals , there are also tons of other reasons why you should study algorithms, the impact is very broad , far reaching and also helps in intellectual stimulations</div><div style="text-align: justify;"><br /></div><blockquote class="tr_bq" style="text-align: justify;">For me , great algorithm are the poetry of computation, just like verse, they can be terse, allusive, dense, and even mysterious . But once unlocked, they cast a brilliant new light on some aspect of computing -- Francis sullivan</blockquote><blockquote class="tr_bq" style="text-align: justify;">An algorithm must be seen to be believed -- Donald Knuth</blockquote><blockquote class="tr_bq" style="text-align: justify;">I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important . Bad programmers worry about the code. God programmers worry about data structures and their relationships -- Linus Torvalds ( Creator of Linux)</blockquote><blockquote class="tr_bq" style="text-align: justify;">Algorithms + Datat structures = Programs -- Niklaus Wirth</blockquote><div style="text-align: justify;"><br /></div><div style="text-align: justify;">There will often be limited resources when solving a problem so Writing the perfect and efficient login/solution to a problem requires the right set of data structure and algorithms, Because there are always several ways to solve a program , but not all the method are good and efficient. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">If you want to become a master programming, then learning how to write great algorithms is a must. You can start learning algorithms without prior knowledge of any programming language but to be able to implement them you would need to learn at least one programming language. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Here are few topics you should look into to become an algorithm expert </div><div style="text-align: justify;"><div>Data types: stack, queue, bag, union-find, priority queue</div><div>Sorting: sorting quicksort, mergesort, heapsort and radix sorts</div><div>Searching: Binary search tree, red-black tree, hash table</div><div>Graphs: Breath first search, DFS, prim, kruskal, Dijkstra</div><div>Strings: KMP, regular expression . TST, Huffman, LZW</div><div>Advance: B-tree, suffix array, maxflow</div><div><br /></div></div><div style="text-align: justify;">Recommended Books :</div><div style="text-align: justify;"><div><a href="https://www.wikiwand.com/en/The_Art_of_Computer_Programming">Donald Knuth’s The Art of Computer Programming</a></div><div>Algorithm Design Manuel</div></div><div style="text-align: justify;"><br /></div><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px} li.li1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} li.li2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Menlo; color: #454545} li.li4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #e4af0a} span.s1 {font: 10.0px Menlo} span.s2 {font: 10.0px Menlo; color: #454545} span.s3 {font: 12.0px 'Helvetica Neue'; text-decoration: underline ; color: #e4af0a} ul.ul1 {list-style-type: disc} </style></div></div>Authornoreply@blogger.com1tag:blogger.com,1999:blog-4967142548457893721.post-49698408749711908882016-01-27T18:05:00.001-08:002016-01-30T14:05:05.063-08:00The wonders of prime numbers<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;">People often come across diverse prime number problems, such as Finding largest prime factor of a number or finding all primes between two values. A prime number is a whole number greater than 1 that can only be divisible by itself and 1. It is obvious that prime numbers are different from other numbers because of it several applications in the real world.<br /><br />Questions like this "find the ten digit prime number having highest number of fives in it" may throw you of course a bit, after seeing such questions you often wonder "How many prime number exist", "what is the fastest way to generate a continuous stream of prime numbers" etc.<br /><br />There have been several problems and several solutions on prime numbers. This part of mathematics is not a joke, Many questions regarding prime numbers remain open, such as Goldbach's conjecture (that every even integer greater than 2 can be expressed as the sum of two primes), and the twin prime conjecture (that there are infinitely many pairs of primes whose difference is 2). Such questions spurred the development of various branches of number theory, focusing on analytic or algebraic aspects of numbers. people have even studied just prime numbers as a profession, this is to show the extent at which its relevant.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-gSljhOIUAkY/Vql4UmESSKI/AAAAAAAACBc/BLM8Tel_Jhc/s1600/prime%2Bnumber%2Bchart%2BII.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="http://4.bp.blogspot.com/-gSljhOIUAkY/Vql4UmESSKI/AAAAAAAACBc/BLM8Tel_Jhc/s320/prime%2Bnumber%2Bchart%2BII.jpg" width="320" /></a></div><br /><br />The applications of prime numbers in computing can not be quantified, from cryptography to various generalizations functions. As a computer scientist the deep knowledge of prime number will be required when working on project such as encryption, special generators functions etc. If you are a computer scientist or programmer without fundamental knowledge of prime numbers, then you should go and study a book on it after this post.<br /><br />Here is one of the provoking problems you will encounter, "The product of a 3 digit palindrome and 13379872 is an exciting 10 digit number, which is also a palindrome. one less than this number is the product of 5 and 6 digit prime numbers. find the palindrome and the prime factors". you should give it a try.<br /><br />Note:<br /><br /><ul><li>2(Two) is the only even prime number</li><li>when testing if a number n is prime, only divide to square root of n</li></ul>Subsequent post will discuss on several methods of generating prime numbers<br />For programming problems on prime numbers check <a href="https://projecteuler.net/archives">https://projecteuler.net/archives</a></div></div>Authornoreply@blogger.com0tag:blogger.com,1999:blog-4967142548457893721.post-18803891024063699302016-01-26T14:09:00.001-08:002017-07-09T14:52:27.700-07:00Mathematics and Programming<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">People Have wondered if good knowledge in mathematics is required to be a proficient programmer or software developer, depending on who you ask the question you will either get a Yes or a No as an answer.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">The questions may not necessarily be a 'yes' or 'No' answer, it more of knowing the focus of the person involved. learning a programming language such as Java, python, c++, c#, php, ruby obviously does not require a mathematical background or knowledge. The more a person programs in a language the more proficient the person becomes, so there is no really any required mathematical skills. But being a software engineer or programmer is not just all about writing programming in a literal sense ( writing of codes ), you may need some basic mathematical skills in approaching a solution faster or getting a more optimizes solution.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-96Dg2aGSUfc/VqgN5t8PT0I/AAAAAAAACBI/FSfc5xkJHKs/s1600/mathcsc.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://1.bp.blogspot.com/-96Dg2aGSUfc/VqgN5t8PT0I/AAAAAAAACBI/FSfc5xkJHKs/s400/mathcsc.jpg" width="400" /></a></div><br /></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Computer science is entirely different from programming, Although programming is a core part of computer science, most people outside the field or new to the field often think it is the same or that programming is the only thing in computer science. computer science deals with the science of computer, every thing about it, from bit manipulation, architecture, operating system to huge data structure. Mathematics is a core and very important part of computer science, and its relevant and indispensable for all computer science student. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Several algorithms used by programming languages and the ones used by the computer are core mathematical solutions, Mathematics is widely used in computer science research, as well as being heavily applied to graph algorithms and areas of computer vision. several topics were adopted from mathematics to computer science. Random number generator and shortest part algorithm are obvious examples of solutions derived from mathematics. Some of the early stage contributor to computer science algorithm were mathematicians although with core computer science background. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Examples of such people includes Edsger Wybe Dijkstra (professor of mathematics and computer scientist, One of the most influential perform in computer science. His fundamental contributions cover diverse areas of computing science, including compiler construction, operating systems, distributed systems, sequential and concurrent programming, programming paradigm and methodology, programming language research, program design, program development, program verification, software engineering ), Donald Ervin Knuth ( American computer scientist, mathematician, and professor emeritus. Author of The Art of Computer Programming. Knuth has been called the father of the analysis of algorithms). </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Its obvious now that a person can not be a proficient computer scientist without good knowledge of mathematics . Overall, for just programming, mathematics may not be required but for other areas of computer science mathematics is a must. </div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">Some list of mathematics for computer science resources</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/video-lectures/"><span style="color: blue;">MIT Mathematics for computer science</span></a></div><div style="text-align: justify;"><span style="color: blue;"><a href="https://projecteuler.net/"><span style="color: blue;">Project Euler programming</span></a> </span></div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><br /></div></div>Authornoreply@blogger.com1