MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / countNodes

Function countNodes

CPP/LINKED LIST/Linked_list.cpp:54–66  ·  view source on GitHub ↗

time : O(n) space : O(1)

Source from the content-addressed store, hash-verified

52// time : O(n)
53// space : O(1)
54int countNodes(struct Node *p)
55{
56 // while address of next block is not null
57 int count = 0;
58
59 while (p != NULL)
60 {
61 count++;
62 p = p->next;
63 }
64
65 return count;
66}
67
68void insert(struct Node *p, int index, int data)
69{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected