Week-09 Program-01
Due on 2024-03-28, 23:59 IST
Write a program to print all the locations at which a particular element (taken as input) is found in a list and also print the total number of times it occurs in the list. The location starts from 1.
For example, if there are 4 elements in the array
5
6
5
7
If the element to search is 5 then the output will be
5 is present at location 1
5 is present at location 3
5 is present 2 times in the array.
For example, if there are 4 elements in the array
5
6
5
7
If the element to search is 5 then the output will be
5 is present at location 1
5 is present at location 3
5 is present 2 times in the array.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 4
5
6
5
7
5 | 5 is present at location 1.\n
5 is present at location 3.\n
5 is present 2 times in the array. | 5 is present at location 1.\n
5 is present at location 3.\n
5 is present 2 times in the array. | Passed |
Test Case 2 | 5
67
80
45
97
100
50 | 50 is not present in the array. | 50 is not present in the array. | Passed |
Week-09 Program-02
Due on 2024-03-28, 23:59 IST
Write a C program to search a given element from a 1D array and display the position at which it is found by using linear search function. The index location starts from 1.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 5
78
90
34
54
98
90 | 90 is present at location 2. | 90 is present at location 2. | Passed |
Test Case 2 | 6
30
40
50
20
90
60
90 | 90 is present at location 5. | 90 is present at location 5. | Passed |
Week-09 Program-03
Due on 2024-03-28, 23:59 IST
Write a C program to search a given number from a sorted 1D array and display the position at which it is found using binary search algorithm. The index location starts from 1.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 5
10
20
30
40
50
40 | 40 found at location 4. | 40 found at location 4. | Passed |
Test Case 2 | 4
44
55
66
77
10 | Not found! 10 isn't present in the list. | Not found! 10 isn't present in the list. | Passed |
Week-09 Program-04
Due on 2024-03-28, 23:59 IST
Write a C program to reverse an array by swapping the elements and without using any new array.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 4
10
20
30
40 | Reversed array elements are:\n
40\n
30\n
20\n
10 | Reversed array elements are:\n
40\n
30\n
20\n
10\n
| Passed after ignoring Presentation Error |
Test Case 2 | 5
50
60
40
30
20 | Reversed array elements are:\n
20\n
30\n
40\n
60\n
50 | Reversed array elements are:\n
20\n
30\n
40\n
60\n
50\n
| Passed after ignoring Presentation Error |
NPTEL Problem Solving Through Programming In C Jan-2024 Week 9
netaji gandi
Monday, March 25, 2024