Add office photos
Cognizant logo
Engaged Employer

Cognizant

Verified
3.7
based on 50.6k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
GenC Next
Fresher
Clear (2)

10+ Cognizant GenC Next Interview Questions and Answers for Freshers

Updated 5 Feb 2024

Q1. Minimum Steps for a Knight to Reach Target

Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.

Expl...read more

Ans.

Calculate minimum steps for a Knight to reach target position on a chessboard.

  • Use BFS algorithm to find shortest path from Knight's starting position to target position.

  • Consider all possible moves of the Knight on the chessboard.

  • Keep track of visited positions to avoid revisiting them.

  • Return the minimum number of moves required for the Knight to reach the target position.

Add your answer
right arrow

Q2. Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more

Ans.

The task is to find the total number of ways to make change for a specified value using given denominations.

  • Create a dynamic programming table to store the number of ways to make change for each value up to the target value.

  • Iterate through each denomination and update the table accordingly.

  • The final answer will be the value in the table at the target value.

  • Consider edge cases like when the target value is 0 or when there are no denominations that can make the change.

  • Example: ...read more

Add your answer
right arrow

Q3. Sort Array Problem Statement

Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.

Input:

Each input starts wi...read more
Ans.

Sort an array of positive integers (0, 1, 2) in non-decreasing order.

  • Iterate through the array and count the occurrences of 0, 1, and 2.

  • Update the array with the counts of each element in non-decreasing order.

  • Print the sorted array for each test case.

Add your answer
right arrow

Q4. What are the bounding methods in React? Difference between Class Component and Functional Component in ReactJS?

Ans.

Bounding methods in React are used to limit the scope of a component's updates.

  • Bounding methods include shouldComponentUpdate, getSnapshotBeforeUpdate, and componentDidUpdate.

  • shouldComponentUpdate allows a component to decide if it should update based on changes in props or state.

  • getSnapshotBeforeUpdate allows a component to capture information before a change is made to the DOM.

  • componentDidUpdate is called after a component updates and can be used to perform additional actio...read more

Add your answer
right arrow
Discover Cognizant interview dos and don'ts from real experiences

Q5. Write a program to perform Binary search on an array of N numbers.

Ans.

Program to perform Binary search on an array of N numbers.

  • Sort the array in ascending order

  • Set low and high variables to the first and last index of the array respectively

  • Calculate the mid index as (low+high)/2

  • If the element at mid index is equal to the search element, return mid

  • If the element at mid index is less than the search element, set low to mid+1

  • If the element at mid index is greater than the search element, set high to mid-1

  • Repeat until low is greater than high or e...read more

View 1 answer
right arrow

Q6. What are the different regularization techniques?

Ans.

Regularization techniques are used to prevent overfitting in machine learning models.

  • L1 regularization (Lasso)

  • L2 regularization (Ridge)

  • Elastic Net regularization

  • Dropout regularization

  • Early stopping

  • Data augmentation

  • Batch normalization

Add your answer
right arrow
Are these interview questions helpful?

Q7. What is virtual DOM and why ReactJS uses it?

Ans.

Virtual DOM is a lightweight copy of the actual DOM used for efficient updates.

  • Virtual DOM is a concept where a lightweight copy of the actual DOM is created.

  • ReactJS uses it to efficiently update the UI without re-rendering the entire page.

  • Virtual DOM compares the previous and current states and updates only the necessary changes.

  • This results in faster rendering and better performance.

  • Example: When a user types in a search bar, only the search results are updated, not the ent...read more

Add your answer
right arrow

Q8. Explain all the stages of creating a machine learning model on a given dataset

Ans.

Creating a machine learning model involves data preparation, model selection, training, evaluation, and deployment.

  • Data preparation involves cleaning, transforming, and splitting the data into training and testing sets.

  • Model selection involves choosing the appropriate algorithm and hyperparameters for the problem.

  • Training the model involves feeding the training data to the algorithm and adjusting the parameters to minimize the error.

  • Evaluation involves testing the model on th...read more

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Write a program to perform Merge sort on an array of N numbers.

Ans.

Program to perform Merge sort on an array of N numbers.

  • Divide the array into two halves recursively

  • Sort the two halves using merge sort

  • Merge the two sorted halves

  • Repeat until the entire array is sorted

  • Time complexity: O(nlogn)

Add your answer
right arrow

Q10. What is the formula for gradient descent?

Ans.

Gradient descent is an optimization algorithm used to minimize the cost function of a machine learning model.

  • Start with an initial guess for the model parameters

  • Calculate the gradient of the cost function with respect to each parameter

  • Update the parameters in the opposite direction of the gradient

  • Repeat until convergence or a maximum number of iterations is reached

Add your answer
right arrow

Q11. What is your favourite technology?

Ans.

My favorite technology is artificial intelligence.

  • AI has the potential to revolutionize various industries

  • It can automate repetitive tasks and improve efficiency

  • AI can also help in making better decisions by analyzing large amounts of data

  • Examples include chatbots, image recognition, and predictive analytics

Add your answer
right arrow

Q12. What is poison distribution?

Ans.

Poison distribution refers to the spread of toxic substances through various means.

  • Poison distribution can occur through intentional or accidental means.

  • Examples include the distribution of poison through food or water, or the release of toxic chemicals into the environment.

  • Poison distribution can have serious health consequences and may require immediate medical attention.

  • Prevention measures such as proper storage and disposal of toxic substances can help prevent poison dist...read more

Add your answer
right arrow

Q13. What is PCA?

Ans.

PCA stands for Principal Component Analysis. It is a statistical technique used for dimensionality reduction.

  • PCA is used to identify patterns in data and reduce the number of variables in a dataset.

  • It works by transforming the original variables into a new set of variables called principal components.

  • These principal components are ordered by the amount of variance they explain in the data.

  • PCA is commonly used in fields such as finance, biology, and image processing.

  • Example: P...read more

Add your answer
right arrow

Q14. Explain any clustering algorithm.

Ans.

Clustering algorithm groups similar data points together based on their characteristics.

  • Clustering is an unsupervised learning technique.

  • It can be used for customer segmentation, image segmentation, etc.

  • K-means, hierarchical clustering, and DBSCAN are popular clustering algorithms.

  • The choice of algorithm depends on the data and the problem at hand.

Add your answer
right arrow

More about working at Cognizant

Back
Awards Leaf
AmbitionBox Logo
Top Rated Mega Company - 2024
Awards Leaf
Awards Leaf
AmbitionBox Logo
Top Rated IT/ITES Company - 2024
Awards Leaf
HQ - Teaneck. New Jersey., United States (USA)
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Recently Viewed
JOBS
Capgemini
No Jobs
INTERVIEWS
National Aerospace Laboratories
No Interviews
LIST OF COMPANIES
The Energy and Resources Institute
Locations
INTERVIEWS
National Aerospace Laboratories
No Interviews
INTERVIEWS
National Aerospace Laboratories
No Interviews
SALARIES
NXTDIGITAL
No Salaries
LIST OF COMPANIES
National Aerospace Laboratories
Locations
INTERVIEWS
National Aerospace Laboratories
No Interviews
JOBS
KPMG India
No Jobs
INTERVIEWS
IntouchCX
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter