Recursion (The Good, the Bad and the not so Ugly)

Recursion is a topic most beginner programmers fear and when you get the hang of it, it works like magic (Congrats! Not a noob anymore). When someone introduces recursion, they say it’s basically a function which calls back itself, and your brain goes like WHAAAAAT??

So here’s this GIF which not only gives you a complete mindfuck but also a visual description of what recursion is. Too scary huh? Well, not really. Once, you get an idea of how recursion works and  which base case to work with, it runs smooth as ice. Sometimes, you won’t even be able to fathom how your code worked when it did.
Well, the mantra for recursion is ” Let recursion do the work for you”.

THE GOOD

1. For all those people who want to make their code look pretty as a picture, recursion is the best way to do that. Recursion makes a code more compact, readable and so very elegant.
2. If you can master recursion, it can turn out to be your best friend. Solutions using recursion are easier to strike and code. It also avoids redundancy of code, and your codes are easier to read and maintain.
stackbuddies

3. Three magic words: tail call optimization: Some functional languages implement this wizardry. So basically, what happens is, if a function’s return expression is a result of a function call, the stack frame is reused instead of pushing a new stack frame in the call stack. Sadly, only a few imperative languages have this wizardry.

 

The secret magic of tail call

THE BAD

A lot of programmers avoid using recursion and believe that it is less efficient than it’s iterative counterparts.

 1. Recursion can lead to the perils of stack overflow. To understand better, let’s look at the steps for functions call:-
  •  space is carved out on the stack for function arguments and variables.
  •  arguments are copied into this new space
  • control jumps to the function
  • function code runs
  • function results are copied into the new value
  • stack rewounds to its previous position
  • control jumps back to the caller
Mostly, all of these steps consume more time than their iterative counterparts. Therefore, recursive methods are relatively less efficient in those cases.
recursionagain
2. More importantly, when most programs start, they allocate a single chunk of memory to the stack, if that memory is used, the entire program crashes due to stack overflow.
3. Each function call eats up a lot of space. That amount of space isn’t recovered until the function returns. Iterative methods do not suffer from such problems.
r_219071_tbWYT

5 reasons to be at CodeKaze

Code-Kaze is back with its third edition and this time you wouldn’t want to miss it for anything in the world! It’s triple the fun, challenge and prizes. Code-Kaze is an online coding challenge with a twist and you need to attend it to experience the awesomeness. Why should you attend it, you ask? Ninjas ahoy! Here are the top 5 reasons to participate in Code-Kaze.
Reason_1-01-01
  • Showcase your deadly Ninja skills: You have been sharpening your swords, it’s time that you strike. Put in your coding moves and stand out of the crowd. Competing in online challenges not only certifies your zest for coding but also aids in your portfolio building. Want a final revision before getting to the battle ground? Check out our ‘Challenge of the day’ here.
  • Race against time: Everybody runs the race but only the fastest wins. Code Kaze is not just about solving the problem statement but solving it faster than anybody else. Your brain and those code hands need to move at an equal pace. The fastest fingers will be the first!
  • Hone your skills: Attending the challenge can hone your important industry-specific job skills. Your problem-solving abilities and brain teasing levels will be skyrocketing. Every industry looks for a candidate who has sharp ideation and coding skills.The more you compete, better you become.
  • A truckload of Prizes: A Ninja’s dedication is worthy of a reward and we’ve got amazing rewards stacked up for you. Cash prizes worth INR 10,000 is what the winners take away. Oh yes! And besides the cash, there is a truckload of goodies as giveaways.
  • A rewarding experience: Code Kaze is an extremely rewarding experience! Let’s face it -creating something from scratch isn’t that simple. And there is no greater feeling of accomplishment than coding your heart out to see your solution come to life in just a matter of few hours. Not to mention, there are prizes galore and Ninja lessons to take away.
coding_ninjas_5
If it does not challenge you, it does not change you. Get rolling ninjas, register now!

A Complete Guide to Competitive Coding

What is competitive coding?
First things first, you must know what competitive coding means. It’s like a mind sport over the internet or LAN. A problem statement is thrown to the coders with provided specifications and guidelines and ‘Atta Boy!’ people get to work. Companies like google and facebook encourage these events for their employees on a regular basis. Competitive coding is a fad among the collegiate and graduates. And websites like CodeZenSPOJ, Codechef, and others are taking it to a whole new level.
What kind of problems does it have?
 
It consists of pragmatic usage of classical algorithms and data structures. Your creativity and problem-solving skills are what come into play next. A basic knowledge around things like Complexity Analysis and Discrete Mathematics is required to become a good problem solver.
The problems rotate majorly around:
  • Dynamic Programming (Knapsack, 8-queens, Traveling Salesman)
  • Backtracking (8-queens, Sudoku)
  • Greedy Algorithms (Matching Pursuit, Egyptian Fractions)
  • Sorting (Binary Search, Merge-sort)
  • Search/Path-finding (Breadth-First Search, Depth-First Search, Dijkstra)
  • Network Flow Problems (Minimum Cut, Max Flow)
  • Combinatorial  (Permutations, Calendrical Calculations)
  • Geometrical (Convex Hull, Minkowski Sum)

How can I get good at it?

They say that you need to strengthen your base notes to hit that high octave. Don’t you? So let’s get you started with some basic preparation here.
  • Get basic coding and hands-on knowledge on C, C++ or Java. These are the basic languages allowed in any programming competition. Check out our website for courses that can make you a coding rockstar!
  • Get hitched with an online judge. He will be the critic and guide on your road to code. CodeZen, HackerearthSPOJ, Codechef, Top coders are the ones recommended.
  • Read, practice, implement. There is an ocean of resources on the internet, all available for free. All you need to do is sit and code!
  • Practice as much as you can on popular topics like Graphs, dynamic programming, number theory, arrays etc.
  • When you’ve practiced enough, all that’s left is to participate. Participate in competitions as much as you can. With our Coding Ninja challenges, you can constantly workout and develop those coding biceps.
  • Read and react. Review the codes by top coders, understand their approach and try to outdo it. This is a very important aspect as you get a cheat sheet to what top coders do and how you can better your methodologies.
  • DON’T GIVE UP AND DON’T GIVE IN! I say this, because there is a difference between the two. You should be persistent and sincere no doubts about that but do not get stuck. The moment you feel that’s happening, take a break, get a beer/green tea 😉 or listen to your favourite song. Get back to work and if it still doesn’t work, move on!
Don’t wait up, pick up your Ninja code swords and cut through the world of competitive coding today!

Attempting Google Summer Of Code

The easiest way to get started with GSoC is to just get started! It is not rocket science. It is not even difficult. The process in itself not at all hard or demanding but it is made elusive by the amount of talent and hard work it sees from the students who participate. The aim of the post is to not let any misunderstanding about the the process, or the assumption that the projects to be done, are difficult, hold back a student from trying.

The projects in GSoC are usually simple, well majority of them are. Complex projects do exist but plenty of projects can be picked up by dedicated beginners and be completed successfully. Even if you feel you are not qualified enough,give it a shot as soon as possible, don’t wait for next year. Being rejected (if it happens) in the first attempt will teach you a lot more than the year of waiting will.

So let us start and answer the first question, where to start?

Disclaimer : I will be using the project I mentored in GSoC 2016, PowerUp by Systers to illustrate the process. Also the guide will apply more on development/coding projects under GSoC as I am not well versed to the process of applying for research/scientific projects that exist.

1) Pick an organization (or a project)

0-L7EBPfvPEq4yucK8

To be (preferably) done before the organizations are officially announced

This is sometimes the easiest part, sometimes the hardest.

First things first, what are these organizations? The organizations participating in Gsoc are open source organizations that put up their entire code-base for the developer community to share and build upon. Open Source means just that, open for all. This is not the same as free software but that is beyond the topic of today.

Your task is to go ahead and browse the 150+ organizations list of GSoC(previous edition) and pick one that catches your eye. Or you can browse projects according to your preferred technology stack and pick one from there. For example, say you were to search Android, you would come up with a bucket loads of projects and say you picked PowerUp.

While picking an organisation early you run the slight risk of that organisation not participating or qualifying for the next edition so place your bets safely (preferably an organisation that has had at least 3-4 projects in the previous edition).

— Some Technical Jargon —

Before we move to the next step, you have to know what contributing to a project technically means. It can involve various aspects like : a) Creating an Issue. b) Sending a Pull Request 3) Documentation. 4) So on….

Don’t feel dizzy just yet, explanations are on the way.

For beginners to version control, you would need to learn the ins and outs of Git and Github and how to work on collaborative projects. Refer:https://github.com/chhavip/Git-Guide to get started off the right foot.

A) Creating an Issue.

For this you need to go through the project (run it on device, deploy it on server) and find bugs in it. Head over to the issues section of your project, make sure it doesn’t already exist and open it up! If it gets approved by the project maintainers, you might get to work on it too. Usually it is advised to open an issue first and then send its solution rather than just sending the fix.

B) Sending a Pull Request

Remember the solution to bugs we talked about? This is it. How do you fix something or add a new feature to the project? Pull Request is the way to go. You work on your copy of the project and send a request for specific changes to be merged with the original project. If it gets merged? Go out and celebrate!

C) Documentation

An easier approach to contribution that is often overlooked. Coders are lazy to document but it matters! Help complete the introduction, write the wiki or a guide about the project and believe me the mentors will be more than happy.

— Its Over Finally —

2) Start working on your picked project

Blog_project-01

How much work you do is left up to your own dedication

This is the salient part of the whole process. Here your main aim is to get to know about the project, the organisation and the kind of work they do. Now different organizations go about differently. For some you can simply start out by creating issues and sending PRs on their project, for others you need to introduce yourself first on the mailing list, ask for the required work to be done and then start. The main point being that this is the point where you can showcase your coding skills and make the mentors believe that you are good enough to be selected.

A sample procedure for contributing to an organisation: Suppose you picked PowerUp as your project of choice, then head over to the issues list : https://github.com/systers/powerup-android/issues and sort through all the available issues. Sometimes labels like ‘beginner’ and ‘gsoc’ are put up to help first time contributors make their mark. Understand the project and see if you can fix this issue. If you can, the voilà! But not just yet. The best way to go about sending code to an organization is to first comment on an issue and express your willingness to fix it, wait for approval from the mentor and then you can go ahead and submit that PR . This way the mentors can interact with you and let you know any intricacies hidden with solving the issue or if it has already been assigned to someone else. Again, this may not be the procedure with every organization but serves for widely approved conduct.

3) See the Ideas List

Blog_idea-01Organizations start releasing their ideas list at the same time they start applying to be a part of GSoC which happens around in February. Go through this list. It can have the project you have been working on or completely new projects and sometimes you can even suggest your own ideas to the organization. From the ideas list, pick the projects that seem most suitable to you and start envisioning how you would go about completing the same. This forms the base of the project timeline and the time you spent upon several ideas will showcase your understanding of the same in the proposal. So selecting a final project for which you will be submitting a proposal is a crucial step, give it time.

4) Write a Proposal

Blog_PROPOSAL-01

Now comes the part that carries a good amount of weight age in your selection. This is almost the last step in your entire journey. Now what is a proposal? After the organizations are officially released on the GSoC site, now is your time to start going through the ideas list of each of your previously shortlisted organizations and see what projects suit you best. You may submit a proposal for a completely new project and not the one you contributed to as contributions to the organization are considered on an overall basis. A proposal basically contains all the information about yourself, your academic status and information about how long have you been working in open source. The important parts of the proposal are where you are supposed to answer queries related to your vision and plans for the selected project and provide a concrete timeline according to which you will be working throughout the summer. This is to judge your understanding of the project and see if you can correctly estimate and incorporate the time it would take to complete the project.

In many ways your proposal is the only medium for the organization to get to know you so keep in mind the following points when composing one:

  • Submit as early as possible and utilise mentor feedback.
  • Do not deviate too much from the basic requirements, Quality matters more than Quantity.
  • It’s the only medium for organisation to know you, provide adequate information.
  • Tabulate the final timeline in a clean and efficient manner.
  • Make the timeline as realistic as possible, include buffer period for code cleanup, bug fixing and documentation (an important but often overlooked part).

5) Get Involved with the Community

 

Blog_community-01

Now this is a somewhat vague aspect of the process and so might my advice seem to be. Problem being that there is no set pattern as to how to go about doing this as different organizations have different form of communications. But the purpose is the same irrespective of the organization – make yourself known. This does not mean that you badger the mentors or flood the mailing list! This means that you maintain healthy communication with the members, by properly introducing yourself, by properly researching on a topic to make an informed query and also by helping out fellow students who are stuck somewhere. If your organization arranges a video chat with its prospective applicants, do attend even if you don’t have any questions! You might be able to answer someone else’s query and that will go a long way in uplifting your image.

Coming to the end of this very long post, my final piece of advice (request) would be that you apply, doesn’t matter if you are an absolute beginner or if there is only one month left on the clock. Even if your chances are less than zero, you are guaranteed not to walk away empty handed by investing a few weeks in this task.

I’ll be happy to answer any specific queries. Feel free to post your queries in the comments section below 🙂

BLOG_GSOOC