πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      Consider a `LinkedList` data structure. Which control

      flow statement is most appropriate for iterating through all elements of the list from head to tail?Β 
      A A `do-while` loop that always executes at least once. Correct Answer Incorrect Answer
      B A `for` loop with a fixed number of iterations. Correct Answer Incorrect Answer
      C A `while` loop that continues as long as the current node is not `null`. Correct Answer Incorrect Answer
      D A `switch-case` statement based on node values. Correct Answer Incorrect Answer

      Solution

      Linked lists are typically traversed by starting at the head and moving to the `next` node until the `next` reference becomes `null`, indicating the end of the list. A `while` loop is perfectly suited for this condition-based iteration.

      Practice Next
      ask-question