Data Structure - Lect 04
Data Structure - Lect 04
.
Eng. Mahmmoud Ouf
Lect 04
Data Structure:
Is a way for storing, organizing and Manipulating data array
Array is type of Data Structure
array is fixed length
Linked List:
set of nodes, each node has (Data, Reference to Next node)
node
Data Data
Next Next
Type of Linked List
1) Single Linked List: Head
Head
Double Circular Linked List node
}
/*The addNode is used to add the created node at the end of the linked list. It start by calling
CreateNode, then check if the node is allocated, so it will add it at the end. Data
The method return bool (true if the node is allocated and added, false if it couldn’t allocate the node
and it is not added)*/ Next
public static bool AddNode(int Data){
bool retval = false;
Node node;
Node temp
node = CreateNode(Data); 6
5
if(node != null){
if(Head == null){ //No List
Head = node; null
}
else { //there is a list
temp = Head;
while(temp.Next != null){
temp = temp.Next;
}// end while 9
temp.Next = node;
}//end else null
retval = true;
}//end if
return retval;
}//end of AddNode method
}//end class SingleLinkedList