Additional resources for data structures and algorithms? Computer Science |
- Additional resources for data structures and algorithms?
- Humble Book Bundle: Computer Science by Mercury Learning. Is it worth buying?
- Recursion with Asynchronous JavaScript Callback Functions
- [UPDATE] A (cat) machine learning game I've been working on...
- SenseTime Trains ImageNet/AlexNet In Record 1.5 minutes
- What is a good introductory book on Information and Coding Theory for self-study ?
Additional resources for data structures and algorithms? Posted: 25 Feb 2019 06:08 PM PST I am a sophmore at my university, and I hear from many computer science students that algorithms are extremely important to the interview process and beyond. My school combines data structures and algorithms into one class and I have heard complaints that they do not go in depth enough in certain areas of algorithms. I know the basic concepts of data structures like linked-lists, trees, graphs, and some of the searching and sorting algorithms and but I am going to try to supplement the curriculum with self-taught learning on the subject. Are there any online resources that could help prepare me in this area? Thanks in advance. [link] [comments] |
Humble Book Bundle: Computer Science by Mercury Learning. Is it worth buying? Posted: 26 Feb 2019 02:07 AM PST |
Recursion with Asynchronous JavaScript Callback Functions Posted: 25 Feb 2019 08:26 PM PST Help please! I'm really stuck on recursion && asynchronous JavaScript callback functions right now... I'm a self-taught web developer, and I've never had any formal exposure to computer science fundamentals. I understand recursion on its own, and I also get how JavaScript callback functions work for the most part. But when I try to combine the two, my brain starts melting and I'm at a complete lost. I realize that this is a contrived example and something I wouldn't encounter in most code bases or technical interviews (IDK, maybe a Google interview??), but I'm seeking some help in a particular problem. Let's take for example the classic factorial challenge. Using recursion and JavaScript, that would look something like this:
``` const getNextNum = (num, callback) => { if (Math.random() > 0.5) { setImmediate(() => { callback(null, num - 1) }); } else { callback(null, num - 1); } } const getFactorial = (num, callback) => { getNextNum(num, (err, nextNum) => { if (!nextNum) { callback(null, num) } else { getFactorial(nextNum, (err, nextData) => { callback(null, num * nextData) }) } }) } ``` I basically mocked an asynchronous action by pulling out the decrement logic and making a helper function randomly return the decremented number immediately or later in the event queue. Looks a bit funky, but gets the job and even maintains the same order as the synchronous version. I started reviewing BST traversal algorithms and wanted to do the same thing with them. Implement the first solution with recursion, and then a second solution with recursion and callbacks. For this example, I want to show you the inorder traversal algo. If you have a collection of nodes that look like this: ``` [ {"value":"root","left":1,"right":2}, {"value":"L1","right":3}, {"value":"R1"}, {"value":"R2"} ] /* Binary Tree Visual L1 R1 \ \ R2 */ ``` The Inorder traversal algo should print the nodes in this order => L1, R2, root, R1 The synchronous version with recursion took a while for me to think up, but I got it working with this. ``` const results = []; const inorder = node => { if (node) { inorder(getNode(node.left)); results.push(node.value); inorder(getNode(node.right)); } } inorder(getRoot()); return results; `` In the same way I mocked an async function with my factorial example, I've written a couple of helpers for getNode and getRoot. ``` function inconsistentCallback(value, callback) { if (Math.random() > 0.5) { setImmediate(function () { callback(null, value); }); } else { callback(null, value); } } CallbackTree.prototype.getRoot = function (callback) { inconsistentCallback(this.data[0], callback); }; CallbackTree.prototype.getNode = function (index, callback) { inconsistentCallback(this.data[index], callback); }; ``` This becomes doubly difficult because I'm not sure in what order I should lay out my callback functions. In some iterations, I've only got it to print the root or the left most mode. In other iterations, I have gotten it to print all the nodes, but in random orders because the callbacks are all firing off a different times and it becomes a race condition. I hate throwing in the towel like this but I've spent about 10 hours on it the last few nights and it's driving me crazy. Can anybody help me with this please? [link] [comments] |
[UPDATE] A (cat) machine learning game I've been working on... Posted: 25 Feb 2019 03:52 PM PST I posted my cat machine learning game a few days ago which got a good response, thanks all! I've been working through the responses and have made a bunch of updates, it's hopefully working better now. Interested to get further feedback as it's been really useful so far. Any more suggestions/questions welcome! The link for anyone that wants to try it out is incredicat.com [link] [comments] |
SenseTime Trains ImageNet/AlexNet In Record 1.5 minutes Posted: 25 Feb 2019 08:27 AM PST |
What is a good introductory book on Information and Coding Theory for self-study ? Posted: 25 Feb 2019 06:52 AM PST I have seen the "A Mathematical Theory of Communication" [1948] paper by C.E. Shannon : http://math.harvard.edu/~ctm/home/text/others/shannon/entropy/entropy.pdf Is there a recent book that explains the entirety of the subject in such manner with examples. I'm asking this as both a Electronics and Computer Science Student. [link] [comments] |
You are subscribed to email updates from Computer Science: Theory and Application. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google, 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment