Question types

Data Structure question types

98 questions across 6 question groups — pick any mix to generate a Computer Science paper with step-by-step answer keys.

98
Questions
6
Question groups
5
Question types
Sample Questions

Data Structure questions

One sample from each question group in this chapter. Select any group above to see the full set with answer keys.

Q 112 Marks Each2 Marks
Write definition of a Method COUNTNOW(PLACES) to find and display those place names, in which there are more than 5 characters.

For example:If the list PLACES contains [''DELHI'', ''LONDON'', ''PARIS'', ''NEW YORK'', ''DUBAI'']The following should get displayedLONDONNEW YORK

View full solution
Q 122 Marks Each2 Marks
Write definition of a method ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with zero (0) and display the sum.

For example,If the SCORES contain [200,456,300,100,234,678]The sum should be displayed as 600.

View full solution
Q 132 Marks Each2 Marks
Write the definition of a function Reverse(X) in Python, to display the elements in reverse order such that each displayed element is the twice of the original element (element * 2) of the List X in the following manner:

Example:

If List X contains 7 integers is as follows:

X[0] X[1] X[2] X[3] X[4] X[5] X[6]
4 8 7 5 6 2 10

After executing the function, the array content should be displayed as follows:

View full solution
Q 142 Marks Each2 Marks
For a given list of values in descending order, write a method in python to search for a value with the help of Binary Search method. The method should return position of the value and should return –1 if the value not present in the list.
View full solution
Q 183 Marks Each3 Marks
What will be the status of the following list after the First, Second and Third pass of the bubble sort method used for arranging the following elements in descending order ?

Note: Show the status of all the elements after each pass very clearly underlining the changes. 152, 104, -100, 604, 190, 204

View full solution
Q 193 Marks Each3 Marks
Write a user defined function arrangelements(X),that accepts a list X of integers and sets all the negative elements to the left and all positive elements to the right of the list.

For example:
if L =[1,-2,3,4,-5,7] ,
Then the output should be: [-2,-5,3,4,7]

View full solution
Q 215 Marks Each5 Marks
The following is the code related to the data structure QUEUE

Now answer the following based on the code given:

(a) What is the purpose of EnQueue function

(# Statement-1) defined above:

(i) It is a user defined function to scan / access QUEUE elements

(ii) It is a pre defined function to scan / access QUEUE elements

(iii) It is a user defined function working on double ended queue

(iv) It is a user defined function working on circular queue

(b) What is the line QUEUE.append(VALUE)

(# Statement-2) doing

(i) This will add the element at the end of the QUEUE

(ii) This will remove the element from the end of the QUEUE

(iii) This will add the element at the beginning of the QUEUE

(iv) This will remove the element from the beginning of the QUEUE

(c) Conceptually if the QUEUE is already full , what will happen

(i) PEEK() function will be executed

(ii) OVERFLOW occurs

(iii) UNDERFLOW occurs

(iv) We may still add more elements in it.

(d) What is the use of the variable VALUE used in argument (# Statement-1)

(i) This is the position of FRONT

(ii) This is the position of REAR

(iii) This is an element added in a QUEUE

(iv) This is the name of the list

(e) When the else part (# Statement-3) of the above code will be executed

(i) When the length of the QUEUE is zero

(ii) When the length of the QUEUE is one

(iii) When the length of the QUEUE is more than one

(iv) This part of the code will always executed

View full solution
Q 225 Marks Each5 Marks
Read the following code carefully which is implementing the concept of STACK:

Now answer the following based on the code given:

(a) How are the above two functions interrelated?

(i) The function isEmpty(STACK) will be called when pop(STACK) is called

(ii) The function pop(STACK) will be called when is Empty(STACK) is called

(iii) Both functions are implementing recursion

(iv) These functions are not related to each other.

(b) What is the difference in between STACK.pop() and pop(STACK)

(i) Both are pre-defined functions

(ii) Both are user-defined functions

(iii) STACK.pop() is pre defined and pop(STACK) is user defined

(iv) STACK.pop() is user defined and pop(STACK) is pre defined

(c) What is the return type of the function defisEmpty (STACK)

(i) None (ii) void

(iii) int (iv) Boolean

(d) What will the pop(STACK) function return if the stack already consist of [‘A’,’B’] at the position 0 and 1 respectively

(i) A (ii) B (iii) Both A and B (iv) None

(e) if len(STACK) == 0: What is the purpose of this line in the above code:

(i) It checks if the stack is already full

(ii) It checks if the stack can add more value in it or not

(iii) It checks if the stack is already empty

(iv) It checks if the stack exist or not

View full solution
Q 274 Marks Each4 Marks
Write the function Selection() to sort the list using Selection sort technique. The function will take the list as parameter.
View full solution

Generate a Data Structure paper free

Pick question groups from the list above, set marks and difficulty, and export a branded PDF with step-by-step answer keys. First 3 chapters free — no signup.

Download App