Report 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

Green University of Bangladesh

Department of Computer Science and Engineering(CSE)


Faculty of Sciences and Engineering
Semester: (Fall, Year: 2022), B.Sc. in CSE (Day)

LAB REPORT NO #01


Course Title: Data Structure Lab
Course Code: CSE 106 Section: 221 D12

Lab Experiment Name:


1. Find the specific node of element that is present or not in the singly linked list.
2. Call a function that will generate the size of the singly linked list.
3. Insert element between any specific position of the singly linked list
Student Details:
Name ID

Sadika Tamim 221002609

Lab Date : 03/11/2022


Submission Date : 10/11/2022
Course Teacher’s Name : Nazim Uddin.
[For Teachers use only: Don’t Write Anything inside this box]
Lab Report Status
Marks:............................... Signature:...............
Comments:....................... Date:.......................

1.TITLE OF THE LAB EXPERIMENT :


Problem 1: Find the specific node of element that is present or not in the singly
linked list
Problem 2: Call a function that will generate the size of the singly linked list.
Problem 3: Insert element between any specific position of the singly linked list.

2.OBJECTIVES:

Problem 1:In this program, we gain our knowledge on linked list. Recalling the
knowledge on pointer, structure and malloc.
Problem 2:In this program, we gain our knowledge on linked list. Input same value in
the linked list and find the length of the linked list.
Problem 3:In this program, we create a single linked list. Then we insert and node
between
any specific position. We gain our knowledge how to insert any element at
any
position in the list.
3.PROCEDURE:

Problem 1:
1. Input the element to search from user. Store it in some variable say
keyToSearch
2. Declare variable.
3. Declare struct node *curNode=head.
4. If curNode is not NULL and its data is not equal to KeyToSearch. Then increment
Index and move curNode to its next node.
5. Repeat step 3 till curNode !=NULL and element is not found otherwise move to
5 th

step
6. If curNode is not NULL then element is found hence return index otherwise.

Problem 2:
1. At first initialize the length count=0.
2. Then initialize a node pointer and update current node current=head.
3. Do following while current is not NULL
a. current= current-> next
b. increment count by 1.
4. Then return count of the length.

Problem 3:

1. If the position where we are asked to insert pos is smaller than 1 or greater than the
size of the list, it is invalid, and we will return.
2. Else we will make variable curr and make it point to the head of the list.
3. After the termination of the above loop, curr will be standing at the (position – 1)th
node.
4. As explained above, we will wimply make newnode-next= curr-next and curr-next=
newnode.
5. Store data for new node.
6. Change next pointers to include new node in between.

4.IMPLEMENTATION :
Problem 1:
Problem 2:
Problem 3:
5.TEST RESULT :

Problem 1:

Problem 2:
Problem 3:

6.ANALYSIS AND DISCUSSION :

1. In this experiment every program is done with struct. In last problem I insert element
between any specific position of the singly linked list

2. In this experiment, I have learned many things. I learned how to find the specific node of
element that is present or not in the singly linked list. How to call a function that will
generate the size of the singly linked list.
3. In this program, first I faced a few problems because I had used different formulas in each
problem. But when I try it many times it is not too hard.

You might also like