Please enable JavaScript.
Coggle requires JavaScript to display documents.
CHAPTER 1: INTRODUCTION TO DATA STRUCTURES, Catherine, Mauldorna &…
CHAPTER 1: INTRODUCTION TO DATA STRUCTURES
UNDERSTAND DATA STRUCTURE
(slide 4 - 14)
Erika & Gibson
Primitive And Non-primitive
Non-primitive
*Non-primitive data types are not predefined and are developed by the programmer.
Structure
a specific data-organization and-storage format
Union
a value that can be represented or formatted in a variety of ways
Linked List
A linked list is a linear collection of data pieces called nodes, each of which has a pointer pointing to the next node.
Stacks
an ordered collection of data types that are similar
Queues
a data structure that resembles Stacks but is more abstract
Arrays
Each element (values or variables) in an array is identifiable by at least one array index or key.
Primitive
a data type that is built into a programming language, or one that could be characterized as a basic structure for building more sophisticated data types.
Integer : data type contains the numeric values. It contains the whole numbers that can be either negative or positive.
Float: The float is a data type that can hold decimal values. When the precision of decimal value increases then the Double data type is used.
Boolean: It is a data type that can hold either a True or a False value. It is mainly used for checking the condition.
Character: It is a data type that can hold a single character value both uppercase and lowercase such as 'A' or 'a'.
String :This is used to represent group of characters
JAZRIN
DEFINITION
(slide 4)
A data structure is a particular way of organizing data in a computer so that it can be used effectively. For example, we can store a list of items having the same data-type using the array data structure
ANOTHER DEFINITION
A data structure is a data organization, management, and storage format that enables efficient access and modification.
More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data. It is an algebraic structure about data.
Types data structure
Linear and Non-Linear
(slide 7)
Linear
:- Data elements are organized sequentially, in which only one data element can directly be reached.
easy to implement in the computer's memory.
Example: Stacks, Queues, Linked List , etc.
Non-Linear
: -Data element can be attached to several other data elements to represent specific relationship that specific among them. - data items are not arranged in sequential structure .
Example: Trees, Graph , etc.
Static and Dynamic
(Slide 8)
Static:
Static is a collection of data in memory that is fixed in size. This result in the maximum size needing to be known in advance, as memory cannot be reallocated at a later point.
Array are a prominent example of a static data structure
.
Dynamic:
Dynamic data structure refers to an collection of data in memory that has the flexibility to grow or shrink in size, enabling a programmer to control exactly how much memory is utilized. Typical example are
lists and tree that grow and shrink dynamically
.
This diagram show a example of an
link list data structure
This diagram is an example of an
Array Data Structure
ABSTRACT DATA TYPE (ADT)
(Slide 9)
An abstract data type or ADT is a mathematical model of a data structure. No implementation in detail.
ADT are a way of separating the specification and representation of data types.
Benefits of using ADTs: code is easier to understand
Example: lists, sets, graphs, stacks are examples of ADT along with their operations.
STRUCTURE
WARDINA
CASE STUDY
(SLIDE 13)
Declare a structure to illustrate student details contained information such as name, Id, Class and Session and CGPA.
ANSWER :
(refer slide 13 for the correct way and better understanding to declare)
struct studentDetails
{
char studentName[30];
char studentID[10];
char class[5];
char session[10];
float cgpa;
}student;
preview of the case study answer
studentDetails
: structure tag
{
char studentName[30];
char studentID[10];
char class[5];
char session[10];
float cgpa;
}
: the elements of the structure which is inside the parentheses are called members of the structure
the members of the structure need to be declared with their respective data types
student
: variable
WAN AHMAD
SLIDE 10
Declaring Structure
Structure is a collection of related data items using one similar name.
Element in structure called as member and they can be different data types.
To declare a structure, use the struct statement. It declares a new data types, with more than one member.
Syntax :
struct [structure tag]
{
member definition;
};
Example :
struct Book
{
char bookname;
int bookisbn;
};
nur athirah
slide 11
DECLARING STRUCTURE (continue )
Suppose that write struct declaration started with
Staff Record that contains Employee No, Name, Position and Basic Salary.
The most common and perhaps best way to define a new structure type involves naming it, with a tag, as shown in the following example
This defines a new type, StaffRecord. Do not forget the semicolon after the right brace. The convention is to capitalize the first letter in any new type name.
DECLARING STRUCT VARIABLE
The new struct type can now be used to declare variables.
syntax:
Struct <tag name> <variable>;
{
variable declaration
};
Example:
Struct studentRecord student;
{
char name[20];
int marks[5];
};
Elton joel (slide 14)
Declare a structure called AddressInfo which holds an info such as address, town, state, and postcode.
struct AddressInfo
{
char address[30];
char town[10];
char state[20];
long int postcode;
};
AddressInfo Address;
Structure tag: struc AddressInfo
Member of structure:
{
char address[30];
char town[10];
char state[20];
long int postcode;
};
Variable structure : AddressInfo Address
ARIF
TYPE OF DATA STRUCTURE (Slide 5)
Primitive and non-primitive
Linear and non-linear
Static and dynamic
UNDERSTAND ARRAY DATA STRUCTURE
(Slide 15-19)
SLIDE 18
HAZIQ
BASIC OPERATIONS
Operations supported by an array
Search
Searches an element using the given index or by the value
Insertion
Adds an element at the given index
Update
Updates an element at the given index
Traverse
Prints all the array elements one by one
Deletion
Deletes an element at the given index
Disadvantages of Array
(slide 19)
Array is static structure. It means that array is of fixed size.
It means that array is of fixed size
The memory which is allocated to array can not be increased or reduced
We cannot change the size of array in run-time.
We must know in advance that how many elements are to be stored in array.
We can store elements only up to a [10000000] (10^7) in a array of integers.
Only elements of same data types can be stored in an array.
We cannot store elements of multiple data types in a single array.
Allocating less memory than the required to an array leads to loss of data.
If it isn't able to allocate memory, it will return a null pointer, (zero)
Array is of fixed size
when memory allocate more than requirement then the memory space will be wasted
while less memory allocate than requirement , it will create problem
elements of array are stored in consecutive memory locations
insertions and deletion are very difficult
time consuming
SLIDE 17
SYAZWAN
Array Presentation
can be declared by various way in different language
Example
as per below illustration there are important points
Index start at 0
array length is 8 which means it can store 8 elements
Each element can be accessed via its index. For example, we can fetch an element at index 6 as 9.
SLIDE 16
ABDULLAH
ARRAY
DEFINITION
Array is a container which can hold a fix number of items and these items should be of the same type.
Most of the data structures make use of arrays to implement their algorithms.
Following are the important terms to understand the concept of Array.
ELEMENT
Each item stored in an array is called an element.
INDEX
Each location of an element in an array has a numerical index, which is used to identify the element.
Catherine
Mauldorna & Ayuna
Dominic Mathew
Anding
slide 12
shahrul