The document contains answers to an Advanced Data Structures exam, divided into multiple choice and short answer sections. It covers topics such as array and linked list operations, abstract data types (ADTs), and graph representations including adjacency matrices and lists. Key concepts include time and space complexities, common operations on lists, and the significance of ADTs in software design.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
7 views
Advanced Data Structures Answers
The document contains answers to an Advanced Data Structures exam, divided into multiple choice and short answer sections. It covers topics such as array and linked list operations, abstract data types (ADTs), and graph representations including adjacency matrices and lists. Key concepts include time and space complexities, common operations on lists, and the significance of ADTs in software design.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Advanced Data Structures Exam Answers
Section A (Multiple Choice Questions)
1. Which of the following is not a disadvantage to the usage of array?
Answer: (d) Accessing elements at specified positions (Arrays allow constant time O(1) access to elements.) 2. What is the time complexity of inserting at the end in dynamic arrays? Answer: (d) Either O(1) or O(n) (It is O(1) in amortized cases and O(n) if resizing is required.) 3. What is the time complexity to count the number of elements in the linked list? Answer: (b) O(n) (A linked list must be traversed to count elements.) 4. Which of the following performs deletion of the last element in the list? Answer: (a) (It correctly traverses the list and updates the second last node’s next pointer to null.) 5. What is the functionality of the given function? Answer: (c) Inserting a node at the end of the list (It iterates to the last node and adds a new node at the end.) 6. What is the space complexity for deleting a linked list? Answer: (a) O(1) (Deleting nodes requires no extra space apart from constant references.) 7. How would you delete a node in the singly linked list? Answer: (a) (It correctly adjusts pointers to remove the node at the given position.) 8. Which of these is not an application of a linked list? Answer: (d) Random access of elements (Linked lists do not support constant-time random access like arrays.) 9. Which of the following piece of code has the functionality of counting the number of elements in the list? Answer: (a) (This correctly traverses the list while counting elements.) 10. How do you insert an element at the beginning of the list? Answer: (a) (This correctly updates the head and maintains the link to the existing list.)
Section B (Short Answer Questions)
1. What is a list in programming?
A list is a data structure that stores a sequence of elements, where elements can be added, removed, or modified dynamically. 2. What does ADT stand for? ADT stands for Abstract Data Type. 3. Name one common operation on lists. Insertion (Adding an element at the beginning, end, or a specific position.) 4. What are some examples of ADTs? o List o Stack o Queue o Deque o Set o Map 5. How does a list differ from an ADT? An ADT defines the behavior of a data structure, while a list is a specific implementation of an ADT. 6. What are some common operations performed on lists? o Insertion o Deletion o Traversal o Searching o Sorting 7. Why are ADTs important in software design? ADTs help in designing modular, reusable, and efficient code by providing clear abstraction without exposing implementation details. 8. How does the concept of homogeneity apply to lists? Homogeneity means that all elements in the list are of the same type (e.g., an array of integers). 9. What data structure is commonly used to implement lists? o Arrays (for array lists) o Linked Lists (for dynamic lists) 10. What is the purpose of the resize method in the array list implementation? The resize method dynamically increases the array size when it reaches capacity, allowing more elements to be stored.
Section C (Graph Representations)
Adjacency Matrix Construction
An Adjacency Matrix is a 2D array where:
Rows and columns represent nodes.
1 (or weight) indicates an edge between nodes, and 0 means no connection.
Adjacency List Construction
An Adjacency List represents the graph as:
A list of nodes, where each node has a list of its adjacent nodes.
For specific graph construction, provide the graph image or details.