Computer Science and Defining Data
Programs in computers typically store data that is need later. This data needs to be stored in a structured way so that it can be reused in future. the data in a computer is retrieved, manipulated or deleted and computers therefore have this great capability to search through large amounts of data to obtain the correct results. Data structures enable optimal storage and retrieval or search of data. Programs store data in files for use in the future.
Items of data are stored in Data types to use for different purposes. For example, integers or whole numbers — are used for counting. Providing computer-based solutions to real-world problems must involve the appropriate use of data types.
Records are composite data types.
They are formed when several related items that may be of different data types are grouped into a single identifier. In its definition, a composite data type will refer to other existing data types.
Arrays are data structures.
Arrays are made up of several elements of the same data type. These elements are accessed through identifier names and the position of each element in the array is indexed from the lower bound to the upper bound. To put it in a different way, an array (one-dimensional) can be thought of as a 1 x n table. As logic dictates, a two-dimensional array will be a 2 x n table.
It is from data structures that Search or Sort algorithms are typically implemented.
Strategies:
- Linear Search
This is a strategy of searching an array whereby the array is checked in order, from the lower bound to the upper bound, until the item is found or the upper bound is reached.
2. Bubble Sort
This strategy sorts data into a meaningful order. Data is useful when data needs to be stored in a meaningful order. For example, names can be stored in alphabetical order for easier searching in a database. In a Bubble Sort algorithm, each element of the array is compared with the next element and swapped if the elements are in the wrong order. The Bubble Sort moves in a linear direction.
ABSTRACT DATA TYPES
An abstract data type is a collection of data and the set of operations for that data. For example, the items held in a stack and the operations to add or remove an item from the stack all make up an abstract data type.
Stack
A stack is a list containing many items operating on the Last In, First Out principle. Items can be added to the stack (push) and removed (pop) from the stack.
Queue
A queue is a list containing many items operating on the First In, First Out principle. Items can be added to the queue (enqueue) and removed (dequeue) from the queue.
Linked List
A linked list is a list containing many items in which each item in the list points to the next item in that list. They are implemented using 1D arrays and items are always added to the start of the list.