Data Structure Quiz! Exam

By Harish Sharma
Harish Sharma, Computer Science
Harish is an experienced Computer Science Faculty with expertise in Artificial Intelligence, Data Structures, Image Processing, Information Retrieval, and Research. He holds a BTech in Computer Science and Engineering and a Master of Technology in ICT with a specialization in Machine Intelligence.
Quizzes Created: 2 | Total Attempts: 288
, Computer Science
Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
Questions: 10 | Attempts: 164

SettingsSettingsSettings
Data Structure Quiz! Exam - Quiz

.


Questions and Answers
  • 1. 

    Assume a linked list has been created and the start pointer is referring the first node of that linked list. Select the following code that can add a new node that addresses hold by temp pointer, at beginning of that linked list.

    • A.

      Temp->link=start; start=temp;

    • B.

      Start=temp; temp->link=start;

    • C.

      Start=temp->link; temp=start;

    • D.

      Temp=start; temp=start->link

    Correct Answer
    A. Temp->link=start; start=temp;
    Explanation
    The correct answer is "temp->link=start; start=temp;". This code first assigns the link of the new node to the start pointer, effectively making the new node point to the previous first node. Then, it assigns the start pointer to the new node, making the new node the first node of the linked list.

    Rate this question:

  • 2. 

    Insertion of a node at the beginning of the singly linked list involves modification of?

    • A.

      One pointer

    • B.

      Two pointer

    • C.

      Three pointer

    • D.

      Nothing

    Correct Answer
    B. Two pointer
    Explanation
    When inserting a node at the beginning of a singly linked list, two pointers need to be modified. The first pointer is the new node's next pointer, which needs to point to the current first node of the list. The second pointer is the head pointer of the list, which needs to be updated to point to the new node, making it the new first node of the list. By modifying these two pointers, the new node is successfully inserted at the beginning of the linked list.

    Rate this question:

  • 3. 

    Assume a linked list referred by start pointer. which of the following set of statements will result in the deletion of a node at position pos.

    • A.

      If(pos==1) start=start->link; else { t1=start; for(int i=2;ilink; } t1->link=t1->link->link; }

    • B.

      If(pos==1) start=start->link; else { t1=start; for(int i=1;ilink; } t1->link=t1->link->link; }

    • C.

      If(pos==1) start=start->link; else { t1=start; for(int i=1;ilink; } t1=t1->link; }

    • D.

      If(pos==1) start=start->link; else { t1=start; for(int i=1;ilink; } t1->link=t1; }

    Correct Answer
    A. If(pos==1) start=start->link; else { t1=start; for(int i=2;ilink; } t1->link=t1->link->link; }
    Explanation
    The given set of statements will result in the deletion of a node at position pos. If pos is equal to 1, then the start pointer is updated to point to the second node, effectively deleting the first node. Otherwise, a temporary pointer t1 is set to the start pointer, and a loop is executed until the desired position is reached. Inside the loop, t1 is updated to point to the previous node before the node to be deleted, and then the link of the previous node is updated to skip the node to be deleted. This effectively deletes the node at the specified position.

    Rate this question:

  • 4. 

    Given a pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?

    • A.

      Possible if size of linked list is even

    • B.

      Possible if size of linked list is odd

    • C.

      Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.

    • D.

      Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.

    Correct Answer
    A. Possible if size of linked list is even
    Explanation
    The given answer states that it is possible to delete the node X from the linked list if the size of the linked list is even. This means that if the number of nodes in the linked list is divisible by 2, we can delete the node X. However, if the size of the linked list is odd, we cannot delete the node X using this method. Additionally, the answer also suggests a two-step process to delete the node X if it is not the last node or the first node in the linked list.

    Rate this question:

  • 5. 

    Which of the following points is/are true about Linked List data structure when it is compared with array

    • A.

      Arrays have better cache locality that can make them better in terms of performance

    • B.

      It is easy to insert and delete elements in Linked List

    • C.

      Random access is not allowed in a typical implementation of Linked Lists

    • D.

      All of the mentioned

    Correct Answer
    D. All of the mentioned
    Explanation
    The given answer is correct because all of the mentioned points are true about the comparison between Linked List and array data structures. Arrays have better cache locality, meaning that accessing elements in an array is faster compared to accessing elements in a Linked List. It is indeed easier to insert and delete elements in a Linked List because it involves changing pointers, whereas in an array, elements need to be shifted. Lastly, random access is not allowed in a typical implementation of Linked Lists, meaning that to access an element, we need to traverse the list from the beginning.

    Rate this question:

  • 6. 

    What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6 void fun(struct node* start) {  if(start==NULL)   return;   while(start->link!=NULL)   {   printf("%d ",(start->link)->info);   start=start->link;   }  }

    • A.

      1 2 3 4 5 6

    • B.

      2 3 4 5 6

    • C.

      2 3 4 5

    • D.

      1 2 3 4 5

    Correct Answer
    B. 2 3 4 5 6
    Explanation
    The given function starts from the first node of the linked list and prints the info value of each node's next node until it reaches the last node. In this case, the output will be "2 3 4 5 6" because it starts from the first node (which has info value of 1) and prints the info value of each node's next node (2, 3, 4, 5, 6) until it reaches the last node.

    Rate this question:

  • 7. 

    What is the change in the linked list after the execution of the following code? start:- points to first node of linked start->info=start->link->info;

    • A.

      The values of first node and second node will be same

    • B.

      The value of first node will be copied into second node

    • C.

      The value of three node will be copied into first node

    • D.

      No change

    Correct Answer
    A. The values of first node and second node will be same
    Explanation
    After the execution of the given code, the value of the first node in the linked list will be copied into the second node. Therefore, the values of the first node and second node will be the same.

    Rate this question:

  • 8. 

    Linked is a ......

    • A.

      Linear data structure

    • B.

      Non linear data structure

    • C.

      Dynamic data structure

    • D.

      None

    Correct Answer
    A. Linear data structure
    Explanation
    The given correct answer is "Linear data structure." A linear data structure is a type of data structure where elements are arranged in a sequential manner, with each element having a unique predecessor and successor, except for the first and last elements. Examples of linear data structures include arrays, linked lists, stacks, and queues. In contrast, non-linear data structures, such as trees and graphs, do not have a sequential arrangement. Dynamic data structure refers to a data structure that can change in size during runtime, which is not mentioned in the question.

    Rate this question:

  • 9. 

    You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

    • A.

      Delete the first element

    • B.

      Insert a new element as a first element

    • C.

      Delete the last element of the list

    • D.

      Add a new element at the end of the list

    Correct Answer
    C. Delete the last element of the list
    Explanation
    The operation of deleting the last element of the list is dependent on the length of the linked list. This is because in order to delete the last element, we need to traverse the entire list until we reach the second-to-last node and update its next pointer to null. The length of the list determines the number of nodes we need to traverse in order to reach the second-to-last node.

    Rate this question:

  • 10. 

    Binary search is possible in Linked list.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Binary search is not possible in a linked list because unlike an array, a linked list does not provide constant time access to elements based on their index. In a linked list, elements are accessed sequentially by following the links between nodes. Binary search relies on random access to elements, which is not supported by a linked list. Therefore, it is not possible to perform binary search efficiently in a linked list.

    Rate this question:

Harish Sharma |Computer Science |
Harish is an experienced Computer Science Faculty with expertise in Artificial Intelligence, Data Structures, Image Processing, Information Retrieval, and Research. He holds a BTech in Computer Science and Engineering and a Master of Technology in ICT with a specialization in Machine Intelligence.

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 30, 2017
    Quiz Created by
    Harish Sharma
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.