PYTHON DATA STRUCTURE QUIZ DESCRIPTION

Dijkstra’s Algorithm cannot be applied on which of the following?

  •  Directed and weighted graphs
     

  •  Graphs having negative weight function

  •  Unweighted graphs

  •  Undirected and unweighted graphs

Does python uses dynamic typing?

  • Yes
     

  •  No

  •  It depends on python version

  •    it depends on the data type
     

Which of the following sorting algorithms provide the best time complexity in the worst-case scenario?
 

  • Merge Sort
     

  • Quick Sort

  • Bubble Sort

  • Selection Sort

Where does a new element go in a queue's linked list implementation?
 

  • At the head of link list
     

  • At the tail of the link list

  • At the centre position in the link list

  • At any position in the linked list

Which of the following algorithms are useful for processing queries on trees?
 

  • Centroid Decomposition.
     

  • Heavy Light Decomposition.

  • Both (A) and (B).

  • Neither (A) nor (B).

What are the advantages of using a linked list instead of an array to express binary trees?
 

  • dynamic size
     

  • ease of insertion/deletion

  • ease in randomly accessing a node

  • both dynamic size and ease in insertion/deletion

Which of the following is a linear data structure?


  • Array
     

  • AVL Trees

  • Binary Trees

  • Graphs
     

Which data structure is mainly used for implementing the recursive algorithm?

  • Queue
     

  • Stack

  • Array

  • List

In a graph of n nodes and n edges, how many cycles will be present?

  • Exactly 1
     

  • At most 1

  • At most 2

  • Depends on the graph

Which of the following scenario is true for the statement - “Arrays are best data structures”?

  •  For the size of the structure and the data in the structure are constantly changing
     

  • For relatively permanent collections of data

  •  Both A and B

  •  None of the above

In circular queue, the value of REAR would be?

  •  REAR = REAR + 1
     

  •  REAR = (REAR + 1) % (QUEUE_SIZE+1)

  •  REAR = (REAR + 1) % (QUEUE_SIZE)

  •  REAR = (REAR - 1) % (QUEUE_SIZE-1)

Which of the following statements is true about AVL Trees?

  • The difference between the heights of left and right nodes cannot be more than 1.
    The height of an AVL Tree always remains of the order of O(logn)
    AVL Trees are a type of self-balancing Binary Search Trees.
    All of the above.

  • The height of an AVL Tree always remains of the order of O(logn)

  • AVL Trees are a type of self-balancing Binary Search Trees.

  • All of the above.

Which of the following data structures are indexed structures?

  •  Queue
     

  •  Trees

  •  Linear Arrays

  •  None of the above

What is the most important criteria that must be met before being inserted into a linked queue?
 

  • Underflow
     

  • Overflow

  • Front value

  • Rear value
     

Which of the following algorithms are used to find the shortest path from a source node to all other nodes in a weighted graph?
BFS.

  • Djikstra’s Algorithm.
     

  • Prims Algorithm.

  • Kruskal’s Algorithm.

The binary search method needs no more than ________ comparisons.

  •  (log2n) + 1
     

  •  logn

  •  (logn) + 1

  •  log2n

What will be the final elements on the stack if the following sequence of operations are executed?
Push(a,s);
Push(b,s);
Pop(s);
Push(c,s);
where a, b, c are the data elements and s is the stack.

  • abc

  • ac

  • acb

  • a

What is the maximum number of children a node can have in an n-ary tree?
 

  • 2

  • 0

  • 1

  • n

Which of the following represents the Postorder Traversal of a Binary Tree?

  • Left -> Right -> Root
     

  • Left -> Root -> Right

  • Right -> Left -> Root

  • Right -> Root -> Left

Which of the following data structures is linear?

  •  Graph
     

  •  AVL Tree

  •  Red-Black Tree

  •  Stack

Which of the following statement is true:

  •  The less frequently the split occurs, if the order of B-tree is large
     

  • The split occurs more frequently, if the order of B-tree is large

  •  The more frequently the split occurs, if the order of B-tree is small

  •  The less frequently the split occurs, if the order of B-tree is small

Which of the following code snippet is used to convert decimal to binary numbers?
 

  • public void convertBinary(int num)
    {
    int bin[] = new int[50];
    int index = 0;
    while(num > 0)
    {
    bin[index++] = num%2;
    num = num/2;
    }
    for(int i = index-1;i >= 0;i--)
    {
    Syst

  • public void convertBinary(int num)
    {
    int bin[] = new int[50];
    int index = 0;
    while(num > 0)
    {
    bin[++index] = num/2;
    num = num%2;
    }
    for(int i = index-1;i >= 0;i--)
    {
    Syst

  • public void convertBinary(int num)
    {
    int bin[] = new int[50];
    int index = 0;
    while(num > 0)
    {
    bin[index++] = num/2;
    num = num%2;
    }
    for(int i = index-1;i >= 0;i--)
    {
    Syst

  • public void convertBinary(int num)
    {
    int bin[] = new int[50];
    int index = 0;
    while(num > 0)
    {
    bin[++index] = num%2;
    num = num/2;
    }
    for(int i = index-1;i >= 0;i--)
    {
    Syst

 

Consider the following code snippet:
void solve(vector<int> &a) {
   int queries;
   cin >> queries;
   while(queries--) {
       int type;
       cin >> type;
       if(type == 1) {
           int index, value;
           cin >> index >> value;
           update(a, index, value);
       }
       else {
           int l, r;
           cin >> l >> r;
           cout << getXOR(a, l, r) << endl;
       }
   }
}

The update() function updates the element at the given index in the array to some given value. The getXOR() function returns the XOR of the elements in the array a, in the range [l, r]. Which of the following data structures can perform the above tasks optimally?

  • Segment Trees.
     

  • Prefix XOR Arrays.

  • Tries.

  • Stacks.
     

which feature does not match with python

  • open source
     

  • interpreted

  •    compiled

  •  high level
     

Garbbage collection introduced in which python version

  • 2

  • 1

  • 3

  • 4

Worst case time complexity to access an element in a BST can be?

  • O(n)
     

  • O(n * logn)

  • O(1)

  • O(logn)

What is the time complexity to count the number of elements in the linked list?

  • O(n)
     

  • O(1)

  • O(logn)

  • O(n^2)

Which one of these is not a Built-in Data Structure of python?

  • List
     

  •  Tuple

  •  Structure

  •  Set
     

How can memory be saved when storing colour information in a Red-Black tree?

  •  Using the least significant bit of one of the node's pointers to store colour information
     

  •  another array with the colours of each node

  •  Keeping colour data in the node structure

  •  employing both negative and positive numbering

A node in a tree, such that removing it splits the tree into forests, with size of each connected component being not greater than n / 2 is called?

  • Center
    Diameter
    Centroid
    Path

  • Diameter

  • Centroid

  • Path