Data types 1. Primitive: is a data type provided by a programming language as a basic building block 2. Composite: is any data type which can be constructed in a program using its programming language's primitive data types and other composite types 3. Abstract: is a mathematical model for a certain class of data structures that have similar behavior; or for certain data types of one or more programming languages that have similar semantics
TEN COMPONENTS OF DATA STRUCTURE A. Array
Arrays are one of the simplest and most widely used data structures in computer programs. Arrays in any programming language all share a few common properties: • The contents of an array are stored in contiguous memory. • All of the elements of an array must be of the same type or of a derived type; hence arrays are referred to as homogeneous data structures. • Array elements can be directly accessed. With arrays if you know you want to access the ith element, you can simply use one line of code: arrayName[i].
The common operations performed on arrays are: • Allocation • Accessing
An array holds several values of the same kind. Accessing the elements is very fast. It may not be possible to add more values than defined at the start, without copying all values into a new array.
B. List
A List can hold several values. Each item in the list has a way of telling where the next element is; some lists can also tell where the previous element is. It is very easy to add a new element at the start of the list; telling whether an element is already in the list is more difficult, and needs going through all elements of a list.
Here are all of the methods of list objects: list.append(x) Add an item to the end of the list; equivalent to a[len(a):] = [x]. list.extend(L)
Extend the list by appending all the items in the given list; equivalent toa[len(a):] = L.
list.insert(i,