This quiz works best with JavaScript enabled. Home > Cbse > Class 12 > Science > Computer Science > Class 12 Computer Science Chapter 1 Data Structures Using Python – Quiz 1 🏠 Homepage 📘 Download PDF Books 📕 Premium PDF Books Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 1 (60 MCQs) Quiz Instructions Select an option to see the correct answer instantly. 1. Consider the usual algorithm for determining whether a sequence of parentheses is balanced.Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation? A) 4. B) 2. C) 6. D) 3. Show Answer Correct Answer: B) 2. 2. Array can be classified in how many types? A) 1. B) 3. C) 2. D) More than 4. Show Answer Correct Answer: C) 2. 3. ..... is very useful in situation when data have to stored and then retrieved in reverse order. A) Link list. B) Stack. C) Queue. D) List. Show Answer Correct Answer: B) Stack. 4. What is the time complexity of deleting from the rear end of the dequeue implemented with a singly linked list? A) O(n). B) O(n$^{2}$). C) O(nlogn). D) O(logn). Show Answer Correct Answer: A) O(n). 5. What is the advantage of using a priority queue over a regular queue? A) Priority queues are faster for all operations. B) It allows elements to be processed based on their priority rather than their order of arrival. C) Priority queues are more memory-efficient. D) Priority queues do not require sorting. Show Answer Correct Answer: B) It allows elements to be processed based on their priority rather than their order of arrival. 6. What will this code do? colors[1] = "yellow" A) Change the second item in the list. B) Add a new value to the front. C) Do nothing. D) Remove the first item. Show Answer Correct Answer: A) Change the second item in the list. 7. How do you access elements in a tuple? A) Use curly braces to access elements, e.g., tuple name{index}. B) Access elements using parentheses, e.g., tuple name(index). C) Use indexing with square brackets, e.g., tuple name[index]. D) Elements can only be accessed by iterating through the tuple. Show Answer Correct Answer: C) Use indexing with square brackets, e.g., tuple name[index]. 8. What is the difference between a list and a dictionary? A) A list can only contain numbers; a dictionary can contain any data type. B) A list is unordered; a dictionary is an ordered collection of items. C) A list is a collection of key-value pairs; a dictionary is an ordered collection of items. D) A list is an ordered collection of items; a dictionary is a collection of key-value pairs. Show Answer Correct Answer: D) A list is an ordered collection of items; a dictionary is a collection of key-value pairs. 9. How do you check if a variable is equal to a specific value using if-else? A) If (value == variable) { // code for true } else { // code for false }. B) If (variable != value) { // code for true } else { // code for false }. C) If (variable = value) { // code for true } else { // code for false }. D) If (variable == value) { // code for true } else { // code for false }. Show Answer Correct Answer: D) If (variable == value) { // code for true } else { // code for false }. 10. For the 'Calculating Percent Markup' activity, what validation should the function include? A) Check that inputs are positive numbers. B) Ensure inputs are strings. C) Confirm inputs are less than 100. D) Verify inputs are whole numbers only. Show Answer Correct Answer: A) Check that inputs are positive numbers. 11. How do you append an element to a list in Python? A) Use the add() function:my list.add(element). B) Combine lists with my list += [element]. C) Use the append() method:my list.append(element). D) Insert the element with my list.insert(element). Show Answer Correct Answer: C) Use the append() method:my list.append(element). 12. B-tree and AVL tree have the same worst case time complexity for insertion and deletion. A) A) True. B) B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) A) True. 13. What is a two-dimensional array visualized as? A) A table. B) A line. C) A cube. D) A graph. Show Answer Correct Answer: A) A table. 14. What is the time complexity to insert an element to the front of a LinkedList(head pointer given)? A) O(n log n). B) O(n). C) O(1). D) O(log n). Show Answer Correct Answer: C) O(1). 15. Root has more left descendants than the right descendants or vice versa. A) Unbalanced Tree. B) Balanced Tree. C) Right Tree. D) Perfect Tree. Show Answer Correct Answer: A) Unbalanced Tree. 16. Which data structure is suitable for implementing a breadth-first search algorithm? A) Queue. B) Stack. C) Heap. D) Linked list. Show Answer Correct Answer: A) Queue. 17. Which of the following is not an advantage of trees? A) Faster search. B) Router algorithms. C) Hierarchical structure. D) Undo/Redo operations in a notepad. Show Answer Correct Answer: D) Undo/Redo operations in a notepad. 18. What is the purpose of the del statement in Python? A) Deletes any items from a tuple. B) Deletes items from a list based on element value. C) Deletes items from a dictionary based on value. D) Deletes items from a List based on index position. Show Answer Correct Answer: D) Deletes items from a List based on index position. 19. In a graph if E=(u, v) means ..... A) U is adjacent to v but v is not adjacent to u. B) E begins at u and ends at v. C) U is processor and v is successor. D) Both b and c. Show Answer Correct Answer: D) Both b and c. 20. Pushing an element into stack already having five elements and stack size of 5, then stack becomes A) Crash. B) Overflow. C) Underflow. D) User flow. Show Answer Correct Answer: B) Overflow. 21. Which of the following is the disadvantage of the array? A) Index of the first element in an array can be negative. B) Stack and Queue data structures can be implemented through an array. C) Wastage of memory if the elements inserted in an array are lesser than the allocated size. D) Elements can be accessed sequentially. Show Answer Correct Answer: C) Wastage of memory if the elements inserted in an array are lesser than the allocated size. 22. What are the main differences between a list and a set in Python? A) Sets allow duplicates and maintain order; lists do not allow duplicates and are unordered. B) Lists do not allow duplicates and are unordered; sets allow duplicates and maintain order. C) Lists are unordered and allow duplicates; sets maintain order and allow duplicates. D) Lists allow duplicates and maintain order; sets do not allow duplicates and are unordered. Show Answer Correct Answer: D) Lists allow duplicates and maintain order; sets do not allow duplicates and are unordered. 23. What is a tuple? A) A key-value store. B) An ordered, unchangeable collection. C) An unordered, changeable collection. D) A unique-value collection. Show Answer Correct Answer: B) An ordered, unchangeable collection. 24. Main Operations in Stacks are Called A) Insertion and deletion. B) Push and Pop. C) Append and insertion. D) Append and pop. Show Answer Correct Answer: B) Push and Pop. 25. Three standards ways of traversing a binary tree T with root R ..... A) Pre-traversal, in-traversal, post-traversal. B) Pre-process, in-process, post-process. C) Prefix, infix, postfix. D) Pre-order, in-order, post-order. Show Answer Correct Answer: D) Pre-order, in-order, post-order. 26. Scores = [5, 7, 0, 10, 8, 3, 7, 3]Which value will be found using the following statement:print(scores[2]) A) 5. B) 10. C) 7. D) 0. Show Answer Correct Answer: D) 0. 27. What is the significance of the head and tail in a linked list? A) The head is used for sorting, while the tail manages memory allocation. B) The head points to the middle, and the tail connects to the previous node. C) The head stores the last element, and the tail holds the first element. D) The head is the starting point for traversal, and the tail indicates the end of the list. Show Answer Correct Answer: D) The head is the starting point for traversal, and the tail indicates the end of the list. 28. What is the purpose of the 'with' statement in Python? A) The 'with' statement is used to handle exceptions in Python. B) The 'with' statement simplifies exception handling by encapsulating common preparation and cleanup tasks. C) The 'with' statement is used to define a function in Python. D) The 'with' statement is used to create a new thread in Python. Show Answer Correct Answer: B) The 'with' statement simplifies exception handling by encapsulating common preparation and cleanup tasks. 29. What will be the output of this program?a = 2**3*5+(10-1)*9 A) 351. B) 41. C) Error. D) 121. Show Answer Correct Answer: D) 121. 30. Name and explain two common sorting algorithms. A) Radix Sort and Shell Sort. B) Insertion Sort and Merge Sort. C) Bubble Sort and Quick Sort. D) Heap Sort and Selection Sort. Show Answer Correct Answer: C) Bubble Sort and Quick Sort. 31. What is the output of the following code:for i in range(5):print(i)? A) 01234. B) -1. C) 10. D) 5. Show Answer Correct Answer: A) 01234. 32. What does the following code do? public Object function() { if(isEmpty()) return-999; else { Object high; high = q[front]; return high; } } A) Dequeue. B) Return the front element. C) Return the last element. D) Enqueue. Show Answer Correct Answer: B) Return the front element. 33. How do you create a tuple? A) You create a tuple by using angle brackets, e.g., <1, 2, 3>. B) You create a tuple by using square brackets, e.g., [1, 2, 3]. C) You create a tuple by using curly braces, e.g., {1, 2, 3}. D) You create a tuple by using parentheses, e.g., (1, 2, 3). Show Answer Correct Answer: D) You create a tuple by using parentheses, e.g., (1, 2, 3). 34. In the 'Counting Words in a sentence' activity using len(), what preprocessing step would be most important? A) Remove all punctuation marks. B) Count only alphabetic characters. C) Convert all letters to lowercase. D) Split the sentence into individual words. Show Answer Correct Answer: D) Split the sentence into individual words. 35. How can we initialize an array in C language? A) Int arr(2)={10, 20} ;. B) Int arr(2) = (10, 20) ;. C) Int arr[2] = {10, 20};. D) Int arr[2]=(10, 20);. Show Answer Correct Answer: C) Int arr[2] = {10, 20};. 36. A map can contain duplicate keys. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: B) False. 37. In algorithm comment use by ..... brackets. A) Curley. B) Secure. C) None of the above. D) Both of the above. Show Answer Correct Answer: B) Secure. 38. How can you remove an item from a dictionary? A) Use 'dict.clear()'. B) Use 'dict.delete(key)'. C) Use 'del dict[key]' or 'dict.pop(key)'. D) Use 'dict.remove(key)'. Show Answer Correct Answer: C) Use 'del dict[key]' or 'dict.pop(key)'. 39. Queue uses ..... for adding and deleting elements. A) Top. B) Front. C) Rear. D) 2 and 3. Show Answer Correct Answer: D) 2 and 3. 40. Which of the following represents the Postorder Traversal of a Binary Tree? A) Right $\rightarrow$ Left $\rightarrow$ Root. B) Left $\rightarrow$ Root $\rightarrow$ Right. C) Left $\rightarrow$ Right $\rightarrow$ Root. D) Right $\rightarrow$ Root $\rightarrow$ Left. Show Answer Correct Answer: C) Left $\rightarrow$ Right $\rightarrow$ Root. 41. What is an AVL tree? A) A tree that has utmost two children. B) A tree that has utmost three children. C) A binary search tree and height-balanced tree. D) A binary search tree but an unbalanced tree. Show Answer Correct Answer: C) A binary search tree and height-balanced tree. 42. Which of the following operations is used to add an element to a queue? A) Enqueue. B) Dequeue. C) Peek. D) Pop. Show Answer Correct Answer: A) Enqueue. 43. How do you add a new key-value pair to a dictionary? A) Use 'dictionary.insert(key, value)' to add a key-value pair. B) Use 'dictionary[key] = value' to add a new key-value pair. C) Set 'dictionary.add(key, value)' to include a new entry. D) Use 'add(key, value)' method to insert a new pair. Show Answer Correct Answer: B) Use 'dictionary[key] = value' to add a new key-value pair. 44. Every stack has a variable ..... associated with it. A) TOP. B) BOT. C) POT. D) None of the above. Show Answer Correct Answer: A) TOP. 45. Arranging the books in order and removing from the topmost book is an example for ..... A) Queue. B) Linked List. C) Structure. D) Stack. Show Answer Correct Answer: D) Stack. 46. The format identifier '%i' is also used for ..... data type. A) Double. B) Char. C) Int. D) Float. Show Answer Correct Answer: C) Int. 47. Which of the following statements are not correct with respect to Singly Linked List(SLL) and Doubly Linked List(DLL)? A) Complexity of Insertion and Deletion at known position is O(n) in SLL and O(1) in DLL. B) SLL uses lesser memory per node than DLL. C) DLL has more searching power than SLL. D) Number of node fields in SLL is more than DLL. Show Answer Correct Answer: D) Number of node fields in SLL is more than DLL. 48. A container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. A) Element. B) Array. C) Index. D) None of the above. Show Answer Correct Answer: B) Array. 49. The examples of Linear Data Structures are A) Tree, graph. B) Int, float, complex. C) Stacks, Queues, Linked list. D) Operators, tokens, punctuators. Show Answer Correct Answer: C) Stacks, Queues, Linked list. 50. Which type of array is the following example?score = [5, 7, 0, 10, 8, 3, 7, 3] A) 2D. B) 3D. C) 4D. D) 1D. Show Answer Correct Answer: D) 1D. 51. In which situation would you use a stack for evaluating an expression? A) To evaluate a postfix expression. B) To evaluate an infix expression. C) To evaluate a prefix expression. D) All of the above. Show Answer Correct Answer: A) To evaluate a postfix expression. 52. What is meant by 'declaring' an array? A) Create an array in a program, specifying its name and size. B) Creating a program, specifying its size. C) Create a program, specifying its name. D) Create an array to assign to a Selection process. Show Answer Correct Answer: A) Create an array in a program, specifying its name and size. 53. What kind of linked list is best to answer question like "What is the item at position n?" A) Singly linked list. B) Circular linked list. C) Array implementation of linked list. D) Doubly linked list. Show Answer Correct Answer: C) Array implementation of linked list. 54. In algorithm variable names should be in capital letters. A) True. B) False. C) All the above. D) None of the above. Show Answer Correct Answer: A) True. 55. Describe the characteristics of a stack data structure. A) A stack is characterized by LIFO order, operations like push and pop, and can be implemented using arrays or linked lists. B) A stack can only be implemented using hash tables or trees. C) A stack allows random access to elements like an array. D) A stack is characterized by FIFO order and only allows peek operations. Show Answer Correct Answer: A) A stack is characterized by LIFO order, operations like push and pop, and can be implemented using arrays or linked lists. 56. How do you convert a list to a set? A) List(your list). B) Set(your list). C) Convert(your list). D) Array(your list). Show Answer Correct Answer: B) Set(your list). 57. What operation would you use to add an element to a queue in Python? A) Add or insert. B) Store or save. C) Put or append. D) Enqueue or push. Show Answer Correct Answer: C) Put or append. 58. Which of the following is false about a binary search tree? A) The left child is always lesser than its parent. B) The right child is always greater than its parent. C) The left and right sub-trees should also be binary search trees. D) In order sequence gives decreasing order of elements. Show Answer Correct Answer: D) In order sequence gives decreasing order of elements. 59. Which data structure in Python is used to store key-value pairs? A) Set. B) Tuple. C) List. D) Dictionary. Show Answer Correct Answer: D) Dictionary. 60. How do you remove a key-value pair from a dictionary? A) Use 'dict.remove(key)'. B) Use 'del dict[key]' or 'dict.pop(key)'. C) Use 'key.remove(dict)'. D) Use 'dict.delete(key)'. Show Answer Correct Answer: B) Use 'del dict[key]' or 'dict.pop(key)'. Next →Related QuizzesScience QuizzesClass 12 QuizzesClass 12 Computer Science Chapter 1 Data Structures Using Python Quiz 2Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 3Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 4Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 5Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 6Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 7Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 8Class 12 Computer Science Chapter 1 Data Structures Using Python Quiz 9 🏠 Back to Homepage 📘 Download PDF Books 📕 Premium PDF Books