Tuesday, August 6, 2013

Programming contests importance for a B.Tech student

·         What is a programming Contest?
·         What are the requirements for being a successful programmer?
·         What students have been accustomed to learn so far?
·         What benefits them?
·         Why Programming?
·         Why should students attend Programming Contests?
·         What students have learnt so far?
·         What actually is happening when a student joins in his B.Tech course?
·         How the impacts of 2nd and 3rd year studies are shown in 4th year?
·         What actually is happening during Campus Recruitment?
·         How easy it is for a student to get through the campus recruitment?
·         Where students are lagging?
·         What kinds of activities should be organized to get the job done?
·         What kind of support does a student require to excel his/her skills from the Departments as well as from the management?
·         What level of commitment should be shown by a student as well by the instructor?
Now I am here to give the answers for the above questions with substantial evidences which might give you clear insight on what a student is doing in the college at present and what he/she can do to see himself/herself at acme at the time of completing his/her under graduation.
1)      What is a Programming Contest?


The link mentioned above gives the list of programming contests a student can freely participate to compete with the students (masters) round the globe. It is the arena where an aspiring student can enrich his logical as well as mathematical aptitude, when implemented, can get the desired outcome by writing a computer program.

2)      What are the requirements for being a successful programmer?

In order to be a successful programmer, a student should necessarily possess problem solving skills. He should come up with the solution in different possible ways and selecting the optimal solution in the minimum time span makes the person a successful programmer.

3)      What students have been accustomed to learn so far?

Students, now a day have been accustomed to practice the conventional way of learning the things. They have been shown the most common way of sitting and working in labs rather than giving pragmatic approach to face the ever challenging world.

4)      What benefits them?

Facing the ever growing competition when they are at the freshmen stage and sophomore stage gives them a huge benefit.

5)      Why Programming?

As already discussed the art of programming can make our lives so simpler and more accurate as everything can be automated using the computer programs and it is possible only when people start developing the ideology in a more optimal and efficient approach.

6)      Why should students attend Programming Contests?

Attending the programming contests have very huge impact on the growth of a student as it gives them a platform to meet different minds and understand where they are standing out in the world outside.

7)      What have majority of the students learnt so far?

Majority of the students have learnt the approach of studying the curriculum and sticking to the basic programming paradigms. They are not exposed to the expertise in the particular area which plays a pivotal role in bringing some motivation in them.

8)      What actually is happening when a student joins in his B.Tech graduation course?

When a student is joined in the B.Tech course, he does not have the maturity of thinking what benefits him the most. And, I personally feel that it is the responsibility of the senior students to elucidate what are the activities that a fresher should do during the extra hours and leisure hours.

9)      How the impacts of 2nd and 3rd year studies get reflected during 4th year?

The effort that is being put by a fresher is getting through mixed subject knowledge when he is at the fresher stage. But once he steps into the second year he faces the core subjects where he can get maximum resources to utilize. Unfortunately, students are not utilizing the resources that are being provided which are actually making them to lag during their campus recruitment.

10)   What actually is happening during Campus Recruitment?

During the Campus recruitments, students are feeling that they are not having enough knowledge on their core subjects. Even they are unable to retain the basics of those subjects when a question is posed by an interviewer during the interview.  And this is the main reason why students feel they are lacking in the skills that is required for campus placements.

11)   How easy it is for a student to get through the campus recruitment?

It is very easy for a student to get through the campus recruitment if he can possess the art of implementing his knowledge on the real world entities. And, it is all possible through these types of exposure to the Programming contests and Expert lectures with practical examples.

12)    Where Students are lagging?

Students are lagging in reality. They are not doing the work whole heartedly. The responsibility should be taken by the counselors to get the best out of them providing the resources and motivating them reducing the communication gap between the faculty and student.

13)   What kinds of activities should be organized to get the job done?

It is very important to form a student committee guided by the faculty. Regular commencements of the student teams should be there to get the information up to date. Problems should be designed by different teams every time and there should be discussions on the problem setting as well as solutions to those problems. Every team should be made to communicate with other team during the discussion in English which reduces the communication barriers which students are thinking that skill as an evil for their campus recruitment.

14)   What kind of support does a student require to excel his/her skills from the Departments as well as from the management?

Faculty as well as the management should interact with the students and proper feedback should be collected from them in order to provide the enough required back up for the students.


15)   What level of commitment should be shown by a student as well by the instructor?


Student as well as the instructor should have the same level of commitment in updating their knowledge and mutual efforts can give rise to a grand new culture of pragmatic approaches combined with the art of getting the gist of knowledge in related subjects at hand.

Saturday, July 20, 2013

STL types


STL can be categorized into the following groupings:
  • Container classes:
    • Sequences:
    • Associative Containers:
      • set (duplicate data not allowed in set), multiset (duplication allowed): Collection of ordered data in a balanced binary tree structure. Fast search.
      • map (unique keys), multimap (duplicate keys allowed): Associative key-value pair held in balanced binary tree structure.
    • Container adapters:
      • stack LIFO
      • queue FIFO
      • priority_queue returns element with highest priority.
    • String:
      • string: Character strings and manipulation
      • rope: String storage and manipulation
    • bitset: Contains a more intuitive method of storing and manipulating bits.
  • Operations/Utilities:
    • iterator: (examples in this tutorial) STL class to represent position in an STL container. An iterator is declared to be associated with a single container class type.
    • algorithm: Routines to find, count, sort, search, ... elements in container classes
    • auto_ptr: Class to manage memory pointers and avoid memory leaks.

Sample code for C++ STL and expmle showing segmentation faults


#include <iostream>
02#include <vector>
03#include <string>
04 
05using namespace std;
06 
07main()
08{
09   vector<string> SS;
10 
11   SS.push_back("The number is 10");
12   SS.push_back("The number is 20");
13   SS.push_back("The number is 30");
14 
15   cout << "Loop by index:" << endl;
16 
17   int ii;
18   for(ii=0; ii < SS.size(); ii++)
19   {
20      cout << SS[ii] << endl;
21   }
22 
23   cout << endl << "Constant Iterator:" << endl;
24 
25   vector<string>::const_iterator cii;
26   for(cii=SS.begin(); cii!=SS.end(); cii++)
27   {
28      cout << *cii << endl;
29   }
30 
31   cout << endl << "Reverse Iterator:" << endl;
32 
33   vector<string>::reverse_iterator rii;
34   for(rii=SS.rbegin(); rii!=SS.rend(); ++rii)
35   {
36      cout << *rii << endl;
37   }
38 
39   cout << endl << "Sample Output:" << endl;
40 
41   cout << SS.size() << endl;
42   cout << SS[2] << endl;
43 
44   swap(SS[0], SS[2]);
45   cout << SS[2] << endl;
46}
Compile: g++ exampleVector.cpp
Run: ./a.out
Output:
Loop by index:
The number is 10
The number is 20
The number is 30

Constant Iterator:
The number is 10
The number is 20
The number is 30

Reverse Iterator:
The number is 30
The number is 20
The number is 10

Sample Output:
3
The number is 30
The number is 10
        

Two / Three / Multi Dimensioned arrays using vector:
A two dimensional array is a vector of vectors. The vector contructor can initialize the length of the array and set the initial value.
Example of a vector of vectors to represent a two dimensional array:
01#include <iostream>
02#include <vector>
03 
04using namespace std;
05 
06main()
07{
08   // Declare size of two dimensional array and initialize.
09   vector< vector<int> > vI2Matrix(3, vector<int>(2,0));   
10 
11   vI2Matrix[0][0] = 0;
12   vI2Matrix[0][1] = 1;
13   vI2Matrix[1][0] = 10;
14   vI2Matrix[1][1] = 11;
15   vI2Matrix[2][0] = 20;
16   vI2Matrix[2][1] = 21;
17 
18   cout << "Loop by index:" << endl;
19 
20   int ii, jj;
21   for(ii=0; ii < 3; ii++)
22   {
23      for(jj=0; jj < 2; jj++)
24      {
25         cout << vI2Matrix[ii][jj] << endl;
26      }
27   }
28}
Compile: g++ exampleVector2.cpp
Run: ./a.out
Loop by index:
0
1
10
11
20
21

A three dimensional vector would be declared as:
01#include <iostream>
02#include <vector>
03 
04using namespace std;
05 
06main()
07{
08                               // Vector length of 3 initialized to 0
09   vector<int> vI1Matrix(3,0);
10 
11                               // Vector length of 4 initialized to hold another
12                               // vector vI1Matrix which has been initialized to 0
13   vector< vector<int> > vI2Matrix(4, vI1Matrix);
14 
15                               // Vector of length 5 containing two dimensional vectors
16   vector< vector< vector<int> > > vI3Matrix(5, vI2Matrix);
17 
18   ...
or declare all in one statement:
01#include <iostream>
02#include <vector>
03 
04using namespace std;
05 
06main()
07{
08   vector< vector< vector<int> > > vI3Matrix(2, vector< vector<int> > (3, vector<int>(4,0)) );
09 
10   for(int kk=0; kk<4; kk++)
11   {
12      for(int jj=0; jj<3; jj++)
13      {
14         for(int ii=0; ii<2; ii++)
15         {
16            cout << vI3Matrix[ii][jj][kk] << endl;
17         }
18      }
19   }
20}

Using an iterator:
Example of iterators used with a two dimensional vector.
01#include <iostream>
02#include <vector>
03 
04using namespace std;
05 
06main()
07{
08   vector< vector<int> > vI2Matrix;    // Declare two dimensional array
09   vector<int> A, B;
10   vector< vector<int> >::iterator iter_ii;
11   vector<int>::iterator                 iter_jj;
12 
13   A.push_back(10);
14   A.push_back(20);
15   A.push_back(30);
16   B.push_back(100);
17   B.push_back(200);
18   B.push_back(300);
19 
20   vI2Matrix.push_back(A);
21   vI2Matrix.push_back(B);
22 
23   cout << endl << "Using Iterator:" << endl;
24 
25   for(iter_ii=vI2Matrix.begin(); iter_ii!=vI2Matrix.end(); iter_ii++)
26   {
27      for(iter_jj=(*iter_ii).begin(); iter_jj!=(*iter_ii).end(); iter_jj++)
28      {
29         cout << *iter_jj << endl;
30      }
31   }
32}
Compile: g++ exampleVector2.cpp
Run: ./a.out
Using Iterator:
10
20
30
100
200
300
         
[Potential Pitfall]: Note that "end()" points to a position after the last element and thus can NOT be used to point to the last element.
iter_jj = SS.end();
cout << *iter_jj << endl;
This will result in a "Segmentation fault" error.