DXC Automata Fix Questions and Answers

DXC Automata Fix Questions

DXC Automata Fix Questions and Answers has make some changes in its exam pattern for its 2024 drive. In this year drive for DXC there will Coding Questions in Automata Section, in which you have to solve 2 Coding question in 45 mins.

Although, the name of the section is still Automata

DXC Automata Fix Questions and Answers

DXC Automata Question Paper Analysis

Automata fixDetails
No. of Questions2
Time limit45 mins
DifficultyMedium- High

How to solve DXC Automata Fix Questions and Answers

In Automata fix questions you have to figure out the mistakes that are there in the code, and make it execute properly, for doing so, some basic steps that you can follow our -:

  1. Look for syntactical mistakes, like missing semi-colons, missing brackets, error in function names.
  2. Second thing after checking this is mistake in loops and  conditions, which may lead to infinite looping or wrong outputs.
  3. Check for missing return statements.
  4. If, there are no such errors in the code, then you have to check that what the question is asked for.For eg – there may be a question for arranging the data in ascending order, and it might be getting arranges in descending order.

What types of questions are asked in DXC Automata Fix Sections

DXC has introduced this new section in its 2024 drive, so as to test logical thinking and problem solving capabilities of students. Although DXC has added this section this year only, there are many other companies who asks these types of questions in their recruitment drives. Some common questions that are asked in Automata Fix sections are -:

  1. Arranging the data of an array in some specific order.
  2. Comparing two given strings
  3. Finding the second largest/smallest element of the array.
  4. Finding some specific element in the given data.
  5. Fixing the code for some popular searching or sorting like linear search, binary search, merge sort, radix sort, etc.

We are not saying that these are the only asked questions, but yeah most of the questions come from these concepts only, but the questions are delivered in such a way, that students may find it a bit difficult to fix those codes. Below are some practice questions which you can practice, to get an idea about DXC Automata Fix Section.

 

Sample Questions for DXC Automata Fix Questions and Answer

Question : 1

Check for syntax error/ logical error and correct the error to get the desired output.

The function sortString  modifies the input list by sorting its elements depending upon the length of the array, i.e; if the length of the array is even, then the elements are arranged in the ascending order, and if the length of the array is odd, then the elements are arranged in the descending order 

The function sortString accepts two arguments – len representing the length of the string, and arr a list of characters, representing the input list respectively.

The function sortString compiles successfully but fails to get the desired results for some test cases due to logical errors. Your task is to fix the code, so that it passess all the test cases

Use Coupon Code “CT10” and get flat 10% OFF on PrepInsta Prime, additionally get:

  • 1 months extra on 3 & 6 months plan
  • 2 months extra on 12 & 24 months plans
  • 3 months extra on 36 & 48 months plan

Question : 2

Check for syntax error/ logical error and correct the error to get the desired output.

The function maxReplace print space separated integers representing the input list after replacing all the elements of the input list with the sum of all the element of the input list.

The function maxReplace accepts two arguments – size  an integer representing the size of the input list and inputList, a list of integers representing the input list respectively.

The function maxReplace compiles unsuccessfully due to compilation errors. Your task is to fix the code so that it passes all the test cases.

Question : 3

Check for syntax error/ logical error and correct the error to get the desired output.

The function replaceElements is modifying the input list in such a way – if the sum of all the elements of the input list is odd, then all the elements of the input list are supposed to be replaced by 1s, and in case if the sum of all the elements of the input list  is even, then the elements should be replaced by 0s.

For example, given the input list [1,2,3,4,5], the function will modify the input list like [1, 1, 1, 1, 1] 

The function replaceElements  accepts two arguments – size an integer representing the size of the given input list and arr, a list of integers representing the input list.

The function replaceElements compiles successfully but fails to get the desired result for some test cases due to incorrect implementation of the function. Your task is to fix the code so that it passes all the test cases

 

Question : 4

Ram is a 6 years old boy who loves to play with numeric lego. One day ram’s mom created a number using those lego and asked ram to tell the number of elements available between two specific numbers ‘alpha1’ and ‘alpha2’. After 15 years when ram started learning C, he now wants to write a C code to find the number of elements lies between ranges alpha1 and alpha2. If the number is arr and the starting and ending points are alpha1 and alpha2, find the numbers of elements lies in the range

Input:
Three space-separated integers
1. First is the length of arr.
2. Second is the starting point as alpha1
3. The third is the endpoint as alpha2
Output:
Indexes of elements lie between this range.

Example
Input
9 2 6
1 2 3 4 5 6 7 8 9

Output
1 2 3 4

Find the error in the given code

Question : 5

Find the security key to access the bank account in from the encrypted message. The key in the message is the first repeating number from the given message of numbers.

Input format:

Single Integer value

Output format:

The first repeating number from the message

Example:

Input:

123456654321

Output:

1

Find the error in the given C programming code:

Question : 6

From the given set of the array, integer numbers in an array Write the program to add the numbers the same as the given number. The program takes 3 space-separated values, First is the length as ’len’, Second arr[]ar as ’arr’, Third the given number as ‘value’.

Input format:

Three space-separated inputs

  1. Length
  2. Input number
  3. Element 

Output format:

Sum of elements the same as the value

Example:

Input:

8 12342562 2

Output:

6

The code for the given problem is solved by one of our coder find the error in the given code.

Question : 7

For the generation of energy at the atomic center the energy is used to start the plant is in negative sign and the energy generated after the plant started is represented with a positive sign. Our task is to calculate the total number of energy that is generated throughout the day.

Below is the code in C programming but it is not working well find the error in the code

Input format:

Two inputs One for the number of times energy was recorded  as ‘total_reading’ and second the reading of the energy used or produced ‘arr’

Output format:

Sum of the total energy produced

Example:

Input:

8

1 4 -5 6 7 -4 4 -1

Output:

12

Question : 8

Print the number at the given index of the series 1 1 2 3 5… and so on. Consider the index as the number and print the value

Input format:

Single input of the index of the number as ‘number’

Output format:

The number at the given index of the series

Example:

Input:

10

Output:

55

below is the code for this problem find the problem in the given code

Question : 9

Function/method employeeID accepts four arguments-len, an integer representing the length of input list. arr,start , end of range and a list of integers It returns an integer representing the sum of all id’s of the employees in that range for example  

len = 6,start=30,end=50, arr = [29 38 12 48 39 55]

function /method will return 8 i.e 1+3+4. Function/method compiles successfully but fails to return the desired result for some/all cases due to incorrect implementation. Your task is to debug the code so that it passes all test cases.

Example

Input

6 30 50

29 38 12 48 39 55

Output

8

Explanation  :

There are 3 employees with id 1, 3, 4 whose distance from the office lies within the given range sum of the id’s is 8.

Question : 10

Function/method secretKey ​accepts a single argument- arr, a string. It returns an integer representing the count of all characters in it without duplicates(length of string after removing duplicates)

arr=5435436789

function /method will return 7. Function/method compiles successfully but fails to return the desired result for some/all cases due to incorrect implementation. Your task is to debug the code so that it passes all test cases.

Example

Input

5435436789

Output

7

Explanation

The repeated digits in the data are 5,4 and 3. So, the security key is 7 which is the length of the string after removing duplicates.

Question : 11

Function/method energyCal accepts two arguments-len, an integer representing the length of input list. energy,​ a list of integers. It returns an integer representing the sum of elements whose product is maximum for example  len = 7, energy= [9 -3 8 -6 -7 8 10]

function /method will return 19 function/method compiles successfully but fails to return the desired result for some/all cases due to incorrect implementation. Your task is to debug the code so that it passes all test cases.

Example

Input

7

9 -3 8 -6 -7 8 10

Output

19

Explanation

The maximum product of the energies is 90 i.e 9*10

So the sum of energy of chemicals is 19.

Question : 12

Function/method nthFib accepts single argument-num, an integer representing number. for example  num=9

function /method will return 34 function/method compiles successfully but fails to return the desired result for some/all cases due to incorrect implementation. Your task is to debug the code so that it passes all test cases.

Example

Input

8

Output

21

Explanation:

The sequence generated by the system will be 1, 1, 2, 3, 5, 8, 13, 21. The 8th number generated from this series will be 21

Question : 13

The​ function studentSort(int *arr, int len) accepts​ an integer array arr(which is heights of students) of length len as an input and performs an in place sort operations on it. The function is expected to return the input array sorted in descending order of their heights, but instead, it returns the array sorted in ascending order due to a bug in the code.

Your task is to debug the program to pass all test cases.

 

Question : 14

The​ function patternPrint(int num) ​prints even or odd numbers based on the values of the input arguments num(num >= 0).

If the input number num is even, the function is expected to print the even whole numbers upto num and in case it is odd, is expected to print the odd numbers upto num(inclusively).

For example given input 6, the function prints the string “0 2 4 6”(without quotes).

The function compiles successfully but fails to print the desired result due to logical errors.

Your task is to debug the program to pass all the test cases.

Test Cases:

Test Case 1:

Input:

23

Expected Return Value:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45

Test Case 2:

Input:

14

Expected Return Value:

0 2 4 6 8 10 12 14 16 18 20 22 24 26

Question : 15

The function mulTable(int num) ​is supposed to print the first twenty multiples of the multiplication table of the input number num​     ​. 

The function compiles fine but fails to return the desired result for some cases.

Your task is to fix the program so that it passes all the test cases.

Test cases:

TestCase 1:

Input:

6

Expected return value:

6  12  18  24  30  36  42  48  57  60 66 72 78 84 90 96 102 108 114 120

TestCase 2:

Input:

0

Expected return value:

0  0  0  0  0  0  0  0  0  0 0 0 0 0 0 0 0 0 0 0

Question : 16

The function binarySearch(int* arr,int len, int target) performs the binary search algorithm to look for an element target​ in the input array arr​ of length len​ ​. In case it is found the function returns the index of target​ ​ in arr​ ​ and returns a-1 if not found. 

The function works seemingly well but goes into an infinite loop for some test cases. 

Your task is to fix the program so that it passes all the test cases.

Note: If there is a ​Time limit exceeded error,​  it can be due to an infinite loop.​

Test Cases:

TestCase 1:

Input:

[0 , 2 , 3 , 4 , 5,  6 , 7 , 8] , 8 , 4

Expected Return Value:​

3

TestCase 2:

Input:

[2 , 3],2,3

Expected Return Value:

1

Question : 17

The function/method sameOddElementCount returns an integer representing the number of elements of the input list which are odd numbers and equal to the elements to its left. For example, if the input list is [1,3,3,4,5,5,9,9,10,11] then the function/method should return the output ‘3’ as it has three similar groups i.e. {3,3},  {5,5}, {9,9}.

The function/method sameOddElementCount accepts two arguments – size, and integer representing the size of the input list and inputList, a list of integers representing the input list.

The function/Method compiles successfully but fails to return the desired result for some test cases due to incorrect implementation of the function/method sameOddElementCount. Your task is to fix the code so that it passes all the test cases.

Test Case 1:

Input :

11

[1, 5, 5, 2, 2, 7,7, 8, 6 ,6, 9, 10]          

Expected Return Value

2

Test Case 1:

Input :

5

[13, 12, 12, 13, 14]          

Expected Return Value 

0

Question : 18

The function/method allExponent returns a real number representing the result of exponentiation of base raised to power exponent for all input values.

The function/method allExponent accepts two arguments – baseValue, an integer representing the base and exponentValue, and integer representing the exponent.

The incomplete code in the function/method allExponent works only for negative values of the exponent. You must complete the code and make it work for positive values of exponent as well.

Another function negativeExponent uses an efficient way for exponentiation but accepts only negative exponent values. You are supposed to use this function/method to complete the code in allExponent function/method.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription

4 comments on “DXC Automata Fix Questions and Answers”