Data Structure Skills Quiz! Trivia

10 Questions | Total Attempts: 132

SettingsSettingsSettings
Data Structure Skills Quiz! Trivia - Quiz

Have you ever heard of data structure? A data structure is a data organization, supervision and storage format that allows for efficient contact and modification in computer science. Data structures are often employed as objects, so understanding these items and analyzing them is an extremely important skill to possess. A data structure is a compilation of data values and the relationships they keep. This quiz will demonstrate your skills with the data structure.


Questions and Answers
  • 1. 
    Struct Node{    int val;    struct Node *next; }*head; int get_max() {       struct Node* temp = head->next;   int max_num = temp->val;   while(______)   {         if(temp->val > max_num)     max_num = temp->val; temp = temp->next;   }   return max_num; } Which of the following lines should be inserted to complete the above code?
    • A. 

      Temp->next!=0

    • B. 

      Temp->next!=0

    • C. 

      Head->next!=0

    • D. 

      Head != 0

  • 2. 
    What is the time complexity of inserting a node in a doubly linked list?
    • A. 

      O(nlogn)

    • B. 

      O(logn)

    • C. 

      O(n)

    • D. 

      O(1)

  • 3. 
    Which of the following real-world scenarios would you associate with a stack data structure?
    • A. 

      Piling up of chairs one above the other

    • B. 

      People standing in a line to be serviced at a counter

    • C. 

      Offer services based on the priority of the customer

    • D. 

      All of the above

  • 4. 
    What does the following piece of code do?   public Object function() { if(isEmpty()) return -999; else { Object high; high = q[front]; return high; } }
    • A. 

      Dequeue

    • B. 

      Enqueue

    • C. 

      Return the front statement

    • D. 

      None

  • 5. 
    1. What is the output of the following code?
    #include<stdio.h> int recursive_search_num(int *arr, int num, int idx, int len) {      if(idx == len)       return -1;      if(arr[idx] == num)       return idx;      return recursive_search_num(arr, num, idx+1, len); } int main() {       int arr[8] ={-11,2,-3,0,3,5,-6,7},num = -2,len = 8;       int indx = recursive_search_num(arr,num,0,len);       printf("Index of %d is %d",num,indx);       return 0; }
    • A. 

      Index of -2 is 1

    • B. 

      Index of -2 is 0

    • C. 

      Index of -2 is -1

    • D. 

      None

  • 6. 
    Which data structure can be used suitably to solve the Tower of Hanoi problem?
    • A. 

      Tree

    • B. 

      Heap

    • C. 

      Priority Queue

    • D. 

      Stack

  • 7. 
    What is the space complexity of the post-order traversal in the recursive fashion? (d is the tree depth and n is the number of nodes)
    • A. 

      O(1)

    • B. 

      O(nlogd)

    • C. 

      O(logd)

    • D. 

      O(d)

  • 8. 
    How many times is the recursive function called, when the following code is executed?   void my_recursive_function(int n) {      if(n == 0)      return;      printf("%d ",n);      my_recursive_function(n-1); } int main() {      my_recursive_function(10);      return 0; }
    • A. 

      9

    • B. 

      10

    • C. 

      11

    • D. 

      12

  • 9. 
    What is the output of the following code?   void my_recursive_function(int n) {     if(n == 0)     return;     printf("%d ",n);     my_recursive_function(n-1); } int main() {     my_recursive_function(10);     return 0; }
    • A. 

      10

    • B. 

      1

    • C. 

      10 9 8 ……. 1 0

    • D. 

      10 9 8 ……. 1

  • 10. 
    What is a dynamic array?
    • A. 

      A variable size data structure

    • B. 

      An array which is created at runtime

    • C. 

      The memory to array is allocated at runtime

    • D. 

      An array which is reallocated everytime whenever new elements have to be added

Back to Top Back to top