Posted on by Kalkicode
Code Probability

Find probability of a key in linked list

Probability of node is calculate by number of occurrences of key divided by total number of nodes. For example.

Find probability of key in linked list
Linked List :   1  6  111  3  1  9  1  3  11  1  21
Given node value      : 1
Occurrences           : 4  [count occurrences]
Number of total nodes : 11 [count nodes]

Result  :  (occurrences/total nodes)
              (4/11)  = 0.363636

Here given code implementation process.


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment