2 Lecture
CS301
Midterm & Final Term Short Notes
List Implementation
List implementation refers to the process of creating a data structure that can store a sequence of elements, where each element is linked to the next one. This can be achieved using arrays or linked lists. Array-based lists use a fixed-size arr
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
Which data structure is used to implement a list? a) Array b) Stack c) Queue d) Tree Answer: a) Array
Which of the following is a disadvantage of array-based lists? a) Efficient random access to elements b) Dynamic resizing of the list c) Inefficient insertion and deletion operations d) No need to allocate memory in advance Answer: c) Inefficient insertion and deletion operations
Which of the following is a disadvantage of linked-list based lists? a) Efficient random access to elements b) Dynamic resizing of the list c) Inefficient insertion and deletion operations d) No need to allocate memory in advance Answer: a) Efficient random access to elements
Which of the following is true for an empty list? a) It has no elements b) It has one element c) It has multiple elements d) None of the above Answer: a) It has no elements
Which operation adds an element at the end of an array-based list? a) push() b) pop() c) insert() d) append() Answer: d) append()
Which operation adds an element at the beginning of a linked-list based list? a) push() b) pop() c) insert() d) append() Answer: a) push()
Which operation removes the last element from an array-based list? a) push() b) pop() c) insert() d) append() Answer: b) pop()
Which operation removes the first element from a linked-list based list? a) push() b) pop() c) insert() d) append() Answer: b) pop()
Which of the following is a common application of lists? a) Implementing a queue b) Implementing a hash table c) Implementing a binary search tree d) Implementing a heap Answer: a) Implementing a queue
Which of the following is not a type of list? a) Singly linked list b) Doubly linked list c) Circular linked list d) Heap linked list Answer: d) Heap linked list
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is an array-based list? Answer: An array-based list is a data structure that stores a collection of elements in a contiguous block of memory, where each element can be accessed using an index.
What is a linked-list based list? Answer: A linked-list based list is a data structure that stores a collection of elements as nodes, where each node contains an element and a reference to the next node in the list.
What is the difference between an array-based list and a linked-list based list? Answer: An array-based list uses a fixed-size array to store the elements, while a linked-list based list uses a dynamic data structure composed of nodes. The main difference is that arrays offer efficient random access to elements, while linked lists offer efficient insertion and deletion operations.
What is the time complexity of accessing an element in an array-based list? Answer: The time complexity of accessing an element in an array-based list is O(1).
What is the time complexity of accessing an element in a linked-list based list? Answer: The time complexity of accessing an element in a linked-list based list is O(n).
What is the advantage of using a linked-list based list over an array-based list? Answer: The main advantage of using a linked-list based list is that it offers efficient insertion and deletion operations, which can be expensive in an array-based list.
What is the disadvantage of using a linked-list based list over an array-based list? Answer: The main disadvantage of using a linked-list based list is that it offers inefficient random access to elements, which can be expensive in an array-based list.
What is dynamic resizing of a list? Answer: Dynamic resizing of a list refers to the ability of a list to grow or shrink in size as elements are added or removed.
How is dynamic resizing achieved in an array-based list? Answer: Dynamic resizing in an array-based list is achieved by allocating a new, larger array when the existing array becomes full, and copying the elements from the old array to the new array.
How is dynamic resizing achieved in a linked-list based list? Answer: Dynamic resizing in a linked-list based list is achieved by allocating new nodes as needed and updating the references between nodes.