0

What is binary tree,node and linked list?

I currently learning OOP C++ but I cant seem to understand these few term and its coding. Can I have some simple example how these code work? Give me roughly idea please... Thanks

15th Mar 2017, 2:30 PM
Hoo Ds
Hoo Ds - avatar
2 odpowiedzi
+ 6
binary tree: a data structure represented as a tree with maximum of 2 child nodes it looks roughly like this: O root / \ node O O node / \ \ node O O leaf O leaf \ O leaf root - the starting node node - every one of those O is a node leaf - a node with no child nodes each node can store data values, it all depends on the implementation usually you would implement this using struct and pointers (in C/C++) or by making a node class with child nodes as references
15th Mar 2017, 5:35 PM
Burey
Burey - avatar
+ 4
linked list: a data structure where each element holds in addition to the data, a pointer to the next element in the linked list, hence, the name the last element points to NULL value, which indicates the end of the list. let data be some data variable, and p be pointer to an address |data|p| --> |data|p| --> |data|p| --> NULL an advantage of this approach is no wasted space as you do not need to declare an entire array, just enough for each node in the linked list. a clear downside is the access time, as for each access to a certain node, you have to search it by "riding" each element onto the next until reaching the searched value.
15th Mar 2017, 5:57 PM
Burey
Burey - avatar