# Cognizant GenC Next Data Structure Questions 2024

## GenC Next Data Structure Questions 2024

Cognizant has announced its GenC Next Hiring profile for 2024 graduates. In this hiring exam, DSA plays a very important role. The hiring exam of GenC next consists of two sections-:

• Section 1 – MCQ Round
• Section 2 – Coding Round

And, in both these sections Data structures plays a very important role, you’ll find questions based on DSA both in the GenC Next MCQ Round and Coding Round

Total Question

Total Time

Marking Scheme

Negative Marking

## Practice Questions for GenC Next Data Structure

1. Prepster has a simple undirected planar graph on 4 vertices with 14 edges. If graph is a connected graph, then the number of bounded faces in any embedding of graph on the plane is equal to

10

10

32.75%

11

11

17%

12

12

45.5%

None of the mentioned

None of the mentioned

4.75%

Explanation : v-e+f=2 is used to calculate the number of bounded faces in any embedding of graphs on the plane.Here, in the given question we have v=4, e=14

So, f=2+(14-4) => f=12

2. Prepster wants to perform the insertion sorting on the array containing elements {2,1,4,3,7,9,0} , to sort the array in ascending order. How many insertion operations does he need to perform?

2

2

14.82%

1

1

6.12%

3

3

64.24%

None of the mentioned

None of the mentioned

14.82%

Given array contains elements {2,1,4,3,7,9,0}.

First insertion will done in inserting 1 to its correct position , so array will become {1,2,4,3,7,9,0}

Second insertion will done in inserting 3 to its correct position , so array will become {1,2,3,4,7,9,0}

And third insertion will done in inserting 0  to its correct position , so array will become {0,1,2,3,4,7,9}

3. A stack is implemented as a linear array A[0…N-1]. Prepster writes the following
functions for popping an element from the stack.

```Fun_POP (top, N)
{
if (top >= 0)
{
}
else
{
print "Underflow"
}

}```

Prepster wants to know what should be written at the place of  // Add your code//

top = top+1

top = top+1

23.99%

top = top-1

top = top-1

73.67%

Error

Error

1.49%

None of the mentioned

None of the mentioned

0.85%

As Fun_POP() will delete the element so the index of top will get decremented by 1.

4. Prepster design a complete graph G of order x. Then how many maximum cut vertices does that graph contain?

x

x

7.95%

x-1

x-1

33.97%

x-2

x-2

36.99%

x+1

x+1

21.1%

Explanation : Vertex cut is a subset of vertices of a graph which, if removed (or "cut")--together with any incident edges--disconnects the graph (i.e., forms a disconnected graph). A complete graph G, of order x will contain x-2 maximum cut vertices.

5. What will be the maximum number size of the stack that will appear during the analysis of the ( ( ) ( ( ) ) ( ( ) ) ) at any instance of time

4

4

9.87%

3

3

54.55%

6

6

27.53%

2

2

8.05%

Let max_size=0 represents the required size and curr_size is the current size of the stack.

Initially ( will push into stack now curr_size=1, as curr_size > max_size so max_size =1

now,( will push into stack now curr_size=2, as curr_size > max_size so max_size =2

Now, ) comes then pop() operation will perform so curr_size become 1 ,

Now ( will push into stack now curr_size=2, as curr_size > max_size so max_size =2

Now again  ( will push into stack now curr_size=3, as curr_size > max_size so max_size =3

Now, ) comes then pop() operation will perform so curr_size become 2

Again ) comes then pop() operation will perform so curr_size become 1

Now ( will push into stack now curr_size=2, as curr_size > max_size so max_size =2

Now again  ( will push into stack now curr_size=3, as curr_size > max_size so max_size =3

Now, ) comes then pop() operation will perform so curr_size become 2

Again ) comes then pop() operation will perform so curr_size become 1

And at last ) comes then pop() operation will perform so curr_size become 1

So the max_size appears to be 3.

6. What the following function will return :

```void fun (Node * root)
{

if (!root)
return;

return (1 + fun (root->left) + fun (root->right)));

}```

10

/  \

20     30

/  \

40   50

If the root of the above tree is passed initially to function fun():

5

5

48.82%

4

4

17.06%

3

3

20.73%

1

1

13.39%

Explanation : The following code will return the total number of nodes in the tree, in the given code we pass the root of the tree which has 5 odes, ence the function will give output as 5.

7. Prepster pushed seven elements X, Y, Z, P, Q, R and S onto a stack in reverse order, i.e., starting from S. The stack is popped five times and each element is inserted into a queue.Two elements are deleted from the queue The second deleted  item is ________.

X

X

5.88%

Y

Y

71.76%

P

P

16.76%

Q

Q

5.59%

In the given scenario:

The status of the stack , when 7 elements are inserted into it is : S R Q P Z Y X.

As stack follows LIFO then  status of queue will be : X Y Z P Q.

Now the queue follows FIFO principle then the first deleted element will be X and second will be Y.

8. If the prepster performs a certain operation on an empty queue.

DELETE

DELETE

DELETE

What element is present at the front and rear respectively?

27 90

27 90

9.09%

90 27

90 27

74.43%

20 27

20 27

12.5%

27 20

27 20

3.98%

Initially the queue is empty,

Queue follows FIFO mechanism

Operation            Status of queue

DELETE               -

DELETE               32  90

DELETE               90

Hence, 90 is present at front end and 27 at rear end.

9. Prepster  pushes five items A, B, C, D, and E into a stack, one after another starting from A. The stack is popped with four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item has popped from the stack. The popped item is

A

A

6.69%

B

B

12.74%

C

C

10.19%

D

D

70.38%

Initially the stack will contain A B C D E when stack is popped four times and element from stack will be inserted in queue then Queue contain E D C B and stack contain A only ,.

Now two elements will deleted from queue and inserted into stack then stack contain A E D and queue contain C B.

Now the popped element from stack is D.

10. What is the time complexity to check if a string(length m) is a substring of another string(length n) stored in a Directed Acyclic Word Graph, given n is greater than m?

O(m+n)

O(m+n)

48.54%

O(1)

O(1)

5.26%

O(n)

O(n)

33.33%

O(m)

O(m)

12.87%

The time complexity will be O(n) , n is the length of the main string.

×

## Cognizant GenC Next Data Structure Preparation Material

GenC Next is comparatively a difficult hiring than the normal Cognizant GenC, the level of questions in GenC next exam are difficult and tricky, and covers a vast syllabus. DSA plays an important role in the GenC Next exam, as it is asked in both the MCQ Round and in the Coding Round. Below we have mentioned all the topics that you need to cover to prepare for Data Structures for Cognizant GenC Next Exam.

• Arrays
• Searching and Sorting
• Struct
• Queues
• Stacks
• Trees
• Graphs

## GenC Next Data Structure Section Details

DSA SectionGenC Next
Number of Questions20 – 25 Questions
Time Limit40 Mins
DifficultyHigh
ImportanceHigh

## FAQs about GenC Next DSA Round

#### Is there a separate Data Structure round in GenC Next Exam ?

No, there is no separate section for DSA questions, you’ll find them within both the sections, with other questions

• Section 1 – MCQ Round
• Section 2 – Coding Round

#### Is there any sectional cut-off in genc next exam ?

No, there is no sectional cut-off in GenC Next Exam, but you need to clear both the sections to move up to the interview round.

#### Is there any elimination round in genc next exam ?

No, there is no elimination round in GenC Next Exam, but you need to clear both the sections to move up to the interview round.