answersLogoWhite

0


Best Answer

It depends on whether the nodes are in a list, a binary tree, a heap, or some other structure. If the nodes are in an unsorted list, then the simplest solution would be to build a frequency table (requiring a single traversal of the list), and then list all the table elements that have a frequency greater than 1. If the list is sorted, then duplicate nodes will always be found side-by-side, thus you can quickly enumerate them without the need of a frequency table unless you wished to store the results for further analysis.

Similar procedures can be done with other structures. For instance, sorted binary trees in ascending order will have equal nodes to the right of a parent node (greater than or equal to). Regardless, you must traverse the entire structure in order to determine the frequency of each node, and thus the frequency of duplicate nodes.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Counting the occurrence of duplicate nodes in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Calculate even numbers of nodes in link list in c plus plus?

The number of even nodes in any list is always half size of the list rounded down to the nearest integer. To round down you simply take the integral portion of the division. E.g., for a list of 5 nodes, nodes 2 and 4 are the even nodes, therefore there are only 2 even nodes. Thus: 5 / 2 = 2.5 = 2. A list of 4 nodes also has 2 even nodes, thus 4 / 2 = 2.0 = 2.


What difference between two nodes in c plus plus of single link list?

Their address. They may also have different values, and their sequence may matter, depending on the design of the algorithm.


What is a header node in c plus plus?

A header node, or head node, is a node that marks the start of a series of nodes, usually as part of a list or queue structure. The head node is often a sentinal that holds no data of its own. Sentinels are used to simplify algorithms by ensuring that a list can never be empty, even when it has no data.


A full node is a node with two children Prove that the number of full nodes plus one is equal to the number of leaves in a binary tree?

Let N = the number of nodes, F = number of full nodes, L = the number of leaves, and H = the number of nodes with one child (or half nodes). The total number of nodes in a binary tree equals N = F + H + L. Because each full node is incident on two outgoing edges, each half node is incident on one outgoing edge, and each leaf is incident on no outgoing edge it follows that the total number of edges in a binary tree equals 2F + H. It is also true that the total number of edges in a tree equals N 1. Thus, 2F + H = N 1 H = N 1 2F Subbing this value of H into N = F + H + L gives, N = F + N 1 2F + L N N + 1 = F + L F + 1 = L


How do you write a C plus plus function lastLargestIndex that returns the index of the last occurrence of the largest element in the array?

int lastLargestIndex(int a[],int n) //a=array, n= number of elements in array { int max=a[0],maxp=0; //max=largest no., maxp= position of largest no. for(int i=0;i<n;i++) if(a[i]>=max) { max=a[i]; maxp=i; } return maxp; }

Related questions

How do you apply for the duplicate plus two mark sheet?

1993 puls two marksheet missing not copy how to get duplicate


Calculate even numbers of nodes in link list in c plus plus?

The number of even nodes in any list is always half size of the list rounded down to the nearest integer. To round down you simply take the integral portion of the division. E.g., for a list of 5 nodes, nodes 2 and 4 are the even nodes, therefore there are only 2 even nodes. Thus: 5 / 2 = 2.5 = 2. A list of 4 nodes also has 2 even nodes, thus 4 / 2 = 2.0 = 2.


Is counting plus 0 called an integers?

Yes it is.


How many episodes of 19 kids and counting?

Currently 177, plus specials.


How 2 plus 5 equals 11?

It does not - unless you are counting in base 11.


Does 2 plus 2 equals 10?

Only when you are counting in Base 4. When counting in Base 10, 2 + 2 would equal 4.


How do you make 7 plus 7 plus 7 plus 7 plus 7 plus 7 plus 7 plus 7 equals 1000?

You could try counting in base 561/3 = 3.825862 (approx).


When is this true 2 plus 2 equals 10?

When you are counting in base 4. Or possibly when the "plus" operation is defined in an unusual manner.


How can 5 plus 5 11?

It does if you are counting in base 9. 5 plus 5 equals 1 nine and a remainder of 1.


How to find a whole number?

The whole numbers include the counting numbers, plus zero.


What are the positive multiples of 10?

(Every counting number) plus (a zero tacked on to the end of it) is one of them.


What is a signed counting number?

It means that you add a sign (plus or minus).