Guest User

Untitled

a guest
Apr 21st, 2017
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.99 KB | None | 0 0
  1. fjaos'jfodsajfodsjaofjdsa'fafjjasdfsdafPlease refresh this page to receive new updates.
  2.  
  3. Ask Question
  4. Read
  5. Answer
  6. Notifications
  7. Jinai Arh
  8. Jinai
  9. Students
  10. Algorithms
  11. Computer Science Education
  12. Computer Programming
  13. Which are the 10 algorithms every computer science student must implement at least once in life?
  14. Answer
  15. Request
  16. Follow4k
  17. Comment
  18. Share80Downvote
  19. Promoted by Loggly
  20. Reveal what matters in your log data.
  21. Live Webinar, April 20th:Collect and analyze data generated by AWS services and applications with Loggly.
  22. Sign Up at pages.awscloud.com
  23. 37 Answers
  24. Soham Mehta
  25. Soham Mehta, InterviewKickstart.com. We do this for a living
  26. Updated Jan 12 · Upvoted by Dan Zhang, Computer Engineering PhD student at UT Austin; interned at Microsoft and Apple and Abhishek Dwivedi, MTech in Computer Science from NMiMS
  27. In my daily work [Coding Interview Bootcamp], we come across a lot of neat CS algorithms.
  28.  
  29. A good place to answer this question, would be to see an article that Mathematician Barry Arthur Cipra wrote a few years ago, based on survey of several practitioners: Top 10 Algorithms in 20th Century. That has an excellent list.
  30.  
  31. However, I guess what you’re looking for, are CS algorithms that are ubiquitous in everyday things. Algorithms so pervasive in things we pickup every day, yet a normal person doesn’t know they exist, and we didn’t even do them in our CS courses!
  32.  
  33. Why not implement them, just for fun? Just for gratitude?
  34.  
  35. I’m going to list a few of those below. Not “top 10”, or “best 10”, but “tantalizing 10”, or just “reasonable 10”. What I mean is, that there are many more than 10 that I list here.
  36.  
  37. I’m going to avoid the obvious ones e.g. Binary searches and hash tables. I’ll also avoid some super esoteric ones, like say Krylov.
  38.  
  39. I’ll bias towards ones that are very pervasive in everyday things, are more easily implement-able, you have likely heard of them as a CS student, yet it’s unlikely that you have done them in a CS course. Most importantly, all of these run right under your nose, every day.
  40.  
  41. Some of these are so within reach, that they even form actual coding interview questions! Hope you find them as much fun as I did.
  42.  
  43. Without further ado, in no particular order:
  44.  
  45. Plagiarism detection, using Rabin Karp String matching
  46. String matching algorithms are pervasive in software. One particularly fun one, is Rabin Karp, which is used in Plagiarism detection. As a student in CS (or in any major), plagiarism detection should be of interest ;-)
  47. Rabin Karp is relatively easy to implement. See this: Rabin–Karp algorithm - Wikipedia
  48. Rabin Karp has also inspired a string matching routine in Zlib (one of the most popular un/zip libraries ever). See this, directly into the source code.
  49. Matching users to servers, using Gayle-Shapely Algorithm for Stable Marriage problem
  50. This is a beautiful algorithm for fair matching. Simple, elegant and effective. In its core form, it’s also straightforward to implement. Has numerous applications. See: Stable marriage problem - Wikipedia
  51. A toy implementation of Viterbi algorithm
  52. Ubiquitous in cell phone technology, and many other applications, Viterbi algorithm is a Dynamic Programming based algorithm that finds the most likely sequence of states.
  53. See this toy implementation: http://homepages.ulb.ac.be/~dgon...
  54. Music Search using Fast Fourier Transforms (FFT)
  55. Music recognition is done by converting it into frequency domain using FFT. FFT has implementations in number of languages. See this article for a great start: Shazam It! Music Recognition Algorithms, Fingerprinting, and Processing.
  56. Implement RSA algorithm
  57. SSL transport, is the bane of safe existence on Internet these days. One of the most well-known algorithms in secure transport, is RSA, named by the first initials of its inventors.
  58. Implementing RSA is fun and instructive e.g. C code to implement RSA Algorithm(Encryption and Decryption)
  59. Safe Browsing (or similar) using Bloom filters
  60. Bloom filters found very rare usage until the world got more online and we hit scale. But these days, we see new applications very frequently.
  61. Chrome browser uses Bloom filters to make preliminary decision on safe browsing. See some novel applications here.
  62. Implement an LALR parser
  63. As a CS student, you may have already implemented it as part of your compiler’s class. But if not, then you should. LALR parsing makes syntactic sense of source code, whichever language you use
  64. Many implementations of LALR exist. e.g. Where can I find a _simple_, easy to understand implementation of an LR(1) parser generator?
  65. Also, use YACC to understand LALR parsing better.
  66. Treemap using Red Black Trees!
  67. RB Trees are not algorithms, but they are famed enough, that no discussion of tantalizing DS/Algorithms is complete without discussing them.
  68. The smoothest way to see/implement RB Trees, is to look at Treemap implementation in Java.
  69. Circle Drawing using Bresenham’s algorithm
  70. Ever wondered, how circles are drawn on the screen, with minimal jaggedness (aliasing)? Bresenham’s elegant algorithm is at play here. See a version here: Circle Generation Algorithm .
  71. A refreshing use of a similar algorithm, is to make properly sized tabs in Chrome. Something we see almost every day. Such hidden gems!
  72. Implement PageRank
  73. Can’t miss this. This transformed our lives in ways we never thought possible. Get started here: Pagerank Explained Correctly with Examples
  74. As you’ll see, most useful algorithms are usually not the hardest ones. They are often the most straightforward ones, ones that are easily understood and thus move the world forward.
  75.  
  76. I hope you will enjoy them.
  77. 87.4k Views · View Upvotes
  78. Upvote1.2kDownvoteComments8
  79. Share
  80. Promoted by CUBA Platform
  81. Open source Java Web Framework
  82. Visual design, code generation, enterprise components out of the box.
  83. Download at cuba-platform.com
  84. Peteris Erins
  85. Peteris Erins, Product Manager at QuantumBlack, previously at Twitter, Google
  86. Written Jan 26, 2013 · Upvoted by Siddarth Sampangi, UCSD B.S. in CS '14; UMass Amherst M.S. in CS '16 and Igor Markov, EECS Professor at Michigan - currently at Google
  87. Coming from an intensive programming contest background, having read Introduction to Algorithms, etc., but then moving on to doing real-life projects, I find that some of the more interesting and powerful algorithms in a problem solving setting find little use in the industry.
  88.  
  89. I'm thus going to present algorithms that carry over to engineering, not just research and TopCoder. Another goal was for these algorithms to be useful and widely applicable hammers in their own right, not just as an idea. The benefits of most "algorithms" will be hard to explain them to someone who has not yet been introduced to them, but I tried my best of giving a hint for their role.
  90.  
  91. Naive Bayes. Classification is a natural first step to machine learning and the Naive Bayes classifier combines that with the trending concept of Bayesian inference. Despite its simplicity, can address key problems like spam classification.
  92. Map-Reduce. A simple and visual way of leveraging multiple computers to solve a single task. More on its different uses here: MapReduce Patterns, Algorithms, and Use Cases.
  93. Hill Climbing. Introduces optimization over a non-exhaustible domain and leads to a whole array of powerful methods like gradient-descent, simulated annealing. Optimization allows us to do decision making, it's important.
  94. Binary search. Introduces logarithmic complexity and how the structure of data can change complexity characteristics of operations.
  95. Exponentiation (powers) by halving. Great example of a recursive attack. You would be surprised how many problems can be described as exponentiation (for an associative operation) of something: a number, a matrix and more. Again it's magical that associativity of an operation allows you to turn a linear factor into a logarithmic one.
  96. Floyd-Warshall. Graphs as matrices, shortest paths, negative cycles, dynamic programming in five lines of code.
  97. Inductive inference. Inductive inference. This idea on how to find programs that do certain things without having a human write them I believe is the key to the future of AI and simulating and understanding the human mind.
  98. Markov Chain Monte Carlo. Approximate integral, expected value computation based on a conditional specification of the probability distribution. This gives us a general way of doing data analysis.
  99. Shor's algorithm. Non-trvial example of a quantum algorithm that shows a significant complexity improvement. Reveals how quantum computing works.
  100. PageRank. How to iteratively solve for tightly related variables to extract metrics on graphs.
  101. 138.4k Views · View Upvotes
  102. Upvote703DownvoteComments8+
  103. Share
  104. Promoted by Shopify
  105. Create Ecommerce Website
  106. Start a 14-day free trial now! Easy setup and free 24/7 support.
  107. Free Trial at shopify.com
  108. Sachin Gupta
  109. Sachin Gupta, Programming for some years now :)
  110. Written Sep 27, 2015
  111. Don't have a list of 10 algorithms, but 7 algorithms that every programmer should know. The first 2 in the list are Sorting and Searching algorithms, which in themselves have many algorithms that should be known, so the list actually goes beyond just 10.
  112.  
  113. Sorting Algorithms
  114. Searching Algorithms
  115. Hashing
  116. Dynamic Programming
  117. Binary Exponentiation
  118. String matching and parsing
  119. Primality Testing
  120. These topics have been taken from this blog post (Top 7 algorithms and DS every programmer should know) that covers all of these topics in detail.
  121. 29.6k Views · View Upvotes
  122. Upvote137DownvoteComment
  123. Share
  124. Ron Reiter
  125. Ron Reiter, 20 years a computer geek
  126. Written May 21, 2016
  127. Aside for the must’s (BFS, DFS, sorting, hashing, binary search and tree traversal, divide and conquer, and basic data structures which are not exactly algorithms per se) I would like to suggest a few more from a practical perspective. Not exactly the “top 10” but very useful, practical and simple ones.
  128.  
  129. Maze creation algorithms - this would give a great context to where to actually use the DFS, BFS, Dijkstra and A* algorithms. And it’s fun. The maze creation algorithm itself is not useful, but it’s a great playground for graph solving algorithms, which are extremely useful in the real world. A* is also nice because all strategy games we play today use it to plan out the shortest walking route, so you can try it out on a maze.
  130. Bloom filter - probably one of the most useful algorithms to know that exist in the data structures world. It helps reducing lookup cost. It is important because lookups are usually very common and expensive, so a bloom filter checks if data access is even necessary beforehand. You could stick a bloom filter in just about any data structure. Very easy to code.
  131. Hidden Markov Model - I have used this algorithm at least twice in two different contexts - one for breaking ciphers and another for compression. It can be even used for computer vision applications. It’s very useful when trying to predict probability of the next output of a system given a series of previous outputs. Read more about the Forward Algorithm. It is also extremely easy to code.
  132. Huffman Coding - The simplest form of efficient encoding. Teaches a lot about how data is stored on the computer, and about the theoretical limits of storing data efficiently. Also used in zip, gzip, etc.
  133. RLE Compression - The simplest form of compression out there. Very easy to code.
  134. 2D Ray Caster - The simplest form of a 3D first person shooter you could build. This is how games like Wolfenstein 3D and Doom work. It’s useful because it’s extremely simple, and because raycasting is one of the core foundations of computer graphics. It is also extremely easy to code and understand. Requires very basic understanding of trigonometry.
  135. Deterministic & Heuristic game solvers - A very fun exercise for learning how AI works when playing games against the computer. The easiest one would be to write the tic-tac-toe AI, but you could also go and create chess and checkers, and then implement some heuristics to know the next best move. Also useful to understand the infinite complexity of chess and checkers compared to “solved” games such as tic-tac-toe.
  136. FFT (Fast Fourier Transform) - Programming FFT is not something important to learn because it is based on a lot of theoretical background. But using FFT and similar algorithms such as DCT, wavelets, etc. is also very useful to know for analyzing, compressing and modifying sound, images and video. Anything you can think of in signal processing - from changing pitches, auto-tuning, MP3 compression, JPEG compression, video compression, photoshopping, is done by transforming signals from the spatial domain to the frequency domain, and vice versa.
  137. Public-key cryptography - Very powerful algorithms that solve the key issue of eavesdropping. Both RSA (public/private) and Diffie-Hellman (mutual key exchange) are very easy to implement, and provide you with great understanding on how secure information travels in insecure channels today - secure web pages, certificates, SSH and end-to-end encryption are just a few examples. Requires a bit of modulu arithmetics background but still very simple to implement.
  138. Control loop feedback algorithm (PID) - The most basic algorithm for programming actual robots and IoT devices which controls a specific state by receiving feedback from sensors and applying commands to motors to adjust the state. Examples are: thermostats, autonomous cars, computer guided missiles, etc. This is very easy to implement, but it will require a Raspberry Pi and some sensors to try out. The easiest thing to implement would be a robot that follows a straight line or keeps a specific distance from a wall.
  139. 12.4k Views · View Upvotes
  140. Upvote73DownvoteComments3
  141. Share
  142. There's more on Quora...
  143. Pick new people and topics to follow and see the best answers on Quora.
  144. Update Your Interests
  145. Related Questions
  146.  
  147. What are some must have books for current undergraduate computer science students like CLRS?
  148. What proportion of college students take at least some computer science?
  149. As a computer science grad student, what languages must I know?
  150. What are algorithmic problems that every cse student must solve?
  151. What are some amazing computer science algorithms?
  152. What are the top Stack Overflow questions every computer science student must see?
  153. What are some questions related to computer science on Quora that every computer science student should read?
  154. What are the most interesting famous Computer Science algorithms that you made your own implementation for?
  155. What are the artificial intelligence (AI) algorithms that every computer science student must be aware of?
  156. What are some of the computer science undergraduate courses (available online) which a student must take for graduation?
  157. More Related Questions
  158. Question Stats
  159.  
  160. 4,091 Followers
  161. 694,415 Views
  162. Last Asked Feb 21
  163. Edits
  164. Top Stories from Your Feed
  165. Read In Feed
  166. Answer written ·
  167. Cooking
  168. · 23h
  169. As a professional chef, when was the last time you ate ketchup in a meal?
  170. Rik Osborne
  171. Rik Osborne, Gets called "Chef" but is really just a good cook
  172. Written 23h ago
  173. The last time I ordered a fast-food burger and fries.Ketchup isn’t some lowly condiment that professionals look down on. It’s a perfectly good condiment that is suitable for some foods and is unsui...
  174. Read In Feed
  175. Answer written ·
  176. Computer Science
  177. · Topic you might like · Apr 5
  178. What's something that you should never say to an I.T. person?
  179. Ted Pettit
  180. Ted Pettit
  181. Written Apr 5
  182. The one thing I learned, years ago, from a column that used to be circulated by a guy who was a grouchy computer admin at a university (precursor to an "I.T. person"):Never ever ever say "My passw...
  183. Read In Feed
  184. Answer written ·
  185. Visiting and Travel
  186. · Mar 3
  187. What should I learn in my 20s that will help me to financially retire at 35 and travel the world for the rest of my life?
  188. Dylin Redling
  189. Dylin Redling, Founder at Retire By 45 (2016-present)
  190. Written Mar 3
  191. I retired at 43, but if I knew in my 20s what I know now, then I could’ve retired at 35. Here are the 6 steps I’ve developed to help young people set themselves up for a successful early retirement:...
Advertisement
Add Comment
Please, Sign In to add comment