Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Fundamental Algorithms in Java

The document provides an overview of fundamental algorithms in Java, including sorting, searching, greedy algorithms, and dynamic programming. It explains the importance of algorithms for efficient problem solving and includes details on specific algorithms like Bubble Sort, Quicksort, Merge Sort, and Linear Search, along with their time and space complexities. The content serves as a foundational guide for understanding and implementing these algorithms in Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Fundamental Algorithms in Java

The document provides an overview of fundamental algorithms in Java, including sorting, searching, greedy algorithms, and dynamic programming. It explains the importance of algorithms for efficient problem solving and includes details on specific algorithms like Bubble Sort, Quicksort, Merge Sort, and Linear Search, along with their time and space complexities. The content serves as a foundational guide for understanding and implementing these algorithms in Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Fundamental

Algorithms in Java
Sorting, Searching, Greedy Algorithms, and
Dynamic Programming
Content

▪ What are algorithms?


▪ Fundamental algorithms in Java
– Sorting
– Searching
– Greedy algorithms
– Dynamic programming
Algorithms

▪ Definition
– set of instructions to solve a problem or
perform a task.
▪ Why are algorithms important?
– efficient problem solving
– optimized code
– scalability
– better performance
Common Algorithm Categories

▪ Sorting
▪ Searching
▪ Greedy Algorithms
▪ Dynamic Programming
Sorting
Popular Sorting Algorithms
Bubble Sort

• What is Bubble Sort?


• Compare adjacent elements and swap if needed, repeat the process.

• Time Complexity:
• O(n²)

• Time Complexity:
• O(1)
Bubble Sort Example
Quicksort

• What is Quicksort?
• is a divide-and-conquer algorithm. It picks a pivot element and partitions the array
around the pivot. Recursively sorts the subarrays.

• Time Complexity
• O(n log n) on average, O(n²) in the worst case

• Space Complexity
• O(log n)
Quicksort Example
Merge Sort

• What is Merge Sort ?


• divides the array into two halves, recursively sorts them, and then merges them
back together in a sorted order.

• Time Complexity
• O(n log n)

• Space Complexity
• O(n)
Merge Sort Example
Searching
Popular Searching Algorithms
Linear Search

• What is linear search?


• Checks every element in the array one by one until the target is found.

• Time Complexity
•O(n)
Linear Search Example
Add a Slide Title - 4
Add a Slide Title - 5

Click icon to add picture

You might also like