Time and Space Complexities
Algorithms
Graphs and Trees
Linked Lists
Arrays and Strings
100

What is the time complexity of searching in an unsorted array?

O(n)

100

This sorting algorithm repeatedly compares adjacent elements and swaps them if they are in the wrong order.

Bubble Sort

100

This type of data structure has a root node and is made up of parent-child relationships with no cycles.

Tree

100

In a singly linked list, this is the term for the first node in the list.

Head

100

This type of search checks each element in an array one by one to find a target value.

Linear Search

200

Which of the following sorting algorithms has the best average time complexity?

- Merge Sort

- Bubble Sort

- Insertion Sort

- Selection Sort

Merge Sort

200

This searching algorithm works only on sorted arrays and repeatedly divides the search space in half.

Binary Search

200

This traversal method visits nodes in the order: left child, root, right child.

Inorder Traversal

200

In a doubly linked list, each node contains a reference to the next node and what additional reference?

A pointer to the previous node

200

This common string operation combines two strings into one.

Concatenation

300

What is the time complexity of inserting an element at the beginning of a linked list?

O(1)

300

This sorting algorithm divides the array into two halves, sorts each half, and then merges them together.

Merge Sort

300

In this type of graph, edges have a direction, meaning they go from one node to another in a specific way.

Directed Graph

300

In a linked list, this is the special value that indicates the end of the list when there are no more nodes.

Null (or None)

300

In many languages, strings cannot be changed after creation. What is this property called?

Immutability

400

You are given a function that iterates through an array of size n. Inside the loop, it performs a binary search on the same array. What is the overall time complexity of this function?

O(n log n)

400

This algorithm explores a graph by visiting all neighbors of a node before moving on to the next level.

BFS

400

This traversal uses a stack in its iterative implementation, exploring a branch until its end.

DFS

400

This type of linked list connects the last node back to the first node.

Circular Linked List

400

When inserting an element into the middle of an array, elements to the right must be shifted. This results in what time complexity?

O(n)

500

You are given a function that iterates through an array of size n. Inside the loop, it scans the entire array again to check for a condition. What is the overall time complexity?

O(n^2)

500

What are the two most efficient algorithms to find minimum spanning trees?

Prim's and Kruskal's
500

What is the Binary Search Tree property?

In a binary search tree, this property ensures that for every node, all values in the left subtree are smaller and all values in the right subtree are larger.

500

Compared to arrays, linked lists make which operation easier because no shifting of elements is required?

Insertion

500

Given the following array in python: arr = [0, 5, 4, 6], what is the result of arr[-2]

4