Professional Documents
Culture Documents
Chapter 1
Data Structure :
storage of data
retrieval of data
manipulation of data
Searching : finding the location of a given data element ( key ) in the structure.
Data Structure 1
Insertion : Adding a new data element to the structure.
Merging : Combining data elements from two or more data strucure into one.
-
Dynamic data structures (change size as needed) ( ) متغير
Such as Linked Lists
Data Structure 2
- Linear representation
Such as arrays and linked lists
- Non-linear representation
Such as trees and graphs
Array Dimensionality
Array Operations
Data Structure 3
Inserting : add an element at a certain index
adding an element in the beginning is very slow because we have to shift all
elements over one position
Chapter 2
Data Structure 4
public static int search(int[] a, int value){
for(int i =0; i < a.length; i++){
if(value == a[i])
return i;
}
return -1;
}
Data Structure 5
if(a[mid] == value)
return mid;
else if(a[mid] > value)
high = mid - 1;
else if(a[mid] < value)
high = mid + 1;
}
return -1;
}
first code:
second code:
Data Structure 6
return true;
}
return false;
}
Chapter 3
What is linked list: abstraction of a list, a sequence of nodes which each node is
linked to the node following it ( ordered collection of data )
each node does not necessarily follow the previous one in memory
each element is stored in contiguous does not necessarily follow the other node
location in memory in memory
Data Structure 7
each node has two parts:
Data Structure 8
Head of the list
To reach the first node you must have a reference variable that simply points to
the first node of the list
So we will need two Java Classes:
1. The first class is for the individual nodes of the linked list
class ll_node
class SLinkedList
This class also defines many methods that operate on the list
insertion, deletion, searching, printing nodes, etc
Data Structure 9
--------
}
Data Structure 10