• Breaking News

    Tuesday, February 20, 2018

    How Timers Work: Explanation of Hashed Hierarchical Timing Wheels Computer Science

    How Timers Work: Explanation of Hashed Hierarchical Timing Wheels Computer Science


    How Timers Work: Explanation of Hashed Hierarchical Timing Wheels

    Posted: 19 Feb 2018 06:44 PM PST

    At least 2 ways to do backtracking? How does this specific approach of backtracking really work?

    Posted: 19 Feb 2018 08:54 PM PST

    So i'm working on solving a combinational problem (find the powerset) using recursive backtracking and noticed that there is a template to do backtracking problems.

    problem statement: Given a set of distinct integers, nums, return all possible subsets (the power set).

    For a given set of N distinct integers there are 2N combinations. So one can compute it using the following algorithm where 'cur' stores the partial combination, and 'allSubsets' is called itself 2 times within its body: 1 without the i'th element added to 'cur', and the 2nd call after the i'th element added to 'cur' (after cur.emplace_back and before cur.pop_back)

    approach-1:

    class Solution { public: vector<vector<int>> subsets(vector<int>& nums) { vector < vector<int>> res; vector <int> cur; allSubsets(nums, cur, 0, res); return res; } void allSubsets(vector<int>& v, vector<int>& cur, int idx, vector<vector<int>>& res) { if (idx == v.size()) { res.emplace_back(cur); return; } allSubsets(v, cur, idx+1, res); cur.emplace_back(v[idx]); allSubsets(v, cur, idx+1, res); cur.pop_back(); } }; 

    This approach above of recursive backtracking is understandable due to the reasoning that for every element we are considering two paths-- 1 with elements included and the 2nd with element excluded.

    But I recently saw this following backtracking approach to do the same (generate all subsets), which doesn't make sense to me. It doesn't seem similar to above as genSets is being called a variable # of times within its body than exact 2 times in the previous approach.

    approach-2:

    class Solution { public: vector<vector<int>> subsets(vector<int>& nums) { sort(nums.begin(), nums.end()); vector<vector<int>> subs; vector<int> sub; genSubsets(nums, 0, sub, subs); return subs; } void genSubsets(vector<int>& nums, int start, vector<int>& sub, vector<vector<int>>& subs) { subs.push_back(sub); for (int i = start; i < nums.size(); i++) { sub.push_back(nums[i]); genSubsets(nums, i + 1, sub, subs); sub.pop_back(); } } }; 

    So how is it doing the same work, can someone explain? In 'genSubsets' where are subsets that exclude the current index being formed?

    If nums was {1, 2, 3, 4}, where would the subset {1, 2, 3} get constructed as we don't call genSubsets are pop_back or before sub.push_back? I've spent hours trying to understand this second approach with no luck and confused how it works and is similar to the approach-1 above as this one seems to make NN calls (more than 2N)?

    submitted by /u/eda2topnamejob
    [link] [comments]

    Is the language L*_u,v_* = {<M> | u ∈ L(M) and v ∉ L(M)} semi-decidable?

    Posted: 19 Feb 2018 05:12 AM PST

    I'm currently preparing for an exam and I stumbled upon this language:

    Lu,v = {<M> | u ∈ L(M) and v ∉ L(M)} for any u,v ∈ Σ* as well as u ≠ v. 

    and I'd like to know if it is semi-decidable or not.

    One could probably argue with Rice's theorem that it is undecidable, but I'd also like to proof that is neither semi-decidable nor co-semi-decidable.

    So far my approach has been to reduce it to the Halting problem with the following argumentation:

    Assume Lu,v is decidable and L(u,v) is the machine that decides it. Then using the following construction, it would be possible to decide the halting problem for any input w:

    def R(<M>, w) u = w v = arbitrary L(u,v) L(v,u) accept 

    If <M> does not halt on w, either L(u,v) or L(v,u) would loop. Otherwise it halts and therefore R(<M>, w) accepts.

    Therefore H ≤ L and because the halting problem is undecidable (and not co-semi-decidable) L is undecidable and not co-semi-decidable.

    Now my approach for showing that it is also not semi-decidable is using the Complement of Lu,v and reversing the arguments, then reducing that to Halting Problem as well.

    Is this a valid proof?

    Any help would be highly appreciated

    Also I hope this does not invalidate the "introductory material" rule, but I just couldn't find a formal and correct solution for this problem.

    Thanks!

    submitted by /u/Gravetow
    [link] [comments]

    Where is the best place to read about recursion?

    Posted: 19 Feb 2018 12:28 PM PST

    I've just been introduced to the concept of recursion and methods calling themselves but I'm having trouble wrapping my head around the concept, especially when applying it to problems as I feel like I just get lucky when my code does work :/

    Are there any books or videos that teaches this concept intuitively or just really well?

    submitted by /u/butterpeanut19
    [link] [comments]

    CompSci questions from a student pursuing a degree

    Posted: 19 Feb 2018 10:50 PM PST

    So as my title states, I have just a few questions about this line of work.

    1) I'm just learning to write code using Java, it's my understanding that Java is used across a majority of apps, computers etc like Windows based tech (rather anything that isn't an Apple product) What are some other coding languages that I should look into to further my studies be it during my free time, or potential classes?

    2)Granted, I put in the work, would I be able to find a job after college?

    3)Do any, if at all, of the tech companies out there do internships, say...during summer time?

    4)For those that have a degree, how far did you go? Bachelor's and work up the chain? Masters? PhDs?

    5)For those with a career related to CompSci, what do you do?

    6) Do you enjoy what you do?

    7)Advice for a 19 year old college freshman trying to pursue this line of work?

    submitted by /u/TastyCookie12
    [link] [comments]

    Do you need to know algorithm design and analysis to study machine learning?

    Posted: 19 Feb 2018 06:50 PM PST

    Do I need to know algorithmic design and analysis( proving algorithm correctness, the algorithmic design domains, efficiency analysis, etc.) in order to study machine learning, that is would I be missing anything in the machine learning experience without such prior knowledge of algorithms.

    If not, would you recommend a first year student who is equally interested in both, invest his free time in algorithms or machine learning (One note to take into consideration is that my program has weaker AI courses relative to the algorithms courses)

    Any input would be appreciated.

    submitted by /u/M000000000
    [link] [comments]

    No comments:

    Post a Comment