PYTHON DATA STRUCTURE QUIZ DESCRIPTION

Which node in a max-heap always has the element with the biggest key?

  • root node
     

  • Leaf node

  • First node of left sub tree

  • First node of right sub tree

What will be the output of the following code snippet?
void solve() {
   deque<int> dq;
   for(int i = 1; i <= 5; i++) {
       if(i % 2 == 0) {
           dq.push_back(i);
       }
       else {
           dq.push_front(i);
       }
   }
   for(auto x: dq) {
       cout << x << " ";
   }
   cout << endl;
}

  • 1 2 3 4 5
     

  • 5 4 3 2 1

  • 1 3 5 2 4

  • 5 3 1 2 4

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

  • Queue
     

  • Stack

  • Array

  • List

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

Which of the following sorting methods has the least amount of time ________________complexity when sorting a random linked list?
 

  • Heap Sort
     

  • Merge Sort

  • Insertion Sort

  • Quick Sort

Which of the following is a Stack Data Structure application?
 

  • Managing function calls
      

  • The stock span problem

  • Arithmetic expression evaluation

  • All of the above
         

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

  • O(n)
     

  • O(1)

  • O(logn)

  • O(n^2)

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

What is the time complexity of the Sieve of Eratosthenes to check if a number is prime?

  • O(nlog(logn)) Precomputation, O(1) for check.
     

  • O(n) Precomputation, O(1) for the check.

  • O(n * logn) Precomputation, O(logn) for check.

  • O(n) Precomputation, O(logn) for check.

Which of the following algorithms are used for string and pattern matching problems?
 

  • Z Algorithm
     

  • Rabin Karp Algorithm

  • KMP Algorithm

  • All of the above
     

 

What will the output of the following code snippet be?

void solve() {
   vector<int> a = {1, 2, 3, 4, 5};
   sort(a.begin(), a.end(), [&](const int &x, const int &y) {
       return x % 2 < y % 2;
   });
   for(int x: a) {
       cout << x << " ";
   }
   cout << endl;
}

  • 1 2 3 4 5
     

  • 5 4 3 2 1

  • 1 3 5 2 4

  • 2 4 1 3 5

How is an array initialized in C language?

  • int a[3] = {1, 2, 3};
     


  • int a = {1, 2, 3};
     


  • int a[] = new int[3]
     


  • int a(3) = [1, 2, 3];

Which of the following can be done with LinkedList?

  • Implementation of Stacks and Queues
     

  • Implementation of Binary Trees

  • Implementation of Data Structures that can simulate Dynamic Arrays

  • All of the above

Does python uses dynamic typing?

  • Yes
     

  •  No

  •  It depends on python version

  •    it depends on the data type
     

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

What does the following code snippet do?
void dfs(int node, vector<vector<int>> &edges, vector<bool> &vis, vector<int> &dp) {
   vis[node] = true;
   for(auto x: edges[node]) {
       if(!vis[x]) {
           dp[x] = dp[node] + 1;
           dfs(x, edges, vis, dp);
       }
   }
}

  • Stores depths of all the nodes in a given tree, with respect to some root node.
     

  • Counts the number of nodes in a given tree.

  • Finds the diameter of a tree.

  • Checks if all the nodes are reachable in a given tree.

what is the correct way to set boolean variable myVar to false? 

  • myVar = true
     

  •  myVar = True

  •  var myVar = true

  •  var myVar = True

Which of the following data structures is best for searching words in dictionaries?

  • Binary Search Tree
     

  •  Graph

  •  N-ary tree

  •  Trie

What is the time complexity of the binary search algorithm?

  • O(n)
     

  • O(1)

  • O(log2n)

  • O(n^2)

What is the extentions for the python file?

  • python
     

  •  py

  •    pi

  •    pi3

which feature does not match with python

  • open source
     

  • interpreted

  •    compiled

  •  high level
     

Which of the following data structure can’t store the non-homogeneous data elements?

  •  Arrays
     

  •  Records

  •  Pointers

  •  Stacks

 A directed graph is _______ if there is a path from each vertex to every other vertex in the graph.

  •  Weakly connected
     

  •  Strongly connected

  •  Tightly connected

  • Linearly connected

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

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 one of these is not a Built-in Data Structure of python?

  • List
     

  •  Tuple

  •  Structure

  •  Set
     

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 is a Divide and Conquer algorithm?

  • Bubble Sort
     

  • Selection Sort

  • Heap Sort

  • Merge Sort
     

Consider we have a function, getLCA(), which returns us the Lowest Common Ancestor between 2 nodes of a tree. Using this getLCA() function, how can we calculate the distance between 2 nodes, given that distance from the root, to each node is calculated?
 

  • dist(u) + dist(v) - 2 * dist(getLCA(u, v))
     

  • dist(u) + dist(v) + 2 * dist(getLCA(u, v))

  • dist(u) + dist(v)

  • dist(u) + dist(v) - dist(getLCA(u, v))