The document discusses sorting algorithms, specifically bubble sort. It provides an overview of sorting, why it is important, and common sorting algorithms like bubble sort, selection sort, and insertion sort. It then goes into detail on how bubble sort works, providing pseudocode and examples to show how it iteratively "bubbles up" the largest values to the end of the array after each pass through the elements.
The document discusses sorting algorithms like bubble sort. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the array is fully sorted. It compares each adjacent pair of elements and swaps them if they are in the wrong order. This process is repeated until no swaps are needed, resulting in a sorted array. The document provides pseudocode and examples to illustrate how bubble sort functions in each pass through the array.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, indicating the list is fully sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list through successive swaps.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the list is fully sorted. Each pass of bubble sort places the largest remaining element in its correct place. It takes n-1 passes to fully sort a list of n elements, with each pass requiring fewer comparisons.
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...Muhammad Abuzar
The document describes the bubble sort algorithm. Bubble sort works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This process is repeated until the list is sorted. The algorithm uses a boolean flag to check if any swaps occurred, and stops early if the list is already sorted after a pass with no swaps.
The document discusses sorting algorithms like bubble sort. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the array is fully sorted. It compares each adjacent pair of elements and swaps them if they are in the wrong order. This process is repeated until no swaps are needed, resulting in a sorted array. The document provides pseudocode and examples to illustrate how bubble sort functions in each pass through the array.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
Bubble sort is an algorithm that sorts a collection of elements by repeatedly traversing the list from the first element to the last, comparing adjacent elements and swapping them if they are in the wrong order. This process is repeated until the list is fully sorted, requiring a number of passes equal to the size of the list minus one. The algorithm uses a flag to check if any swapping occurred on a given pass, and can stop early if the list is already sorted after an initial pass.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, indicating the list is fully sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list through successive swaps.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the list is fully sorted. Each pass of bubble sort places the largest remaining element in its correct place. It takes n-1 passes to fully sort a list of n elements, with each pass requiring fewer comparisons.
Bubble sort/ Exchange sort Algorithmdata structures and algorithms-2018,bs it...Muhammad Abuzar
The document describes the bubble sort algorithm. Bubble sort works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This process is repeated until the list is sorted. The algorithm uses a boolean flag to check if any swaps occurred, and stops early if the list is already sorted after a pass with no swaps.
The document describes the bubble sort algorithm through a series of animated examples. It shows the step-by-step process of sorting a list of numbers from largest to smallest by repeatedly swapping adjacent elements that are out of order until no swaps are needed.
Bubble sort is an algorithm that sorts a list of numbers by repeatedly swapping adjacent elements that are out of order. It works by comparing adjacent elements and swapping them if they are in the wrong order, "bubbling" the largest values to the end of the list over multiple iterations. The algorithm iterates through the list N-1 times, where N is the number of elements, to fully sort the list. It uses pairwise comparisons and swapping to move the largest remaining value to its correct place with each pass.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the array is fully sorted. It does this by making multiple passes through the array, comparing adjacent elements on each pass and swapping them if they are in the wrong order. The document provides an example of applying bubble sort to an array by making multiple passes and swapping elements until the array is sorted. It also includes sample C++ code to implement bubble sort.
The document discusses binary heaps and algorithms for building, inserting, and deleting elements from heaps. It begins by defining min-heaps and max-heaps, and the heap property that parent nodes are smaller than child nodes in min-heaps and larger in max-heaps. It then covers algorithms for inserting new elements by placing them at the bottom and bubbling up, deleting the minimum/maximum element by replacing it with the last element and bubbling down. The document concludes by explaining that building a heap from a list of elements can be done in linear time by placing elements in an array and percolating them down level-by-level.
The document describes a Spanish-English flashcard program for learning clothing vocabulary. It contains 14 flashcards with Spanish clothing items on one side and English translations on the other side, such as "la gorra" meaning "the hat". Navigation buttons are provided at the top and right of the interface to flip through the flashcards in any order.
The document describes a Spanish-English flashcard program for learning clothing vocabulary. It contains 14 flashcards that provide the Spanish word on one side and the English translation on the other side. Flashcards include common clothing items like hat, jeans, shirt, shoes, dress, pants, blouse, bag, wristwatch, skirt, button-down shirt, sweater, socks, and jacket. Users can flip through the cards individually or use controls to move between them.
This document appears to be a set of German-English flashcards containing clothing vocabulary words. There are 14 flashcards that show an English or picture term on one side and the German translation on the flip side. The flashcards can be navigated through using control buttons to flip between the front and back or move through the deck.
Fast and accurate metrics. Is it actually possible?Bogdan Storozhuk
This document discusses optimizations that can be made to sliding window reservoir sampling algorithms for metrics collection. It begins with an introduction and plan to analyze the "garbage problem" with these algorithms and provide step-by-step optimizations. Various approaches are presented and benchmarked, with the goal of reducing memory usage and garbage collection pauses. The final approach shown achieves better performance than earlier versions.
The document is a floor plan for the Marana Auditorium showing the layout of the stage, seating, dressing rooms, and amenities. Key elements include the stage, foyer, box office, dressing rooms on level 2, and seating plan for 604 people with rows labeled A through Y except for rows Q and I and seats 1-8 in rows K and L. Utilities such as power, data, phone, and TV outlets are indicated along with dimensions.
The document describes the bubble sort algorithm. Bubble sort works by comparing adjacent elements and swapping them into ascending order. This process is repeated, with each iteration bubbling the largest remaining element to its correct position. The algorithm has an outer loop that repeats the bubbling process N-1 times to fully sort an array of N elements. Each iteration reduces the number of comparisons needed by bubbling one element into place. Though simple, bubble sort is not very efficient for large arrays due to its quadratic time complexity.
- A complete binary tree is a tree that is completely filled, with the possible exception of the bottom level, which is filled from left to right.
- Such a tree can be stored efficiently in an array, with the left and right children and parent of each node calculable from its array position.
- A heap is a complete binary tree that follows the heap property - a parent node's key is always greater than or equal to its children's keys. Heaps allow efficient insertion and deletion of minimum/maximum elements.
The document contains examples and exercises regarding linearizing nonlinear data and finding linear regression models. It discusses rewriting exponential and logarithmic equations in linear form and using a graphing calculator to determine the best fitting regression model for a set of cost data. It estimates the cost to produce 1100 units would be approximately $251 based on an exponential regression model.
Comparative analysis between traditional aquaponics and reconstructed aquapon...bijceesjournal
The aquaponic system of planting is a method that does not require soil usage. It is a method that only needs water, fish, lava rocks (a substitute for soil), and plants. Aquaponic systems are sustainable and environmentally friendly. Its use not only helps to plant in small spaces but also helps reduce artificial chemical use and minimizes excess water use, as aquaponics consumes 90% less water than soil-based gardening. The study applied a descriptive and experimental design to assess and compare conventional and reconstructed aquaponic methods for reproducing tomatoes. The researchers created an observation checklist to determine the significant factors of the study. The study aims to determine the significant difference between traditional aquaponics and reconstructed aquaponics systems propagating tomatoes in terms of height, weight, girth, and number of fruits. The reconstructed aquaponics system’s higher growth yield results in a much more nourished crop than the traditional aquaponics system. It is superior in its number of fruits, height, weight, and girth measurement. Moreover, the reconstructed aquaponics system is proven to eliminate all the hindrances present in the traditional aquaponics system, which are overcrowding of fish, algae growth, pest problems, contaminated water, and dead fish.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
The document describes the bubble sort algorithm through a series of animated examples. It shows the step-by-step process of sorting a list of numbers from largest to smallest by repeatedly swapping adjacent elements that are out of order until no swaps are needed.
Bubble sort is an algorithm that sorts a list of numbers by repeatedly swapping adjacent elements that are out of order. It works by comparing adjacent elements and swapping them if they are in the wrong order, "bubbling" the largest values to the end of the list over multiple iterations. The algorithm iterates through the list N-1 times, where N is the number of elements, to fully sort the list. It uses pairwise comparisons and swapping to move the largest remaining value to its correct place with each pass.
The document describes the bubble sort algorithm. Bubble sort works by repeatedly swapping adjacent elements that are in the wrong order until the array is fully sorted. It does this by making multiple passes through the array, comparing adjacent elements on each pass and swapping them if they are in the wrong order. The document provides an example of applying bubble sort to an array by making multiple passes and swapping elements until the array is sorted. It also includes sample C++ code to implement bubble sort.
The document discusses binary heaps and algorithms for building, inserting, and deleting elements from heaps. It begins by defining min-heaps and max-heaps, and the heap property that parent nodes are smaller than child nodes in min-heaps and larger in max-heaps. It then covers algorithms for inserting new elements by placing them at the bottom and bubbling up, deleting the minimum/maximum element by replacing it with the last element and bubbling down. The document concludes by explaining that building a heap from a list of elements can be done in linear time by placing elements in an array and percolating them down level-by-level.
The document describes a Spanish-English flashcard program for learning clothing vocabulary. It contains 14 flashcards with Spanish clothing items on one side and English translations on the other side, such as "la gorra" meaning "the hat". Navigation buttons are provided at the top and right of the interface to flip through the flashcards in any order.
The document describes a Spanish-English flashcard program for learning clothing vocabulary. It contains 14 flashcards that provide the Spanish word on one side and the English translation on the other side. Flashcards include common clothing items like hat, jeans, shirt, shoes, dress, pants, blouse, bag, wristwatch, skirt, button-down shirt, sweater, socks, and jacket. Users can flip through the cards individually or use controls to move between them.
This document appears to be a set of German-English flashcards containing clothing vocabulary words. There are 14 flashcards that show an English or picture term on one side and the German translation on the flip side. The flashcards can be navigated through using control buttons to flip between the front and back or move through the deck.
Fast and accurate metrics. Is it actually possible?Bogdan Storozhuk
This document discusses optimizations that can be made to sliding window reservoir sampling algorithms for metrics collection. It begins with an introduction and plan to analyze the "garbage problem" with these algorithms and provide step-by-step optimizations. Various approaches are presented and benchmarked, with the goal of reducing memory usage and garbage collection pauses. The final approach shown achieves better performance than earlier versions.
The document is a floor plan for the Marana Auditorium showing the layout of the stage, seating, dressing rooms, and amenities. Key elements include the stage, foyer, box office, dressing rooms on level 2, and seating plan for 604 people with rows labeled A through Y except for rows Q and I and seats 1-8 in rows K and L. Utilities such as power, data, phone, and TV outlets are indicated along with dimensions.
The document describes the bubble sort algorithm. Bubble sort works by comparing adjacent elements and swapping them into ascending order. This process is repeated, with each iteration bubbling the largest remaining element to its correct position. The algorithm has an outer loop that repeats the bubbling process N-1 times to fully sort an array of N elements. Each iteration reduces the number of comparisons needed by bubbling one element into place. Though simple, bubble sort is not very efficient for large arrays due to its quadratic time complexity.
- A complete binary tree is a tree that is completely filled, with the possible exception of the bottom level, which is filled from left to right.
- Such a tree can be stored efficiently in an array, with the left and right children and parent of each node calculable from its array position.
- A heap is a complete binary tree that follows the heap property - a parent node's key is always greater than or equal to its children's keys. Heaps allow efficient insertion and deletion of minimum/maximum elements.
The document contains examples and exercises regarding linearizing nonlinear data and finding linear regression models. It discusses rewriting exponential and logarithmic equations in linear form and using a graphing calculator to determine the best fitting regression model for a set of cost data. It estimates the cost to produce 1100 units would be approximately $251 based on an exponential regression model.
Comparative analysis between traditional aquaponics and reconstructed aquapon...bijceesjournal
The aquaponic system of planting is a method that does not require soil usage. It is a method that only needs water, fish, lava rocks (a substitute for soil), and plants. Aquaponic systems are sustainable and environmentally friendly. Its use not only helps to plant in small spaces but also helps reduce artificial chemical use and minimizes excess water use, as aquaponics consumes 90% less water than soil-based gardening. The study applied a descriptive and experimental design to assess and compare conventional and reconstructed aquaponic methods for reproducing tomatoes. The researchers created an observation checklist to determine the significant factors of the study. The study aims to determine the significant difference between traditional aquaponics and reconstructed aquaponics systems propagating tomatoes in terms of height, weight, girth, and number of fruits. The reconstructed aquaponics system’s higher growth yield results in a much more nourished crop than the traditional aquaponics system. It is superior in its number of fruits, height, weight, and girth measurement. Moreover, the reconstructed aquaponics system is proven to eliminate all the hindrances present in the traditional aquaponics system, which are overcrowding of fish, algae growth, pest problems, contaminated water, and dead fish.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMHODECEDSIET
Time Division Multiplexing (TDM) is a method of transmitting multiple signals over a single communication channel by dividing the signal into many segments, each having a very short duration of time. These time slots are then allocated to different data streams, allowing multiple signals to share the same transmission medium efficiently. TDM is widely used in telecommunications and data communication systems.
### How TDM Works
1. **Time Slots Allocation**: The core principle of TDM is to assign distinct time slots to each signal. During each time slot, the respective signal is transmitted, and then the process repeats cyclically. For example, if there are four signals to be transmitted, the TDM cycle will divide time into four slots, each assigned to one signal.
2. **Synchronization**: Synchronization is crucial in TDM systems to ensure that the signals are correctly aligned with their respective time slots. Both the transmitter and receiver must be synchronized to avoid any overlap or loss of data. This synchronization is typically maintained by a clock signal that ensures time slots are accurately aligned.
3. **Frame Structure**: TDM data is organized into frames, where each frame consists of a set of time slots. Each frame is repeated at regular intervals, ensuring continuous transmission of data streams. The frame structure helps in managing the data streams and maintaining the synchronization between the transmitter and receiver.
4. **Multiplexer and Demultiplexer**: At the transmitting end, a multiplexer combines multiple input signals into a single composite signal by assigning each signal to a specific time slot. At the receiving end, a demultiplexer separates the composite signal back into individual signals based on their respective time slots.
### Types of TDM
1. **Synchronous TDM**: In synchronous TDM, time slots are pre-assigned to each signal, regardless of whether the signal has data to transmit or not. This can lead to inefficiencies if some time slots remain empty due to the absence of data.
2. **Asynchronous TDM (or Statistical TDM)**: Asynchronous TDM addresses the inefficiencies of synchronous TDM by allocating time slots dynamically based on the presence of data. Time slots are assigned only when there is data to transmit, which optimizes the use of the communication channel.
### Applications of TDM
- **Telecommunications**: TDM is extensively used in telecommunication systems, such as in T1 and E1 lines, where multiple telephone calls are transmitted over a single line by assigning each call to a specific time slot.
- **Digital Audio and Video Broadcasting**: TDM is used in broadcasting systems to transmit multiple audio or video streams over a single channel, ensuring efficient use of bandwidth.
- **Computer Networks**: TDM is used in network protocols and systems to manage the transmission of data from multiple sources over a single network medium.
### Advantages of TDM
- **Efficient Use of Bandwidth**: TDM all
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Sinan KOZAK
Sinan from the Delivery Hero mobile infrastructure engineering team shares a deep dive into performance acceleration with Gradle build cache optimizations. Sinan shares their journey into solving complex build-cache problems that affect Gradle builds. By understanding the challenges and solutions found in our journey, we aim to demonstrate the possibilities for faster builds. The case study reveals how overlapping outputs and cache misconfigurations led to significant increases in build times, especially as the project scaled up with numerous modules using Paparazzi tests. The journey from diagnosing to defeating cache issues offers invaluable lessons on maintaining cache integrity without sacrificing functionality.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
4. Sorting…
…
A fundamental application for computers
Done to make finding data (searching) faster
Many different algorithms for sorting
One of the difficulties with sorting is working with a fixed
size storage container (array)
if resize, that is expensive (slow)
The "simple" sorts run in quadratic time O(N2)
bubble sort
selection sort
insertion sort
4
5. Sorting…
…
To arrange a set of items in sequence.
It is estimated that 25~50% of all
computing power is used for sorting
activities.
Possible reasons:
Many applications require sorting;
Many applications perform sorting when they
don't have to;
Many applications use inefficient sorting
algorithms.
6. Sorting
Applications
To prepare a list of student ID, names, and
scores in a table (sorted by ID or name) for
easy checking.
To prepare a list of scores before letter grade
assignment.
To produce a list of horses after a race (sorted
by the finishing times) for payoff calculation.
To prepare an originally unsorted array for
ordered binary searching.
8. Bubble
Sort……
Bubble sort examines the array from start to finish,
comparing elements as it goes.
Any time it finds a larger element before a smaller
element, it swaps the two.
In this way, the larger elements are passed towards the
end.
The largest element of the array therefore "bubbles" to
the end of the array.
Then it repeats the process for the unsorted portion of the
array until the whole array is sorted.
9. Bubble
Sort……
Bubble sort works on the same general principle
as shaking a soft drink bottle.
Right after shaking, the contents are a mixture of
bubbles and soft drink, distributed randomly.
Because bubbles are lighter than the soft drink,
they rise to the surface, displacing the soft drink
downwards.
This is how bubble sort got its name, because the
smaller elements "float" to the top, while
the larger elements "sink" to the bottom.
10. "Bubbling Up" the Largest Element
77 42 35 12 101 5
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
11. "Bubbling Up" the Largest Element
5
12 101
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
77
S
w
ap
42
42 77 35
12. "Bubbling Up" the Largest Element
5
12 101
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
77
S
w
ap35
42 35 77
13. "Bubbling Up" the Largest Element
42 101
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
77
S
w
ap12
35 12 77 5
14. "Bubbling Up" the Largest Element
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
42 35 12 77 101 5
No need to swap
15. "Bubbling Up" the Largest Element
35
42
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
101
S
w
ap 5
12 77
5
101
16. "Bubbling Up" the Largest Element
Traverse a collection of elements
Move from the front to the end
“Bubble” the largest value to the end using pair-wise
comparisons and swapping
1 2 3 4 5 6
42 35 12 77 5 101
Largest value correctly placed
17. An Animated Example
98 23 45 14 6 67 33 42
to_do
index
7
N
1 2 3 4 5 6 7 8
8 did_swap true
18. An Animated Example
98 23 45 14 6 67 33 42
to_do
index
7
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
19. An Animated Example
98 23 45 14 6 67 33 42
to_do
index
7
1
N 8
Swap
1 2 3 4 5 6 7 8
did_swap false
20. An Animated Example
23 98 45 14 6 67 33 42
to_do
index
7
1
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
21. An Animated Example
23 98 45 14 6 67 33 42
to_do
index
7
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
22. An Animated Example
23 98 45 14 6 67 33 42
to_do
index
7
2
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
23. An Animated Example
23 45 98 14 6 67 33 42
to_do
index
7
2
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
24. An Animated Example
23 45 98 14 6 67 33 42
to_do
index
7
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
25. An Animated Example
23 45 98 14 6 67 33 42
to_do
index
7
3
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
26. An Animated Example
23 45 14 98 6 67 33 42
to_do
index
7
3
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
27. An Animated Example
23 45 14 98 6 67 33 42
to_do
index
7
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
28. An Animated Example
23 45 14 98 6 67 33 42
to_do
index
7
4
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
29. An Animated Example
23 45 14 6 98 67 33 42
to_do
index
7
4
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
30. An Animated Example
23 45 14 6 98 67 33 42
to_do
index
7
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
31. An Animated Example
23 45 14 6 98 67 33 42
to_do
index
7
5
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
32. An Animated Example
23 45 14 6 67 98 33 42
to_do
index
7
5
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
33. An Animated Example
23 45 14 6 67 98 33 42
to_do
index
7
6
N 8 did_swap
1 2 3 4 5 6 7 8
true
34. An Animated Example
23 45 14 6 67 98 33 42
to_do
index
7
6
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
35. An Animated Example
23 45 14 6 67 33 98 42
to_do
index
7
6
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
36. An Animated Example
23 45 14 6 67 33 98 42
to_do
index
7
7
N 8 did_swap
1 2 3 4 5 6 7 8
true
37. An Animated Example
23 45 14 6 67 33 98 42
to_do
index
7
7
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
38. An Animated Example
23 45 14 6 67 33 42 98
to_do
index
7
7
N 8
Swap
1 2 3 4 5 6 7 8
did_swap true
39. After First Pass of Outer Loop
23 45 14 6 67 33 42 98
to_do
index
7
8
N 8
Finished first “Bubble Up”
1 2 3 4 5 6 7 8
did_swap true
40. The Second “Bubble Up”
23 45 14 6 67 33 42 98
to_do
index
6
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
41. The Second “Bubble Up”
23 45 14 6 67 33 42 98
to_do
index
6
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
No Swap
42. The Second “Bubble Up”
23 45 14 6 67 33 42 98
to_do
index
6
2
N 8 did_swap
1 2 3 4 5 6 7 8
false
43. The Second “Bubble Up”
23 45 14 6 67 33 42 98
to_do
index
6
2
N 8 did_swap
1 2 3 4 5 6 7 8
false
Swap
44. The Second “Bubble Up”
23 14 45 6 67 33 42 98
to_do
index
6
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
45. The Second “Bubble Up”
23 14 45 6 67 33 42 98
to_do
index
6
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
46. The Second “Bubble Up”
23 14 45 6 67 33 42 98
to_do
index
6
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
47. The Second “Bubble Up”
23 14 6 45 67 33 42 98
to_do
index
6
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
48. The Second “Bubble Up”
23 14 6 45 67 33 42 98
to_do
index
6
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
49. The Second “Bubble Up”
23 14 6 45 67 33 42 98
to_do
index
6
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
No Swap
50. The Second “Bubble Up”
23 14 6 45 67 33 42 98
to_do
index
6
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
51. The Second “Bubble Up”
23 14 6 45 67 33 42 98
to_do
index
6
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
52. The Second “Bubble Up”
23 14 6 45 33 67 42 98
to_do
index
6
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
53. The Second “Bubble Up”
23 14 6 45 33 67 42 98
to_do
index
6
6
N 8 did_swap
1 2 3 4 5 6 7 8
true
54. The Second “Bubble Up”
23 14 6 45 33 67 42 98
to_do
index
6
6
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
55. The Second “Bubble Up”
23 14 6 45 33 42 67 98
to_do
index
6
6
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
56. After Second Pass of Outer Loop
23 14 6 45 33 42 67 98
to_do
index
6
7
N 8 did_swap
1 2 3 4 5 6 7 8
true
Finished second “Bubble Up”
57. The Third “Bubble Up”
23 14 6 45 33 42 67 98
to_do
index
5
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
58. The Third “Bubble Up”
23 14 6 45 33 42 67 98
to_do
index
5
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
Swap
59. The Third “Bubble Up”
14 23 6 45 33 42 67 98
to_do
index
5
1
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
60. The Third “Bubble Up”
14 23 6 45 33 42 67 98
to_do
index
5
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
61. The Third “Bubble Up”
14 23 6 45 33 42 67 98
to_do
index
5
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
62. The Third “Bubble Up”
14 6 23 45 33 42 67 98
to_do
index
5
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
63. The Third “Bubble Up”
14 6 23 45 33 42 67 98
to_do
index
5
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
64. The Third “Bubble Up”
14 6 23 45 33 42 67 98
to_do
index
5
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
No Swap
65. The Third “Bubble Up”
14 6 23 45 33 42 67 98
to_do
index
5
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
66. The Third “Bubble Up”
14 6 23 45 33 42 67 98
to_do
index
5
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
67. The Third “Bubble Up”
14 6 23 33 45 42 67 98
to_do
index
5
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
68. The Third “Bubble Up”
14 6 23 33 45 42 67 98
to_do
index
5
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
69. The Third “Bubble Up”
14 6 23 33 45 42 67 98
to_do
index
5
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
70. The Third “Bubble Up”
14 6 23 33 42 45 67 98
to_do
index
5
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
71. After Third Pass of Outer Loop
14 6 23 33 42 45 67 98
to_do
index
5
6
N 8 did_swap
1 2 3 4 5 6 7 8
true
Finished third “Bubble Up”
72. The Fourth “Bubble Up”
14 6 23 33 42 45 67 98
to_do
index
4
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
73. The Fourth “Bubble Up”
14 6 23 33 42 45 67 98
to_do
index
4
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
Swap
74. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
1
N 8 did_swap
1 2 3 4 5 6 7 8
true
Swap
75. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
76. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
2
N 8 did_swap
1 2 3 4 5 6 7 8
true
No Swap
77. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
78. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
3
N 8 did_swap
1 2 3 4 5 6 7 8
true
No Swap
79. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
80. The Fourth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
4
4
N 8 did_swap
1 2 3 4 5 6 7 8
true
No Swap
81. After Fourth Pass of Outer Loop
6 14 23 33 42 45 67 98
to_do
index
4
5
N 8 did_swap
1 2 3 4 5 6 7 8
true
Finished fourth “Bubble Up”
82. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
83. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
1
N 8 did_swap
1 2 3 4 5 6 7 8
false
No Swap
84. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
2
N 8 did_swap
1 2 3 4 5 6 7 8
false
85. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
2
N 8 did_swap
1 2 3 4 5 6 7 8
false
No Swap
86. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
3
N 8 did_swap
1 2 3 4 5 6 7 8
false
87. The Fifth “Bubble Up”
6 14 23 33 42 45 67 98
to_do
index
3
3
N 8 did_swap
1 2 3 4 5 6 7 8
false
No Swap
88. After Fifth Pass of Outer Loop
6 14 23 33 42 45 67 98
to_do
index
3
4
N 8 did_swap
1 2 3 4 5 6 7 8
false
Finished fifth “Bubble Up”
89. Finished “Early”
1 2 3 4 5 6 7 8
6 14 23 33 42 45 67 98
to_do
index
3
4
N 8 did_swap false
We didn’t do any swapping, so
all of the other elements must
be correctly placed.
We can “skip” the last two
passes of the outer loop.
90. Example:
#include <stdio.h>
void bubble_sort(long [], long); int main()
{
long array[100], n, c, d, swap; printf("Enter
number of elements:"); scanf("%ld", &n);
printf("Enter %ld longegersn", n); for (c = 0; c
< n; c++)
scanf("%ld", &array[c]);
bubble_sort(array, n);
printf("Sorted list in ascending order:n"); for (
c = 0 ; c < n ; c++ )
printf("%ldn", array[c]);
return 0;
}
91. void bubble_sort(long list[], long n)
{
long c, d, t;
for (c = 0 ; c < ( n - 1 ); c++)
{
for (d = 0 ; d < n - c - 1; d++)
{
if (list[d] > list[d+1])
{
t = list[d];
list[d] = list[d+1]; list[d+1]= t;
}
}
}
}
93. Selection
Sort……
Idea:
Find the largest element in the array
Exchange it with the element in the
rightmost position
Find the second largest element and
exchange it with the element in the second
rightmost position
Continue until the array is sorted
131. Example:
#include <stdio.h> main()
{
int A[20], N, Temp, i, j;
printf(" ENTER THE NUMBER OF TERMS...: ");
scanf("%d",&N);
printf("n ENTER THE ELEMENTS OF THE
ARRAY...:");
for(i=1; i<=N; i++)
{
scanf("ntt%d", &A[i]);
}
134. Insertion
Sort……
134
Idea: like sorting a hand of playing cards
Start with an empty left hand and the cards facing
down on the table.
Remove one card at a time from the table, and insert it into
the correct position in the left hand
compare it with each of the cards already in the hand, from
right to left
The cards held in the left hand are sorted
these cards were originally the top cards of the pile on the
table
135. To insert 12, we need to
make room for it by
moving first 36 and then 24.
Insertion Sort
135
140. #include<stdio.h> void main()
{
int A[20], N, Temp, i, j;
printf("ENTER THE NUMBER OF TERMS...: ");
scanf("%d", &N);
printf("n ENTER THE ELEMENTS OF THE ARRAY...:");
for(i=0; i<N; i++)
{
scanf("ntt%d",&A[i]);
}
Example: