Basic Linked List Operations

Verified

Added on  2019/10/12

|15
|2409
|392
Report
AI Summary
The assignment consists of two parts: Question 1 and Question 2. In Question 1, the task is to create a C program that can perform three basic operations on an array: insertion, deletion, and traversal. The program should be able to insert elements at different positions in the array, delete elements from the array, and traverse the array to print its contents. In Question 2, the task is to create a C program that can perform four basic operations on a linked list: creating an empty linked list, inserting new nodes, testing whether the linked list is empty or not, and traversing the linked list. The program should be able to insert elements at different positions in the linked list, test whether the linked list is empty or not, and traverse the linked list to print its contents.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
PENYERAHAN DAN PENILAIAN TUGASAN
ASSIGNMENT SUBMISSION AND ASSESSMENT
_________________________________________________________________________
CDDS 2103
Introduction to Data Structure
MAY 2016
_________________________________________________________________________
ARAHAN KEPADA PELAJAR / INSTRUCTIONS TO STUDENTS
1. Tugasan ini mengandungi DUA (2) soalan sahaja yang disediakan dalam Bahasa Melayu dan
Bahasa Inggeris / This assignment contains only TWO (2) question that is set in both Malay and
English.
2. Jawab dalam Bahasa Melayu atau Bahasa Inggeris. / Answer in Malay or English.
3. Anda dikehendaki menyerahkan tugasan dalam format MsWord melainkan dinyatakan
sebaliknya. Anda tidak dibenarkan untuk menukar teks/frasa tugasan tersebut kepada format
grafik seperti .jpeg / .gif / print screen / dan lain-lain format berkaitan. /Learners are to submit
assignment only in MsWord format unless specified otherwise. Please refrain from converting
text/phrases into picture format such as .gif / .jpeg / print screen / etc.
4. Muat turunkan templat tugasan versi bahasa yang berkenaan daripada myINSPIRE untuk
penyediaan dan penyerahan tugasan anda. Tugasan anda hendaklah ditaip dengan
menggunakan saiz fon 12 Times New Roman dan langkau baris 1.5. / Download the language
version of the assignment template concerned from the myINSPIRE for preparation and
submission of your assignment. Your assignment should be typed using 12 point Times New
Roman font and 1.5 line spacing.
5. Anda dikehendaki menghantar tugasan SECARA ONLINE melalui myINSPIRE. Sila rujuk kepada
portal untuk arahan mengenai prosedur menghantar tugasan anda secara online. Anda
dinasihatkan menyimpan senaskah tugasan yang diserahkan untuk rujukan sendiri. / You must
submit your assignment ONLINE via the myINSPIRE. Refer to the portal for instructions on the
procedures to submit your assignment online. You are advised to keep a copy of your submitted
assignment for personal reference.
6. Anda hanya boleh menghantar tugasan SEKALI sahaja dalam BEBERAPA FAIL seperti mana
keperluan soalan (1 fail utama dan fail-fail sokongan/lampiran. / You can submit your
assignment ONCE only in a MULTIPLE FILE as per requirement of the assignment (1 main file and
attachment/supporting files).
7. Tugasan anda hendaklah diserahkan antara 27hb Jun hingga 17hb Julai 2016 Serahan selepas 17
Julai 2016 TIDAK akan diterima. / Your assignment must be submitted between 27th June until
17th July 2016. Submission after 17th July 2016 will NOT be accepted.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
8. Anda perlu membentangkan hasil kerja tugasan anda kepada tutor F2F. Kedua-dua pelajar F2F
dan OL perlu menghadiri sesi pembentangan ini. Sila rujuk Pentadbir di Pusat Pembelajaran
anda untuk mengetahui tarikh bagi sesi pembentangan ini. / You are required to present your
assignment task to your F2F tutor. Both F2F and OL students should attend this presentation.
Please refer to your Learning Center Administrator to confirm on the date for the presentation.
9. Tugasan hendaklah disiapkan secara individu. Anda dilarang meniru tugasan orang lain. Anda
juga dilarang sama sekali memplagiat kerja orang lain sebagai kerja sendiri. /
Your assignment should be prepared individually. You should not copy another person’s
assignment. You should also not plagiarise another person’s work as your own.
10. Sila ambil maklum tentang PENALTI yang akan dikenakan ke atas penghantaran lewat tugasan
seperti yang tertera di pekeliling pejabat Pendaftar 6/2012 (Rujuk Registrar’s Announcement di
myINSPIRE) / Please take note that PENALTY will be imposed on late submission of assignment as
specified in the Registrar’s Office circular 6/2012 (Refer to Registrar’s Announcement in
myINSPIRE)
11. Anda perlu memastikan RESIT yang dikeluarkan bagi penghantaran tugasan disimpan sebagai
bukti penghantaran. Kegagalan mengemukakan resit dalam sebarang isu yang timbul berkaitan
penghantaran tugasan akan mengakibatkan tugasan dianggap TIDAK dihantar / Please ensure
that you keep the RECEIPT issued upon submisson of your assignment as proof of submission.
Your assignment is considered as NOT submitted if you fail to produce the submission receipt in
any dispute arises concerning assignment submission.
PENILAIAN / EVALUATION
Tugasan ini menyumbang sehingga 50% daripada jumlah markah kursus berkenaan dan akan dinilai
berdasarkan kepada Rubrik yang dilampirkan. / This assignment accounts for 50% of the total
marks for the course and shall be assessed based on the Rubrics attached .
Anda akan diberikan maklum balas tentang tugasan ini sebelum Peperiksaan Akhir Semester
bermula. / You would be given feedback on the assignment before the Final Semester Examination
commences.
PLAGIARISME: POTONGAN MARKAH / PLAGIARISM: MARKS DEDUCTION
Amaran: Tugasan yang diserahkan, secara automatik, akan disemak untuk menentukan kadar
pertindihan. Jika plagiarisme dikesan, markah akan dipotong seperti berikut: / Warning: The
submitted assignment will automatically undergo a similarity check. If plagiarism is detected, marks
would be deducted as follows:
No. % Similarity (from) % Similarity (To) % of Mark Deduction
1 0 30 0
2 30.01 50 5
3 50.01 70 10
4 70.01 100 100
Document Page
ASSIGNMENT QUESTION / SOALAN TUGASAN
PURPOSE
The purpose of this assignment is to test learner’s understanding on the concepts of data
structures such as basic operations of arrays and linked lists.
TUJUAN
Tujuan tugasan ini adalah untuk menguji pelajar memahami mengenai konsep struktur data seperti
operasi asas tatasusunan dan senarai terpaut.
QUESTION 1
REQUIREMENT / ASSIGNMENT QUESTION
Arrays are used to store data of the same type. There are two main concepts of understanding an
array: element, each item stored in an array is called an element, and index, each location of an
element in an array has a numerical index which is used to identify the element. There are several
ways to declare an array. For example:
int Arr[5] = {1,3,5,7,8};
An illustration of the array declared:
elements 1 3 5 7 8
index 0 1 2 3 4
Size: 5
There are many ways to use or manipulate an array, these are some of the basic array operations:
i) Traverse – print all array elements one by one.
ii) Insertion – add an element at a given index.
iii) Deletion – delete an element at a given index.
Document Page
Examples of Insertion and Deletion operations are given:
Insertion Operation
The original array elements are :
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=7
Arr[4]=8
The array elements after insertion at index 3 :
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=10
Arr[4]=7
Arr[5]=8
Deletion Operation
The original array elements are :
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=7
Arr[4]=8
The array elements after deletion at index 2:
Arr[0]=1
Arr[1]=3
Arr[2]=7
Arr[3]=8
Write a C program that will be able to do the 3 basic array operations. The documentation must
include a short introduction to the problem given, the program codes, and several output screens
(screenshots). You must submit the documentation file and the .c program file.
(20)
The assessment will be done based on the following criteria:
i. A proper writing of C codes and its structure
ii. The ability of program to be compiled and executed
iii. Implementation of correct programming techniques
iv. Complete documentation and correct submission
Note: You must write C programming codes for this assignment.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
KEPERLUAN / SOALAN TUGASAN
Tatasusunan adalah digunakan untuk menyimpan data dari jenis yang sama. Terdapat dua konsep
utama memahami tatasusunan; elemen, setiap item yang disimpan dalam tatasusunan dipanggil
elemen, dan indeks, setiap lokasi elemen dalam tatasusunan mempunyai indeks berangka yang
digunakan untuk mengenal pasti elemen.
Terdapat beberapa cara untuk mengisytiharkan tatasusunan. Sebagai contoh:
int Arr[5] = {1,3,5,7,8};
Ilustrasi tatasusunan yang diisytiharkan:
elemen 1 3 5 7 8
indeks 0 1 2 3 4
Saiz: 5
Terdapat banyak cara untuk menggunakan atau memanipulasi tatasusunan, ini adalah sebahagian
daripada operasi asas tatasusunan:
i) Menjelajahi - mencetak semua unsur-unsur pelbagai satu demi satu.
ii) Penyisipan - menambah satu elemen pada indeks yang diberikan.
iii) Penghapusan - memadam unsur pada indeks yang diberikan.
Contoh operasi penyisipan dan penghapusan diberikan:
Operasi Penyisipan
Elemen asal tatasusunan adalah :
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=7
Arr[4]=8
Elemen tatasusunan selepas penyisipan pada indeks 3:
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=10
Arr[4]=7
Arr[5]=8
Operasi Penghapusan
Document Page
Elemen asal tatasusunan adalah :
Arr[0]=1
Arr[1]=3
Arr[2]=5
Arr[3]=7
Arr[4]=8
Element tatasusunan selepas penghapusan pada indeks 2:
Arr[0]=1
Arr[1]=3
Arr[2]=7
Arr[3]=8
Tulis aturcara C yang dapat melakukan 3 operasi asas tatasusunan. Dokumentasi mesti termasuk
pengenalan ringkas kepada masalah yang diberikan, kod aturcara, dan skrin output (screenshot).
Anda mesti menghantar fail dokumentasi serta fail aturcara .c .
Penilaian akan dilakukan berdasarkan kepada kriteria berikut:
i. Penulisan kod C dan strukturnya yang betul
ii. Kebolehan aturcara dikompil dan dilaksanakan
iii. Pelaksanaan teknik-teknik pengaturcaraan yang betul
iv. Dokumentasi lengkap dan penghantaran yang betul
Nota: Anda mesti menulis kod pengaturcaraan C bagi tugasan ini.
Document Page
QUESTION 2
REQUIREMENT / ASSIGNMENT QUESTION
Arrays are not practical for modification or inserting or deleting data. This weakness can be
overcome by using linked lists. Linked lists are collections of data items in a row – insertions and
deletions are made anywhere in a linked list. Linked lists consists of sequential items known as
nodes. Each node is made up of two parts: data, the elements in the list, and link, the link to the
next node in the list.
The linked list data structure can be defined as follows:
typedef int ELEMENT;
typedef struct node;
{
ELEMENT data;
struct node *next;
} NODE;
An illustration of the linked list declared:
In linked lists, there are several basic operations that can be performed:
i) Create an empty linked list
ii) Insert new nodes
iii) Test whether a linked list is empty or not
iv) Traverse a linked list
1 3 5 7 8
Linked
List
NULL

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Examples of Insertion operation is given:
The original linked list
The linked list after inserting element 10, in between element 5 and 7
Write a C program that will be able to do the 4 basic linked list operations. The documentation
must include a short introduction to the problem given, the program codes, and output screens
(screen shots). You must submit the documentation file and the .c program file.
(30)
The assessment will be done based on the following criteria:
i. A proper writing of C codes and its structure
ii. The ability of program to be compiled and executed
iii. Implementation of correct programming techniques
iv. Complete documentation and correct submission
Note: You must write C programming codes for this assignment.
Linked
List
1
NULL
3 5 7
0
8
0
10
1 3 5 7 8
Linked
List
NULL
Document Page
KEPERLUAN / SOALAN TUGASAN
Tatasusunan adalah tidak praktikal untuk pengubahsuaian atau penyisipan atau penghapusan data.
Kelemahan ini boleh diatasi dengan menggunakan senarai terpaut. Senarai terpaut adalah koleksi
item data dalam turutan - sisipan dan penghapusan boleh dibuat mana-mana sahaja dalam senarai
terpaut. Senarai terpaut terdiri daripada item berurutan dikenali sebagai nod. Setiap nod terdiri
daripada dua bahagian: data, elemen-elemen dalam senarai, dan pautan, pautan ke nod seterusnya
dalam senarai.
Struktur data senarai terpaut boleh ditakrifkan seperti berikut:
typedef int ELEMENT;
typedef struct node;
{
ELEMENT data;
struct node *next;
} NODE;
Illustrasi senarai terpaut yang diisytiharkan:
Dalam senarai terpaut, terdapat beberapa operasi asas yang boleh dilakukan:
i) Bina senarai terpaut kosong
ii) Penyisipan nod baru
iii) Uji sama ada senarai kosong atau tidak
iv) Menjelajahi senarai terpaut
1 3 5 7 8
Senarai
terpaut
NOL
Document Page
Contoh operasi penyisipan diberikan:
Senarai terpaut asal
Senarai terpaut selepas penyisipan elemen 10, antara elemen 5 dan 7
Tulis aturcara C yang dapat melakukan 4 operasi asas senarai terpaut. Dokumentasi mesti termasuk
pengenalan ringkas kepada masalah yang diberikan, kod program, dan skrin output (screenshot).
Anda mesti menghantar fail dokumentasi serta fail aturacara .c
Penilaian akan dilakukan berdasarkan kepada kriteria berikut:
i. Penulisan kod C dan strukturnya yang betul
ii. Kebolehan aturcara dikompil dan dilaksanakan
iii. Pelaksanaan teknik-teknik pengaturcaraan yang betul
iv. Dokumentasi lengkap dan penghantaran yang betul
Nota: Anda mesti menulis kod pengaturcaraan C bagi tugasan ini.
(TOTAL 50 marks)
MUKA SURAT TAMAT / END OF PAGE
1 3 5 7 8
Senarai
terpaut
NOL
1 3 5 7
0
8
0
10
Senarai
terpaut
NOL

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
ATTACHMENT
ASSIGNMENT RUBRICS
CDDS 2103 INTRODUCTION TO DATA STRUCTURE / MAY 2016
QUESTION 1
Criteria Weight
age
Low Fair Above average Excellent
Max
Marks
0 1 2 3 4
Program Completion
for Task
Basic array operations:
i) Traverse
ii) Insertion
iii) Deletion
2.0
No
implementation
of the tasks
Implemented only a small
chunk of this task
Moderate implementation
of the task correctly
Most of the task was
implemented correctly
The task was implemented
successfully
8Kesempurnaan Aturcara
BAGI Tugas
Operasi asas
tatasusunan
i) Menjelajahi
ii) Penyisipan
iii) Penghapusan
Tiada
perlaksanaan
arahan
Hanya sebahagian kecil
arahan dilaksanakan
Perlaksanaan arahan yang
sederhana secara betul
Kebanyakan arahan
dilaksanakan dengan
betul
Arahan dilaksanakan dengan
cemerlang
Coding Standards
0.5
Wrong coding Codes were not well
organised
Codes were organised in
moderate manner
Codes were organised
properly
Codes written were very
well structured and
creatively organised
2
Piawaian Kod Pengekodan
yang salah
Kod tidak disusun dengan
sempurna
Kod disusun dengan cara
sederhana
Kod disusun dengan baik Kod ditulis dengan sangat
berstruktur dan disusun
dengan kreatif
Runtime 1.0 The program
could not be
executed at all
The program was not
executed due to errors
OR the program was
executed with the
correct output but the
written coding did not
fulfil all the question’s
requirements
The program was
executed but mostly
with incorrect output
OR the program was
executed with the
correct output but the
written coding did not
fulfil few of the
question’s requirements
The program was
executed mostly with the
correct output
The program was
executed with all the
correct output
AND the program was
executed by fulfilling all
the requirements as
stated in the question
4
Document Page
Masa Larian Aturcara tidak
dapat
dilaksanakan
langsung
Aturcara ini tidak
dilaksanakan disebabkan
ralat
ATAU aturcara ini
dilaksanakan dengan
output yang betul tetapi
kod ditulis tidak
memenuhi keperluan
soalan
Aturcara ini dilaksanakan
tetapi kebanyakan
output adalah salah
ATAU aturcara ini
dilaksanakan dengan
output yang betul tetapi
kodnya ditulis tanpa
memenuhi beberapa
keperluan soalan
Aturcara ini dilaksanakan
dengan kebanyakan
output yang betul
Aturcara ini dilaksanakan
dengan semua output
yang betul
DAN aturcara ini
dilaksanakan dengan
memenuhi semua
keperluan yang
dinyatakan dalam soalan
Efficiency
1.0
Wrong solution A difficult and inefficient
solution
A logical solution that is
easy to follow but it is not
the most efficient
Solution is efficient and
easy to follow
Solution is efficient,
understandable and easy to
maintain
4Efisiensi Penyelesaian
yang salah
Penyelesaian yang sukar
dan tidak berkesan
Penyelesaian logikal yang
senang diikuti tetapi ianya
bukanlah penyelesaian
paling berkesan
Penyelesaian adalah
berkesan dan senang
diikuti
Penyelesaian adalah
berkesan, boleh difahami dan
senang diselenggara
Requirement of
Documentation (Source
Code files & Document
file. Document file has
copy of codes,
screenshots of the
program output and
program comments)
0.5
No
documentation
& source code
file
Incomplete documentation
& without source code file
Brief documentation with
source code file
Good documentation
together with source
code file
Excellent documentation
and complete with source
code file
2
Keperluan Dokumentasi
(fail sumber & fail
dokumen. Fail dokumen
mengandungi salinan
kod, imbasan skrin
output aturcara dan
komen aturcara)
Tiada
dokumentasi
dan fail kod
sumber
Dokumentasi yang tidak
lengkap dan tanpa fail kod
sumber
Dokumentasi yang ringkas
bersama dengan fail kod
sumber
Dokumentasi yang
memuaskan bersama
dengan fail kod sumber
Dokumentasi yang cemerlang
dan lengkap dengan fail kod
sumber
Total 5 20
Document Page
QUESTION 2
Criteria Weight
age
Low Fair Above average Excellent
Max
Marks
0 1 2 3 4

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Program Completion for Task
Basic Linked List Operations:
i) Create empty linked list
ii) Insert new nodes
iii) Test whether list is empty
or not
iv) Traverse linked list
2.0
No
implementation
of the tasks
Implemented only a
small chunk of this task
Moderate implementation
of the task correctly
Most of the task was
implemented correctly
The task was
implemented
successfully
8
Kesempurnaan Aturcara BAGI
Tugas
Operasi asas senarai terpaut
i) Bina senarai terpaut
kosong
ii) Penyisipan nod baru
iii) Uji sama ada senarai
kosong atau tidak
iv) Menjelajahi senarai
terpaut
Tiada
perlaksanaan
arahan
Hanya sebahagian kecil
arahan dilaksanakan
Perlaksanaan arahan yang
sederhana secara betul
Kebanyakan arahan
dilaksanakan dengan
betul
Arahan dilaksanakan
dengan cemerlang
Coding Standards
1.5
Wrong coding Codes were not well
organised
Codes were organised in
moderate manner
Codes were organised
properly
Codes written were very
well structured and
creatively organised
6Piawaian Kod Pengekodan
yang salah
Kod tidak disusun dengan
sempurna
Kod disusun dengan cara
sederhana
Kod disusun dengan baik Kod ditulis dengan
sangat berstruktur dan
disusun dengan kreatif
Runtime
2.0
The program
could not be
executed at all
The program was not
executed due to
errors
OR the program was
executed with the
correct output but the
written coding did not
fulfil all the question’s
requirements
The program was
executed but mostly
with incorrect output
OR the program was
executed with the
correct output but the
written coding did not
fulfil few of the
question’s requirements
The program was
executed mostly with the
correct output
The program was
executed with all the
correct output
AND the program
was executed by
fulfilling all the
requirements as
stated in the
question
8
Masa Larian Aturcara tidak
dapat
dilaksanakan
langsung
Aturcara ini tidak
dilaksanakan
disebabkan ralat
ATAU aturcara ini
dilaksanakan dengan
Aturcara ini dilaksanakan
tetapi kebanyakan
output adalah salah
ATAU aturcara ini
dilaksanakan dengan
Aturcara ini dilaksanakan
dengan kebanyakan
output yang betul
Aturcara ini
dilaksanakan dengan
semua output yang
betul
DAN aturcara ini
Document Page
output yang betul
tetapi kod ditulis tidak
memenuhi keperluan
soalan
output yang betul tetapi
kodnya ditulis tanpa
memenuhi beberapa
keperluan soalan
dilaksanakan dengan
memenuhi semua
keperluan yang
dinyatakan dalam
soalan
Efficiency
1.0
Wrong solution A difficult and inefficient
solution
A logical solution that is
easy to follow but it is not
the most efficient
Solution is efficient and
easy to follow
Solution is efficient,
understandable and
easy to maintain
4
Efisiensi Penyelesaian
yang salah
Penyelesaian yang sukar
dan tidak berkesan
Penyelesaian logikal yang
senang diikuti tetapi ianya
bukanlah penyelesaian
paling berkesan
Penyelesaian adalah
berkesan dan senang
diikuti
Penyelesaian adalah
berkesan, boleh
difahami dan senang
diselenggara
Requirement of
Documentation (Source Code
files & Document file.
Document file has copy of
codes, screenshots of the
program output and program
comments) 1.0
No
documentation
& source code
file
Incomplete
documentation &
without source code file
Brief documentation with
source code file
Good documentation
together with source
code file
Excellent
documentation and
complete with source
code file
4
Keperluan Dokumentasi
(fail sumber & fail dokumen.
Fail dokumen mengandungi
salinan kod, imbasan skrin
output aturcara dan komen
aturcara)
Tiada
dokumentasi
dan fail kod
sumber
Dokumentasi yang tidak
lengkap dan tanpa fail
kod sumber
Dokumentasi yang ringkas
bersama dengan fail kod
sumber
Dokumentasi yang
memuaskan bersama
dengan fail kod sumber
Dokumentasi yang
cemerlang dan lengkap
dengan fail kod sumber
Total 7.5 30
1 out of 15
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]