Monday, March 6, 2023

Primitive&Non-primitive-Data-types

    Data structures are the building blocks of algorithms and computer programs, the primitive -- or base -- data types are the building blocks of data structures. The typical base data types include the following:

·         Boolean, Its store's logical values that are either true or false.


·         integer, which stores an ambition on mathematical integers -- or counting numbers. Different-sized integers hold different ambitions of values -- e.g., a signed 8-bit integer holds values from -128 to 127, and an unsigned long 32-bit integer holds values from 0 to 4,294,967,295.

·         Floating-point numbers, it is store a formulaic representation of real numbers.

·         Fixed-point numbers, which are used in some programming languages and hold real values but are executed as digits to the left and the right of the decimal point.

·         Character, it is uses symbols from a defined mapping of integer values to symbols.

·         Pointers, there are reference values that point to other values.

·         String, it is an array of characters followed by a stop code -- usually a "0" value -- or is execute using a length field that is an integer value.

The data structure hierarchy shows how data types and data structures are related.

Types of data structures

The data structure type used in a particular situation is constant by the type of operations that will be required or the kinds of algorithms that will be applied. The changeable data structure types include the following:



·         Array array stores a collection of items at adjoining memory locations. Items there are the same type are stored stably so the position of each element can be calculated or restored easily by an index. Arrays can be established or flexible in length.

An array can hold a collection of integers, floating-point numbers, wounds or even other arrays.

·         Stack.  Stack is a linear data structure. the stack stores an acquiring of items in the linear order that operations are applied. The order  may be LIFO(last in first out)

·         Queue queue from the Latin word means a line of people or vehicles waiting their turn.it stores a collection of items like a stack; however, the operation order can only be first in, first out.

·         Linked list. A linked list stores a collection of items in a linear order. Each element, or node, in a linked list contains data things, as well as a reference, or link, to the next item in the list

·         Tree. A tree stores an acquiring of things in a complex, hierarchical way. And other node is associated with a key value, with parent nodes linked to child nodes -- or subnodes. They  have one root node that is the ancestor of all the nodes in the tree.

Heap.    A heap is a tree-based structure in which each parent node's associated key value is greater than or equal to the key values of any of its children's key values.

·         Graph. A graph stores a collection of things in a nonlinear fashion. And the Graphs are made up of a finite set of nodes, also called vertices, and lines that connect them, also known as edges. They have useful for representing real-world systems such as computer networks.

·         Trie. A trie, also known as a keyword tree, is a data structure that stores strings as data things that can be organized in a visible graph.

·         Hash table. A hash table -- also known as a hash map -- stores an acquiring of things  in an associative array that plots keys to values. A hash table uses a hash function. It converts an index into an array of buckets that contain the desired data item.

These are considered complex data structures as they can store large amounts of interconnected data.

How to choose a data structure

Some  examples include:

·         Linked lists are best if a program is managing a collection of items that don't need to be ordered, constant time is required for adding or removing an item from the acquiring and increased search time is OK.

·         Stacks are best if the program is managing an acquisition that needs to support a LIFO order.

·         Queues should be used if the program is managing an acquisition that needs to support a FIFO order.

·         Binary trees are good for managing the acquiring of items with a parent-child relationship, such as a family tree.

·         Binary search trees are applicable for managing a sorted acquiring where the goal is to optimize the time it takes to find specific items in the acquiring.

·         Graphs work best if the application will analyze connectivity and relationships mid-acquiring of exclusives in a social media network.

This was last updated in March 2021

 

No comments:

Post a Comment