TCS Prime Advanced Coding Round Syllabus & Practice Questions
The TCS Prime Advanced Coding Round is a crucial component of their recruitment process, designed to evaluate a candidate's programming skills and problem-solving abilities through code.
Scroll down for a detailed overview and breakdown of the syllabus to guide your preparation.
TCS Prime Advanced Coding Round - Quick Overview
Here's an overview of the TCS Prime Advanced Coding Round assessment:
Section Details | Information |
---|---|
Total No. of Questions |
3 |
Time Duration |
90 mins |
Type of Test |
Non- Adaptive |
Negative Marking |
No |
Estimated Cut-off For Prime and Prime |
1 out of 3 - (Ninja roles) |
TCS Prime Advanced Coding Round - Syllabus & Topics
Here's a snapshot of the TCS Prime Advanced Coding Round syllabus:
Topic | Difficulty | Importance | No. of Questions | No. of Minutes |
---|---|---|---|---|
C |
High |
High |
3 questions (shared) |
90 minutes (shared) |
C# |
High |
High |
||
C++ |
High |
High |
||
JAVA |
High |
High |
||
Python |
High |
High |
Practice TCS Prime Advanced Coding Round Questions
1.
1. Problem Statement: Jaya invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of Programmer (the 256th day of the year) during a year in the inclusive range from 1700 to 2700. From 1700 to 1917 , Russia’s official calendar was the Julian Calendar; since 1919 they have used the Gregorian calendar system. The transition from the Julian to Gregorian calendar system occurred in 1918 , when the next day after 31 January was February 14 . This means that in 1918, February 14 was the 32nd day of the year in Russia. In both calendar systems, February is the only month with a variable amount of days; it has 29 days during a leap year, and 28 days during all other years. In the Julian calendar, leap years are divisible by 4 ; in the Gregorian calendar, leap years are either of the following:
- Divisible by 400
- Divisible by 4 and not divisible by 100
Given a year, y, find the date of the 256th day of that year according to the official Russian calendar during that year. Then print it in the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.
For example, the given year is 1984.1984 is divisible by 4, so it is a leap year. The 256 day of a leap year after 1918 is September 12, so the answer is 12.9.1984.
Function Description
- Complete the programmerday function in the editor below. It should return a string representing the date of the 256th day of the year given.
- programmerday has the following parameter(s):
year: an integer
Input Format
- A single integer denoting year y.
Output Format
- Print the full date of programmerday during year y in the format dd.mm.yyyy, where dd is the two-digit day, mm is the two-digit month, and yyyy is y.
Sample Input
2017
Sample Output
13.09.2017
Code in Python:
def dayofProgrammer(year):
if year >= 1700 and year <= 1917:
if year % 4 == 0:
return "12.09." + str(year)
else:
return "13.09." + str(year)
elif year == 1918:
return "26.09." + str(year)
else:
a = not (year % 100)
if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
return "12.09." + str(year)
else:
return "13.09." + str(year)
year = int(input().strip())
res = dayofProgrammer(year)
print(res)
2.
2. Problem Statement:- Hobo’s Drawing teacher asks his class to open their books to a page number. Hobo can either start turning pages from the front of the book or from the back of the book. He always turns pages one at a time. When she opens the book, page 1 is always on the right side: When he flips page 1, he sees pages 2 and 3. Each page except the last page will always be printed on both sides. The last page may only be printed on the front, given the length of the book. If the book is n pages long, and he wants to turn to page p, what is the minimum number of pages he will turn? He can start at the beginning or the end of the book. Given n and p, find and print the minimum number of pages Hobo must turn in order to arrive at page p
Function Description
Complete the countpage function in the editor below. It should return the minimum number of pages Hobo must turn.
countpage has the following parameter(s):
- n: the number of pages in the book
- p: the page number to turn to
Input Format
- The first line contains an integer n, the number of pages in the book.
- The second line contains an integer, p, the page that Hobo’s teacher wants her to turn to.
Output Format
- Print an integer denoting the minimum number of pages Hobo must turn to get to page p.
Sample Input
6
2
Sample Output
1
Code in Python:
main.py
def countPage(n, p):
return min(p//2, n//2 - p//2)
n = int(input())
p = int(input())
result = countPage(n, p)
print(result)
3.
3. Write a program to perform Binary Search on an array.
The binary search algorithm is used to find an element in a sorted array. It is an optimized searching algorithm as the linear search scans all the elements of the array and the searching time for the linear search thus becomes O(N). However, the searching time of Binary Search is O(log2N). This is because in an average case, only log2N elements of an array are compared. We start by checking the middle element of the array. If the middle element of the array is our answer, we have found the element. If the number that we are searching for is greater than the middle element, it will be on the right half of the array as the array is sorted. So apply binary search on the right half. If the number that we are searching for is smaller than the middle element of the array, we will apply the binary search on the left half of the array. Following is the C++ program for binary search.
C++ Program for Binary Search
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int binarysearch(int arr[], int n, int target) {
int lo = 0;
int hi = n-1;
while(lo <= hi) {
int mid = lo + (hi-lo)/2;
if(arr[mid] == target) return mid;
else if(arr[mid] < target) lo = mid + 1;
else hi = mid - 1;
}
return -1;
}
int main() {
int arr[] = {10,12,25,36,42,58,97};
if(binarysearch(arr, 7, 12) == -1) {
cout << "Element was not found";
} else {
cout << "Element was found at index " << binarysearch(arr, 7, 12);
}
}
Output:
Element was found at index 1
1 of 1
Frequently Asked QuestionsFAQ
How can I prepare for the TCS Prime advanced coding test?
Practice coding problems in languages like C, C#, C++, JAVA, and Python, and familiarize yourself with different types of algorithms and data structures.
You should also take timed coding challenges to simulate exam conditions and strengthen your practice.
What are the topics covered in the advanced coding test?
The topics covered in the Advanced Coding Round Test are:
- C
- C#
- C++
- JAVA
- Python
Is it mandatory to attempt the advanced coding section?
Yes, it is mandatory to attempt the advanced coding section in the TCS Prime Advanced section.
How many questions are there in the advanced coding test?
There are 3 questions in the Advanced Coding Round Test.
What is the difficulty level of the advanced coding test questions?
The difficulty level is high for the Advanced Coding Round Test.
Is there a negative marking for incorrect answers in the advanced coding test?
No, there is no negative marking for the Advanced Coding Round Test.
What is the minimum passing score or cutoff mark for the advanced coding test?
The estimated Cut-off would be at least 2 for TCS Digital roles and all the 3 for TCS Prime Prime roles
How should I approach the TCS Prime advanced coding section?
You can approach the section in the following ways:
- Start with the language you are most comfortable with.
- Read the problem statements carefully to understand the requirements.
- Plan your code structure before starting to write.
- Aim for at least 70% code efficiency to qualify for the next round.
Are there any specific resources or study materials recommended for preparing for this section?
Yes, for preparing for the TCS Prime Advanced Coding Round section, you can use the placement preparation website. It offers various resources like sample papers and mock tests that are tailored to help you practice for this specific section.