answersLogoWhite

0


Best Answer

A primary data structure is a data structure that is created without the use of other data structures, whereas a secondary data structure relies on a primary data structure. A data structure is an organized collection of data elements.

[NOTE: Be careful not to confuse the term data structure with the term data type. It is a common mistake. This answer addresses dat structures. Often people who ask about primary data structures or primitive data structures are really asking about primitve data types.]

Here is an example where an array is a primary data structure and a binary tree is a secondary data structure based on the array:

An array is a primary data structure -- it is a set of sequentially numbered data elements, such as an array of integers or an array of names -- name0, name, name2, ...

A binary tree is a data structure where each element (called a node) has a data component and pointers to it's left and right sub-trees. [Think of a directory of folders, but each folder can only have two sub-folders.] We can create an and store an array of nodes to set up the tree in languages like C++ or Java.

The root of the tree could be node 1 in the array, it would point to nodes 2 and 3. node 2 would point to nodes 4 and 5, while node 3 would point to nodes 6 and 7 .. and so on. generally node n point to nodes 2n and 2n+1. (You can start with node 0, but the math is a little easier if you start with node 1.)

The binary tree in this case is the secondary data structure, while the undelying array is the primary data structure.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are primary data structure?
Write your answer...
Submit
Still have questions?
magnify glass
imp