Cognizant GenC Next Data Structure Questions 2023

GenC Next Data Structure Questions 2023

Cognizant has announced its GenC Next Hiring profile for 2023 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

Cognizant GenC Next Data Structure Questions 2023
Total number of Questions in in TCS NQT Verbal

20 - 25 Question

Total Question

Time limit for TCS NQT Verbal Ability Section

40 minutes

Total Time

Marks rewarded for TCS NQT Verbal Ability Section

1 Mark/Question

Marking Scheme

No negative marking in TCS NQT Verbal Ability Section

No

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.24%

11

11

17.13%

12

12

45.84%

None of the mentioned

None of the mentioned

4.79%

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.45%

1

1

6.16%

3

3

64.45%

None of the mentioned

None of the mentioned

14.93%

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)
    {
      // Add your code//
    }
  else
    {
    print "Underflow"
    }

return top
}

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

top = top+1

top = top+1

24.03%

top = top-1

top = top-1

73.61%

Error

Error

1.5%

None of the mentioned

None of the mentioned

0.86%

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.69%

x-1

x-1

34.07%

x-2

x-2

37.09%

x+1

x+1

21.15%

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.92%

3

3

54.83%

6

6

27.15%

2

2

8.09%

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

49.08%

4

4

17.15%

3

3

20.32%

1

1

13.46%

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.9%

Y

Y

71.98%

P

P

16.52%

Q

Q

5.6%

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.

ADD 23

DELETE

ADD 20

ADD 32

ADD 90

DELETE

DELETE

ADD 8

ADD 27

What element is present at the front and rear respectively?

27 90

27 90

9.14%

90 27

90 27

74.57%

20 27

20 27

12.57%

27 20

27 20

3.71%

Initially the queue is empty,

Queue follows FIFO mechanism

Operation            Status of queue

ADD 23                23

DELETE               -

ADD 20                20

ADD 32                20  32

ADD 90                20  32  90

DELETE               32  90

DELETE               90

ADD 8                   90 8

ADD 27                 90 8 27

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.71%

B

B

12.78%

C

C

10.22%

D

D

70.29%

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.39%

O(1)

O(1)

5.28%

O(n)

O(n)

33.43%

O(m)

O(m)

12.9%

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

 

×

Please login to report

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
  • Linked Lists
  • 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.