0% found this document useful (0 votes)
58 views13 pages

cc3 4

The document appears to be a student's lab report submission for a competitive coding course. It includes 4 experiments - the first on finding missing elements in an array, the second on quicksort partitioning, the third on inserting a node in a doubly linked list, and the fourth on detecting cycles in a linked list. Each experiment section includes the aim, tasks, algorithms, code, observations, and learning outcomes. Evaluation grids are also included but not filled in.

Uploaded by

Harwinder Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views13 pages

cc3 4

The document appears to be a student's lab report submission for a competitive coding course. It includes 4 experiments - the first on finding missing elements in an array, the second on quicksort partitioning, the third on inserting a node in a doubly linked list, and the fourth on detecting cycles in a linked list. Each experiment section includes the aim, tasks, algorithms, code, observations, and learning outcomes. Evaluation grids are also included but not filled in.

Uploaded by

Harwinder Kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CHANDIGARH UNIVERSITY

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Submitted By: Akshita Gupta Submitted to: Harkeerat Singh

Subject Name Competitive Coding

Subject Code 20CSP-314

Branch Computer Science


and Engineering

Semester 5
Name: Akshita Gupta UID : 20BCS5201

Sr.No Program Date Evaluation Sign


LW VV FW Total
(12) (10) (8) (30)
Experiment – 3.1

Student Name:Akshita Gupta UID: 20BCS5201


Branch: CSE Section/Group: 708-B
Semester: 5 Date of Performance:
16/08/22 Subject Name: Competitive Programming

Subject Code: 20CSP-314

1. Aim/Overview of the practical: Searching and Sorting

2. Task to be done/ Which logistics used: Find the missing elements of an array

3. Algorithm/Flowchart (For programming based labs):

4. Steps for experiment/practical/Code:


public static ArrayList<Integer> finding(int []arr, int []arr1)
{ ArrayList<Integer>s=new ArrayList<>();
Arrays.sort(arr);
Arrays.sort(arr1);
int first;
int second;
int i=0;
int j=0;
while(i<arr.length){
first=arr[i];
second=arr1[j]; if(first!
=second){
s.add(second);
j++;
}else{
i++; j++;
}
}
return s;
}

5. Result/Output/Writing Summary:
Experiment – 3.2

Student Name:Akshita Gupta UID: 20BCS5201


Branch: CSE Section/Group: 708-B
Semester: 5 Date of Performance:
16/08/22 Subject Name: Competitive Programming

1. Aim/Overview of the practical: Searching and Sorting

2. Task to be done/ Which logistics used: Quicksort 1 - Partition

3. Algorithm/Flowchart (For programming based labs):


1. As given in the question we have to keep arr[0] as pivot element
2. We will make two variable whose duties will be swap the element with the
smaller number.
3. Two variable are I and j will swap each other. They will work in way that all
the elements in at the right of I will be less than pivot.
4. Then we will swap arr[0] and arr[i-1]
4. Steps for experiment/practical/Code:
public static int partition(int []arr){
int pivot=arr[0];
int j=1;
int i=1;
while(j<arr.length){
if(arr[j]<pivot){
int temp=arr[j];
arr[j]=arr[i];
arr[i]=temp; i+
+;
}else {
j++;}
}
int temp=arr[i-1];
arr[i-1]=arr[0];
arr[0]=temp;
return i-1;
}
. Observations/Discussions/ Complexity Analysis: Time Complexity:O(n)

6. Result/Output/Writing Summary:
Learning outcomes (What I have

learnt): 1.Searching

2. Sorting

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):

Sr. No. Parameters Marks Obtained Maximum Marks


1.
2.
3.
Experiment – 4.1

Student Name:Akshita Gupta UID: 20BCS5201


Branch: CSE Section/Group: 708-B
Semester: 5 Date of Performance:
22/08/22 Subject Name: Competitive Programming

Subject Code: 20CSP-314


1. Aim/Overview of the practical: Linked List

2. Task to be done/ Which logistics used: Insert node in a doubly linked list

3. Algorithm/Flowchart (For programming based labs):


 Firstly, check if the given previous node is NULL or not.
 Then, allocate a new node and
 Assign the data to the new node
 And then make the next of new node as the next of previous node.
 Finally, move the next of the previous node as a new node.
4. Steps for experiment/practical/Code:

5. Observations/Discussions/ Complexity Analysis:

Time complexity: O(n)


6. Result/Output/Writing Summary:
Experiment – 4.2

Student Name:Akshita Gupta UID: 20BCS5201


Branch: CSE Section/Group: 708-B
Semester: 5 Date of Performance:
22/08/22 Subject Name: Competitive Programming

Subject Code: 20CSP-314


1. Aim/Overview of the practical: Linked List

2. Task to be done/ Which logistics used: Cycle Detection

3. Algorithm/Flowchart (For programming based labs):


1. In this we make a hashset for stop the duplication.
2. Hashset will be names s
3. S will only contain nodes
4. When we see node getting repeated then we stop as we have the loop
5. Then we return true or false
4. Steps for experiment/practical/Code:
public static void checking(Node head)
{ HashSet<Node>s=new HashSet<>();
Node curr=head;
while(curr!=null){
if(!s.add(curr)){
System.out.println("True");
return;
}
curr=curr.next;
}
System.out.println("false");
}
. Observations/Discussions/ Complexity Analysis:

Time complexity: O(n)

Auxiliary space:O(n)

6. Result/Output/Writing Summary:

Learning outcomes (What I have

learnt): 1.
2.
3.
4.
5.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.

You might also like