0% found this document useful (0 votes)
6 views2 pages

LAB TASK (Array2)

The document outlines tasks for implementing searching and sorting algorithms, including linear search, binary search, bubble sort, selection sort, and insertion sort. It also includes performance analysis through test cases and documentation requirements summarizing implementation, test results, and efficiency observations. Submission requires source code and a report on findings, with an emphasis on good programming practices.

Uploaded by

haleemasadia0024
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)
6 views2 pages

LAB TASK (Array2)

The document outlines tasks for implementing searching and sorting algorithms, including linear search, binary search, bubble sort, selection sort, and insertion sort. It also includes performance analysis through test cases and documentation requirements summarizing implementation, test results, and efficiency observations. Submission requires source code and a report on findings, with an emphasis on good programming practices.

Uploaded by

haleemasadia0024
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/ 2

Lab-Tasks

Part 1: Searching Algorithms


1. Linear Search

 Task: Implement a linear search algorithm.

 Input: An array of integers and a target value.

 Output: The index of the target value if found, otherwise -1.

 Steps:

1. Return the index of the target if found; otherwise, return -1.

2. Binary Search

 Task: Implement a binary search algorithm.

 Input: A sorted array of integers and a target value.

 Output: The index of the target value if found, otherwise -1.

 Steps:

1. Return the index of the target if found; otherwise, return -1.

Part 2: Sorting Algorithms


1. Bubble Sort

 Task: Implement the bubble sort algorithm.

 Input: An array of integers.

 Output: The sorted array.

 Steps:

1. Swap adjacent elements if they are in the wrong order.

2. Continue until the list is sorted.

2. Selection Sort

 Task: Implement the selection sort algorithm.

 Input: An array of integers.

 Output: The sorted array.

 Steps:
1. Repeatedly select the smallest (or largest) element from the
unsorted region and move it to the sorted region.

3. Insertion Sort

 Task: Implement the insertion sort algorithm.

 Input: An array of integers.

 Output: The sorted array.

 Steps:

1. Take each element from the unsorted section and insert it into
the correct position in the sorted section.

Part 3: Performance Analysis


1. Test Cases:

o Create a list of unsorted integers.

o Use the sorting algorithms to sort the list in both ascending


and descending order.

o Use the linear and binary search algorithms to find different


target values, both present and absent in the list.

2. Documentation:

o Write a brief report summarizing:

 The implementation of each algorithm.

 Test results

 Observations on the efficiency of each algorithm.

 Use cases where each search or sort method would be


preferred.

Submission Requirements
 Submit the source code for all implemented algorithms on Slate.

 Include the report summarizing findings.

 Ensure code is well-commented and adheres to good programming


practices.

You might also like