FULL REWRITTEN ASSIGNMENT (Algorithms
Rewritten)
Problem 01: Array Traversing
Problem Statement: (Same as original assignment)
Algorithm:
1. Start the program.
2. Declare an array and input its size.
3. Read all elements from the user.
4. Initialize a loop counter from 0.
5. Visit each array element sequentially.
6. Display every element during traversal.
7. Continue until the final element is processed.
8. Terminate the program.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 02: Array Insertion
Problem Statement: (Same as original assignment)
Algorithm:
1. Start the program.
2. Take the new element from the user.
3. For beginning insertion, shift elements right and place the value at index 0.
4. For end insertion, place the value after the last element.
5. For position insertion, shift elements from the target location.
6. Insert the value into the desired position.
7. Increase the logical size of the array.
8. Display the updated array and stop.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 03: Array Deletion
Problem Statement: (Same as original assignment)
Algorithm:
1. Start the program.
2. Initialize the array and current size.
3. Delete from beginning by shifting elements left.
4. Delete from end by decreasing size.
5. Delete from a specific position by shifting remaining elements.
6. Reduce the array size.
7. Display the updated array.
8. End the program.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 04: Linear Search
Problem Statement: (Same as original assignment)
Algorithm:
1. Start.
2. Read array size and elements.
3. Input the search key.
4. Compare the key with each element one by one.
5. If a match is found, print the index.
6. Stop searching after a successful match.
7. If no match exists, print a not-found message.
8. End.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 05: Binary Search
Problem Statement: (Same as original assignment)
Algorithm:
1. Start.
2. Use a sorted array.
3. Set low and high boundaries.
4. Calculate the middle index.
5. Compare the middle element with the target value.
6. Move left or right depending on the comparison.
7. Repeat until found or search space becomes empty.
8. Display result and stop.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 06: Bubble Sort
Problem Statement: (Same as original assignment)
Algorithm:
1. Start.
2. Store unsorted values in an array.
3. Compare adjacent elements.
4. Swap elements when required.
5. Repeat the process for multiple passes.
6. Place larger values at the end after each pass.
7. Print the sorted array.
8. End.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 07: Selection Sort
Problem Statement: (Same as original assignment)
Algorithm:
1. Start.
2. Assume the current position contains the minimum value.
3. Search the remaining portion of the array.
4. Identify the smallest element.
5. Swap it with the current position.
6. Move to the next position.
7. Repeat until sorting is complete.
8. Display the sorted array and end.
Code: Use the same code provided in the original assignment.
Output: Same as original output.
Problem 08: Insertion Sort
Problem Statement: (Same as original assignment)
Algorithm:
1. Start.
2. Treat the first element as sorted.
3. Pick the next element as the key.
4. Shift larger elements one position right.
5. Insert the key into its correct position.
6. Repeat for all remaining elements.
7. Display the sorted array.
8. End the program.
Code: Use the same code provided in the original assignment.
Output: Same as original output.