Add office photos
Employer?
Claim Account for FREE

Adobe

4.0
based on 1k Reviews
Filter interviews by

10+ Cognizant Interview Questions and Answers

Updated 10 Jan 2025
Popular Designations
Q1. Sort an array according to count of set bits

You are given an array consisting of N positive integers, and your task is to sort the array in decreasing order of count of set bits in the binary representation of ...read more

Add your answer
Q2. Reverse Linked List

Given a singly linked list of integers. Your task is to return the head of the reversed linked list.

For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked lis...read more
Add your answer
Q3. Find power of a number

Write a program to find x to the power n (i.e., x^n). Take x and n from the user. You need to print the answer.

Note: For this question, you can assume that 0 raised to the power of 0 is 1...read more

Add your answer
Q4. Validate BST

Given a binary tree with N number of nodes, check if that input tree is BST (Binary Search Tree) or not. If yes, return true, return false otherwise.

A binary search tree (BST) is a binary tree data...read more

Add your answer
Discover Cognizant interview dos and don'ts from real experiences
Q5. Maximum sum of non-adjacent elements

You are given an array/list of ‘N’ integers. You are supposed to return the maximum sum of the subsequence with the constraint that no two elements are adjacent in the given ...read more

Add your answer
Q6. Colourful Knapsack Problem

You are given 'N' stones labeled from 1 to 'N'. The 'i-th' stone has the weight W[i]. There are 'M' colors labeled by integers from 1 to 'M'. The 'i-th' stone has the color C[i] which ...read more

Add your answer
Are these interview questions helpful?
Q7. Minimum number of lamps needed to be installed

You are given a string 'S' containing dots(.) and asterisks(*) only, where the dot represents free spaces, and the asterisk denotes lamps. A lamp can lighten up its...read more

Add your answer
Q8. There are two singly linked lists in a system. By some programming error, the end node of one of the linked list got linked to the second list, forming an inverted Y shaped list. Write a program to get the poin...read more
Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. 1>linked list node contain a string field and next.find if by concatenating all string fields the string formed is palindrome or not? 2-> merge to sorted array in which one arra is large enough to accomodate el...

read more
Ans.

The first question is about checking if a string formed by concatenating all string fields in a linked list is a palindrome or not.

  • Traverse the linked list and concatenate all string fields

  • Check if the concatenated string is a palindrome by comparing characters from both ends

  • Consider edge cases like empty linked list or single node with an empty string field

Add your answer

Q10. Puzzle question -> 12 people on island with a seesaw. 11 of them have identical weight, one has higher or lower. How can you find out which one? You can only use the seesaw 3 times

Ans.

Use the seesaw 3 times to find the person with different weight among 12 people on an island.

  • Divide the 12 people into 3 groups of 4.

  • Compare 2 groups on the seesaw, then narrow down the group with the different person.

  • Take the 4 people from the identified group and compare 2 of them on the seesaw to find the person with different weight.

Add your answer
Q11. Egg dropping puzzle

It was just discussed at the end.

Add your answer

Q12. 1. Binary tree traversal 2. Multiply 2 big numbers represented in the form of string. 3. Detect the k-th node from the back of a linked list.

Ans.

Questions on binary tree traversal, multiplying big numbers represented as strings, and detecting k-th node from the back of a linked list.

  • Binary tree traversal can be done in three ways: in-order, pre-order, and post-order.

  • To multiply two big numbers represented as strings, you can use the grade-school algorithm or Karatsuba algorithm.

  • To detect the k-th node from the back of a linked list, you can use two pointers approach or find the length of the list first.

Add your answer

Q13. Difference between process and thread

Ans.

A process is an instance of a program, while a thread is a unit of execution within a process.

  • A process is an independent entity that runs in its own memory space, while threads share the same memory space within a process.

  • Processes have their own resources, such as file handles and memory, while threads share these resources.

  • Processes are heavyweight and have higher overhead, while threads are lightweight and have lower overhead.

  • Processes provide better isolation and securit...read more

Add your answer

Q14. Explain C++ memory management & pointers

Ans.

C++ memory management involves allocating and deallocating memory for variables, while pointers store memory addresses.

  • Pointers are variables that store memory addresses.

  • They are used to access and manipulate data stored in memory.

  • Example: int* ptr = new int; *ptr = 10; delete ptr;

Add your answer

Q15. Modified unbounded knapsack.

Ans.

Modified unbounded knapsack problem involves maximizing the value of items with unlimited quantities and weight constraints.

  • Consider items with values and weights, along with a weight constraint

  • Dynamic programming can be used to solve this problem efficiently

  • Examples: Given items with values [60, 100, 120] and weights [10, 20, 30], and a weight constraint of 50, maximize the value

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Cognizant

based on 3 interviews in the last 1 year
Interview experience
5.0
Excellent
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

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