Skip to content

Files

Latest commit

0a1b753 · Oct 26, 2017

History

History

linked-list-find-length

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 26, 2017
Oct 26, 2017
Oct 26, 2017

README.md

LinkedList Find Length Source

What It Is

What It Is

For example, the function should return 5 for linked list [1 -> 3 -> 1 -> 2 -> 1]

Preview Thumbnail

METHOD 1 (Iterative Solution)

    1. Initialize count as 0
    1. Initialize a node pointer, current = head.
    1. Do following while current is not NULL a) current = current -> next b) count++;
    1. Return count
  • Input: Linked List = [1 -> 3 -> 1 -> 2 -> 1]
  • Output: count of nodes is 5

Algorithm Complexity

Complexity Notation
Time Complexity O(n)