Skip to document
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

Primitive vs nonprimitive data structures

COMPARISON BETWEEN PRIMITIVE AND NONPRIMITIVE DATA STRCUTURES IN TABULAR FORM
Course

Btech (kcs-701)

478 Documents
Students shared 478 documents in this course
Academic year: 2021/2022
Uploaded by:
Anonymous Student
This document has been uploaded by a student, just like you, who decided to remain anonymous.
Rajasthan Technical University

Comments

Please sign in or register to post comments.

Preview text

Primitive vs non-primitive data structure

Data structure means organizing the data in the memory. The data can be organized in two ways either linear or non-linear way.

There are two types of data structure available for the programming purpose:

o Primitive data structure

o Non-primitive data structure

Primitive data structure is a fundamental type of data structure that stores the data of only one type whereas the non-primitive data structure is a type of data structure which is a user-defined that stores the data of different types in a single entity.

In the above image, we can observe the classification of the data structure. The data structure is classified into two types, i., primitive and non-primitive data structure. In the case of primitive data structure, it contains fundamental data types such as integer, float, character, pointer, and these fundamental data types can hold a single type of value. For example, integer variable can hold integer type of value, float variable can hold floating type of value, character variable can hold character type of value whereas the pointer variable can hold pointer type of value.

In the case of non-primitive data structure, it is categorized into two parts such as linear data structure and non-linear data structure. Linear data structure is a sequential type of data structure, and here sequential

means that all the elements in the memory are stored in a sequential manner; for example, element stored after the second element would be the third element, the element stored after the third element would be the fourth element and so on. We have different linear data structures holding the sequential values such as Array, Linked list, Stack, Queue.

Non-linear data structure is a kind of random type of data structure. The non-linear data structures are Tree and Graph.

Let's understand the differences between the primitive and non- primitive data structure.

Primitive data structure Non-primitive data structure

Primitive data structure is a kind of data structure that stores the data of only one type.

Non-primitive data structure is a type of d structure that can store the data of more tha one type.

Examples of primitive data structure are integer, character, float.

Examples of non-primitive data structure Array, Linked list, stack.

Primitive data structure will contain some value, i., it cannot be NULL.

Non-primitive data structure can consist o NULL value.

The size depends on the type of the data structure.

In case of non-primitive data structure, size not fixed.

It starts with a lowercase character. It starts with an uppercase character.

Primitive data structure can be used to call the methods.

Non-primitive data structure cannot be use call the methods.

Primitive data structure

Primitive data structure is a data structure that can hold a single value in a specific location whereas the non-linear data structure can hold multiple values either in a contiguous location or random locations

o String: String is defined as an array of characters. The difference between the character array and string is that the string data structure terminates with a 'NULL' character, and it is denoted as a '\0'.

String data structure:

  1. char name[100] = "Hello javaTpoint";

In the above example, the length of the string is 17 as the last character is the NULL character which denotes the termination of the string.

Char Representation:

  1. char name[100] = {'H', 'e', 'l','l','o',' ', 'j', 'a', 'v', 'a', 't','p', 'o', 'i', 'n',

't' }

In the above example, the length of the string is 16 as it does not have any NULL character as the last character to denote the termination.

o Stack: Stack is a data structure that follows the principle LIFO (Last In First Out). All the operations on the stack are performed from the top of the stack such as PUSH and POP operation. The push operation is the process of inserting element into the stack while the pop operation is the process of removing element from the stack. The stack data structure can be implemented by using either array or linked list. o Queue: Queue is a data structure that can be implemented by using array. The difference between the stack and queue data structure is that the elements in the queue are inserted from the rear end while the elements in the queue are removed from the front end.

Was this document helpful?
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

Primitive vs nonprimitive data structures

Course: Btech (kcs-701)

478 Documents
Students shared 478 documents in this course
Was this document helpful?

This is a preview

Do you want full access? Go Premium and unlock all 4 pages
  • Access to all documents

  • Get Unlimited Downloads

  • Improve your grades

Upload

Share your documents to unlock

Already Premium?
Primitive vs non-primitive data structure
Data structure means organizing the data in the memory. The data can be
organized in two ways either linear or non-linear way.
There are two types of data structure available for the programming
purpose:
oPrimitive data structure
oNon-primitive data structure
Primitive data structure is a fundamental type of data structure that stores
the data of only one type whereas the non-primitive data structure is a
type of data structure which is a user-defined that stores the data of
different types in a single entity.
In the above image, we can observe the classification of the data
structure. The data structure is classified into two types, i.e., primitive and
non-primitive data structure. In the case of primitive data structure, it
contains fundamental data types such as integer, float, character, pointer,
and these fundamental data types can hold a single type of value. For
example, integer variable can hold integer type of value, float variable can
hold floating type of value, character variable can hold character type of
value whereas the pointer variable can hold pointer type of value.
In the case of non-primitive data structure, it is categorized into two parts
such as linear data structure and non-linear data structure. Linear data
structure is a sequential type of data structure, and here sequential

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.