Skip to main content

Sorting Algorithms

 

Sorting Algorithms

Bucket sort

This is an algorithm that works by distributing elements into several buckets, then sorting these buckets individually and then merging them to get a sorted result. Its particularly useful when the input is evenly distributed over a range. The worst-case time complexity is when most of the elements are placed in a single bucket as it leads to further sorting which takes longer.


Bubble sort

This is one of the simplest sorting algorithms. It repetitively steps through the list, compares adjacent elements, and swaps them if there in the wrong order. This process continues till the list is sorted. This makes it not time efficient for large lists or for an array to be in reverse order as these forces the algorithm to make the maximum number of comparisons and swaps.


Quick sort

This is one of the most efficient sorting algorithms and it uses a divide and conquer approach. It picks a pivot element and partition the array around the pivot placing elements smaller than the pivot to its left and larger elements to its right. I then recursively apply this process to the left and right subarrays until the entire array is sorted. The worst-case time complexity is when the chosen pivot is consistently the smallest or largest element in the array, which will lead to unbalanced partitioning’s.

Comments

Post a Comment

Popular posts from this blog

Types of network adapters in virtual box

  Types of network adapters in VirtualBox In VirtualBox there’s multiple types of network adapters that can be used to configure virtual machines for different networking needs. Down below will give you a brief overview of each type. NAT (network address translation) The VM is placed behind a VirtualBox-managed router. This allows the VM to access the external network via the networks host’s IP, but the VM itself remains invisible to the outside. Its most suitable for simple internet access with minimal configuration NAT network This is like NAT, but it allows multiple VM’s to communicate with each other in the same NAT network all while sharing the host’s internet connection. Its commonly used when you want to simulate a small, isolated network of VM’s that can also access the internet. Bridged adapter This VM is connected directly to the physical network as if it is a separate device, it also receives its own IP address from the same network as the host. This is ide...
  Designing a SOHO network with DHCP Network requirements for the office Sales department – 4 computers Finance department – 3 computers Networking devices requirement: ·          1 router ·          2 switches (one for each department) ·          1 DHCP server Documentation I started by setting up the network topology and used the automatic connecting cable to connect all the devices together. Then I configured the server with IPv4 address and a subnet mask. to do this you have to press on the server and then go to desktop. Then I filled in all the parameters as seen below. Then I had to configure the DHCP server. To do this I clicked on the server > services > DHCP. Then I turned on the serves and configured the server as seen in this screenshot. For the next step I configured the router with the IPv4 address and subnet mask. To a...

What's the difference between JIRA, MS project and Trello

  What's the difference between JIRA, MS project and Trello Jira, Microsoft Project, and Trello are all project management tools, but they have different features, functionalities, and target audiences. Here's a comparison of the key differences between them:   Target Audience and Use Cases: Jira: Primarily used by software development teams and Agile practitioners. It offers extensive features for issue tracking, bug tracking, project management, and Agile methodologies such as Scrum and Kanban. Microsoft Project: Suited for traditional project management, especially for complex projects in various industries. It provides tools for project planning, scheduling, resource management, and reporting. Trello: Designed for teams and individuals looking for a simple, visual way to manage tasks and projects. It uses boards, lists, and cards to organize and prioritize work, making it ideal for small to medium-sized teams and projects.   Features and Functionality: Jira: Offers ro...