Submit Search
Upload
Linked list proj
•
0 likes
•
32 views
Dr. Ahmed J. Obaid
Follow
نمير حيدر عمران كلية علوم الحاسوب و الرياضيات
Read less
Read more
Science
Report
Share
Report
Share
1 of 4
Download now
Download to read offline
Recommended
Import java
Import java
wildled
Algoritmos 4
Algoritmos 4
Santiago Edd
Шаблоны проектирования 2
Шаблоны проектирования 2
Constantin Kichinsky
Java весна 2013 лекция 6
Java весна 2013 лекция 6
Technopark
Java лаб13
Java лаб13
Enkhee99
Project
Project
taufiq26
Java
Java
Dany Ianko
成果整理表
成果整理表
neymasem
Recommended
Import java
Import java
wildled
Algoritmos 4
Algoritmos 4
Santiago Edd
Шаблоны проектирования 2
Шаблоны проектирования 2
Constantin Kichinsky
Java весна 2013 лекция 6
Java весна 2013 лекция 6
Technopark
Java лаб13
Java лаб13
Enkhee99
Project
Project
taufiq26
Java
Java
Dany Ianko
成果整理表
成果整理表
neymasem
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
Tipprapa Sungsinchai
Bài tập tuần 2
Bài tập tuần 2
Cong Nguyen
Bai tap tham khao CSPE
Bai tap tham khao CSPE
mrcoffee282
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Loïc Knuchel
Prof.js
Prof.js
uupaa
Void numero
Void numero
Oiga Lin
Java весна 2013 лекция 7
Java весна 2013 лекция 7
Technopark
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
Eleanor McHugh
matrix operation using operator overloading
matrix operation using operator overloading
maria azam
1- Sourcecode Array
1- Sourcecode Array
Fajar Baskoro
Tugas pw [10]
Tugas pw [10]
guestf689463
Tugas pw [10]
Tugas pw [10]
guest272e50
Ejercicio8
Ejercicio8
jbersosa
Simulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadratico
José Antonio Sandoval Acosta
Tugas pak putu
Tugas pak putu
Roham Firham
Effective java 摘選條目分享 2 - 泛型
Effective java 摘選條目分享 2 - 泛型
Kane Shih
Os lecture 7
Os lecture 7
Dr. Ahmed J. Obaid
Os lecture 6
Os lecture 6
Dr. Ahmed J. Obaid
Os lecture 5
Os lecture 5
Dr. Ahmed J. Obaid
Operating System Lecture 4
Operating System Lecture 4
Dr. Ahmed J. Obaid
Operating System Lecture 3
Operating System Lecture 3
Dr. Ahmed J. Obaid
Operating System Lecture 2
Operating System Lecture 2
Dr. Ahmed J. Obaid
More Related Content
What's hot
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
Tipprapa Sungsinchai
Bài tập tuần 2
Bài tập tuần 2
Cong Nguyen
Bai tap tham khao CSPE
Bai tap tham khao CSPE
mrcoffee282
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Loïc Knuchel
Prof.js
Prof.js
uupaa
Void numero
Void numero
Oiga Lin
Java весна 2013 лекция 7
Java весна 2013 лекция 7
Technopark
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
Eleanor McHugh
matrix operation using operator overloading
matrix operation using operator overloading
maria azam
1- Sourcecode Array
1- Sourcecode Array
Fajar Baskoro
Tugas pw [10]
Tugas pw [10]
guestf689463
Tugas pw [10]
Tugas pw [10]
guest272e50
Ejercicio8
Ejercicio8
jbersosa
Simulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadratico
José Antonio Sandoval Acosta
Tugas pak putu
Tugas pak putu
Roham Firham
Effective java 摘選條目分享 2 - 泛型
Effective java 摘選條目分享 2 - 泛型
Kane Shih
What's hot
(16)
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
Bài tập tuần 2
Bài tập tuần 2
Bai tap tham khao CSPE
Bai tap tham khao CSPE
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Prof.js
Prof.js
Void numero
Void numero
Java весна 2013 лекция 7
Java весна 2013 лекция 7
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
matrix operation using operator overloading
matrix operation using operator overloading
1- Sourcecode Array
1- Sourcecode Array
Tugas pw [10]
Tugas pw [10]
Tugas pw [10]
Tugas pw [10]
Ejercicio8
Ejercicio8
Simulacion - Algoritmo congruencial cuadratico
Simulacion - Algoritmo congruencial cuadratico
Tugas pak putu
Tugas pak putu
Effective java 摘選條目分享 2 - 泛型
Effective java 摘選條目分享 2 - 泛型
More from Dr. Ahmed J. Obaid
Os lecture 7
Os lecture 7
Dr. Ahmed J. Obaid
Os lecture 6
Os lecture 6
Dr. Ahmed J. Obaid
Os lecture 5
Os lecture 5
Dr. Ahmed J. Obaid
Operating System Lecture 4
Operating System Lecture 4
Dr. Ahmed J. Obaid
Operating System Lecture 3
Operating System Lecture 3
Dr. Ahmed J. Obaid
Operating System Lecture 2
Operating System Lecture 2
Dr. Ahmed J. Obaid
Operating System Lecture 1
Operating System Lecture 1
Dr. Ahmed J. Obaid
More from Dr. Ahmed J. Obaid
(7)
Os lecture 7
Os lecture 7
Os lecture 6
Os lecture 6
Os lecture 5
Os lecture 5
Operating System Lecture 4
Operating System Lecture 4
Operating System Lecture 3
Operating System Lecture 3
Operating System Lecture 2
Operating System Lecture 2
Operating System Lecture 1
Operating System Lecture 1
Linked list proj
1.
/* نمير حيدر عمران اﻷثنين
27 أبريل */ import java.util.NoSuchElementException; public class test1 { public static void main(String[] args) { //مثال عﻠﻰ متغير من نوع linkedList يبين عمﻠية اﻷنشاء و //اﻷضافة و الحذف و عمﻠية عرض العناصر و طباعتها linkedList<String> linkedList = new linkedList<>(); //اﻷضافة linkedList.add("1"); linkedList.add(null); linkedList.add("3"); linkedList.add("4"); linkedList.add(0,"deleted element"); //الحذف linkedList.delete(4); //أستدعاء العناصر و طباعتها for (int i = 0; i < linkedList.size; i++) { System.out.println(linkedList.get(i)); } } /** * class node * هذا الكﻼس يمثل ال(node) المستخدمة فﻲ خوارزمية ال(inkedList) * وتحتوي عﻠﻰ متغيرين ﻛما يﻠﻲ * data --> (node)تحمل بيانات ال * next --> القادم (node)تﺆﺷر عﻠﻰ ال * @param <E> نوع البيانات المستخدم خﻼل أستدعاء ال(class) مثل int او String <-- */ public static class node<E> { E data; node<E> next; //constructor --> يستخدم لتغيير و تحديد قيم المتغيرات داخﻠه public node(E data, node<E> next) { this.data = data; this.next = next; } } /** * class linkedList * الخوارزمية الكامﻠة ﻻنشاء ال(linkedList) و ادارتها و تنفيذ العمﻠيات الشائعة عﻠيها * و ما يﻠﻲ مﺠموعة من العمﻠيات المطبقة عﻠﻰ ال(linkedList) فﻲ هذه الخوارزمية * * get(int index) --> (index)المختار حسﺐ ال (node)ترﺟﻊ قيمة البيانات الموﺟودة داخل ال * getFirst() --> (linkedList)فﻲ ال (node) ترﺟﻊ بيانات أول * gentlest() --> (linkedList)فﻲ ال (node) ترﺟﻊ بيانات أخر * --------------------------------------------------------------------- * add(E val) --> ﺟديد (node) أضافة * add(int index, E val) --> ﺟديد فﻲ أي مكان محدد (node) أضافة * addLast(E val) --> ﺟديد فﻲ النهاية (node) أضافة * addFirst(E val) --> ﺟديد فﻲ البداية (node) أضافة * --------------------------------------------------------------------- * deleteFirst() --> مسﺢ اول عنﺼر * deleteLast() --> مسﺢ أخر عنﺼر * delete(int index) --> مسﺢ من أي مكان * ---------------------------------------------------------------------
2.
* indexChecker(int index)
--> لمعرفة أذا ﻛان صالﺢ لﻸستخدام أم ﻻ(مستخدمة فﻲ أﻛثر من موضﻊ فﻲ الخوارزمية مثل اﻷضافة و الحذف) (index)تختبر ال * node(int index) --> (index)حسﺐ قيمة ال (node) تعيد أي * * المتغيرات الرئيسية فﻲ الخوارزمية * first --> (linkedList)محدد يستخدم لتحديد أول عنﺼر فﻲ ال * last --> (linkedList)محدد يستخدم لتحديد أخر عنﺼر فﻲ ال * size --> (linkedList)عدد عناصر ال * @param <E> نوع البيانات المستخدم خﻼل أستدعاء ال(class) مثل int او String <-- */ public static class linkedList<E> { transient node<E> first; transient node<E> last; int size; public E get(int index) { node<E> n = node(index); return n.data; } public E getFirst() { node<E> f = first; if (f == null) { throw new NoSuchElementException(); } return f.data; } public E getLast() { node<E> l = last; if (l == null) { throw new NoSuchElementException(); } return l.data; } public void add(E val) { addLast(val); } public void add(int index, E val) { if (index == size) { addLast(val); } else if (index == 0) { addFirst(val); } else { indexChecker(index); if (first == null && last == null) { first = new node<>(val, null); } else if (first != null && last == null) { last = new node<>(val, null); first.next = last; } else if (first != null && last != null) { node<E> node = node(index); node<E> prevNode = node(index - 1); node<E> newNode = new node<>(val, node); prevNode.next = newNode; } size++; } }
3.
public void addLast(E
val) { if (first == null && last == null) { first = new node<>(val,null); } else if (first != null && last == null) { last = new node<>(val, null); first.next = last; } else if (first != null && last != null) { node<E> temp = last; last = new node<>(val, null); temp.next = last; } size++; } public void addFirst(E val) { if (first == null && last == null) { first = new node<>(val,null); } else if (first != null && last == null) { last = first; first = new node<>(val, last); } else if (first != null && last != null) { node<E> temp = first; first = new node<>(val, temp); } size++; } public void deleteFirst() { node<E> temp = first; first = first.next; temp = null; size--; } public void deleteLast() { node<E> prev = node(size - 2); prev.next = null; size--; } public void delete(int index) { if (index == 0) { deleteFirst(); } else if (index == size - 1) { deleteLast(); } else { node<E> node = node(index); node<E> prevNode = node(index - 1); prevNode.next = node.next; size--; } } private void indexChecker(int index) { if (!(index >= 0 && index < size)) { throw new IndexOutOfBoundsException("at index of: " + index); } } private node<E> node(int index) { indexChecker(index);
4.
node<E> x; x =
first; for (int i = 0; i < index; i++) { x = x.next; } return x; } } }
Download now