DSA Series 1 : Answers for all 20 practice questions (C Edition & Python edition )



Answers for all 20 practice questions

(C Edition & Python edition )


Answers for 20 Practice Questions (Plain Text)

  1. O(1)

  2. O(n)

  3. O(n²)

  4. O(log n)

  5. Time: O(n log n), Space: O(n)

  6. Average: O(n log n), Worst: O(n²)

  7. O(1)

  8. O(n)

  9. O(n)

  10. O(n)

  11. Time: O(n), Space: O(n) (due to recursion stack)

  12. O(V + E)

  13. O(1) (if pointer to the node is given)

  14. O(1)

  15. O(n)

  16. O(1) amortized

  17. Nested loops: O(n²), Using hash table: O(n)

  18. O(n)

  19. O((V + E) log V)

  20. Adjacency matrix: O(V²), Adjacency list: O(V + E)


Comments