Welcome to the Basic Data Structures and Algorithms (DSA) Quiz in Python! This quiz is designed to test your understanding of fundamental data structures and algorithms concepts in Python. Whether you’re a beginner or looking to brush up on your skills, this quiz will help you solidify your knowledge of DSA using Python. Let’s dive in!

Question 1:

Which data structure follows the “Last-In-First-Out” (LIFO) principle?

a) Queue

b) Stack

c) Linked List

d) Tree

Question 2:

What is the time complexity of accessing an element by its index in an array?

a) O(1)

b) O(n)

c) O(log n)

d) O(n^2)

Question 3:

Which sorting algorithm has the best average-case time complexity?

a) Bubble Sort

b) Merge Sort

c) Insertion Sort

d) Selection Sort

Question 4:

Which data structure provides a way to store data in key-value pairs?

a) Array

b) Stack

c) Queue

d) Dictionary

Question 5:

What is the purpose of the “binary search” algorithm?

a) To find the maximum element in a list

b) To find the minimum element in a list

c) To search for a specific element in a sorted list efficiently

d) To sort a list in ascending order