About Me

header ads

Foundation Preparation for TCS Digital

Intended audience - This blog is targeted toward students pursuing engineering, and are currently in their final year (irrespective of their stream). However, if you are in one of your earlier years, this article will still help you can get early start, which in fact is a big advantage.

The first point to know to address any subject is to know the purpose and objective of the subject. In order to crack TCS code vita you should know what is the agenda of TCS? There is a drastic changes happening in technologies and as a result TCS is getting adapted to the digital transformation. To get a place in any Major software MNC's (JOB) one should work on the following topics ie., Logical, Aptitude, Reasoning and programming. On programming part we would recommend you to focus on Python ahead of C,C++ & Java because Python is a scientific language which can add advantage to you as the companies are getting into digital era. These days more number of projects from Artificial Intelligence & Machine learning are pouring in for MNC's, so as a result there is a rapid growth in demand for python developers in the software market so the recruiters are looking for early python adapters in the market because there are lot of experienced JAVA , C ,C++ developers who are not keen to switch their language of comfort zone. This makes us to feel python has a superior advantage in TCS code vita ahead of any other languages as of now.

There are Four stages in the recruitment process:

1)CodeVita
2)Interview for Ninja
3)Online Test for Digital
4)Interview for Digital

Let's take a dive into the stage 3

Online Test for Digital

1.English
2.Quantitative Aptitude
3.Lateral Thinking
4.Agility
5.Programming Logic

The first above 4 areas are common foundation for any interview. So let us discuss point number 5 which is the Programming Logic in detail

Programming Logic:

Recursion, arrays, stacks, queues, linked lists, trees, binary search trees, binary heaps, graphs.Recursion, arrays, stacks, queues, linked lists, trees, binary search trees, binary heaps, graphs.

Recursion:

Recursion is a method of solving problems that involves breaking a problem down into smaller and smaller sub problems until you get to a small enough problem that it can be solved trivially. Usually recursion involves a function calling itself. While it may not seem like much on the surface, recursion allows us to write elegant solutions to problems that may otherwise be very difficult to program.

Python Functions

A function is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.

Following is an example of recursive function to find the factorial of an integer.
Factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 5 (denoted as 5!) is 1*2*3*4*5 = 120.
def calc_factorial(x):
    """This is a recursive function
    to find the factorial of an integer"""

    if x == 1:
        return 1
    else:
        return (x * calc_factorial(x-1))


num = 5
print("The factorial of", num, "is", calc_factorial(num))
In the above example, calc_factorial() is a recursive functions as it calls itself.When we call this function with a positive integer, it will recursively call itself by decreasing the number.

Each function call multiples the number with the factorial of number 1 until the number is equal to one. This recursive call can be explained in the following steps.



Arrays:


In programming, an array is a collection of elements of the same type.Following are the important terms to understand the concept of Array.

    • Element− Each item stored in an array is called an element.

    • Index − Each location of an element in an array has a numerical index, which is used to identify the element.

An array is a variable that can store multiple values. For example, if you want to store 10 integers, you can create an array for it. int data[10];

Below is an example of an array representation


Index starts with 0.
Array length is 10 which means it can store 10 elements.

Array in Python can be created by importing array module. array(data_type, value_list) is used to create an array with data type and value list specified in its arguments.

# Python program to demonstrate 
# Creation of Array 
# importing "array" for array creations 
import array as arr 
# creating an array with integer type 
a = arr.array('i', [1, 2, 3]) 
# printing original array 
print ("The new created array is : ", end =" ") 
for i in range (0, 3): 
print (a[i], end =" ") 
print() 
# creating an array with float type 
b = arr.array('d', [2.5, 3.2, 3.3]) 
# printing original array 
print ("The new created array is : ", end =" ") 
for i in range (0, 3): 
print (b[i], end =" ") 



Stack:

Data structures are the key to organise storage in computers so that we can efficiently access and edit data. Stacks is one of the earliest data structures defined in computer science. In simple words, Stack is a linear collection of items. It is a collection of objects that supports fast last-in, first-out (LIFO) semantics for insertion and deletion. It is an array or list structure of function calls and parameters used in modern computer programming and CPU architecture. 

Stacks are simple data structures that allow us to store and retrieve data sequentially.

There are two types of operations in Stack:

    •  Push – To add data into the stack.
    •  Pop – To remove data from the stack.

In Python, we can implement python stacks by:
  • Using the built-in List data structure. Python’s built-in List data structure comes with methods to simulate both stack and queue operations.
  • Using the deque library which efficiently provides stack and queue operations in one object. 
  • Using the queue.LifoQueue Class.

we can add items to a stack using the “PUSH” operation and remove items using the “POP” operation. 

PUSH Operation:
Push - adds an element at the top of the stack Refer the below image for easy understanding.
POP Operation
Pop – removes an element from the top of the stack.























Sample stack Program




# Python program to demonstrate stack implementation 
# using list 
stack = [] 
# append() function to push 
# element in the stack 
stack.append('A') 
stack.append('B') 
stack.append('C') 
print('Initial stack') 
print(stack) 
# pop() function to pop 
# element from stack in 
# LIFO order 
print('\nElements poped from stack:') 
print(stack.pop()) 
print(stack.pop()) 
print(stack.pop()) 
print('\nStack after elements are poped:') 
print(stack) 

Post a Comment

0 Comments