Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- st.Reset();
- st.Start();
- double temp;
- for (int pass = 1; pass < _arr.Length - 1; pass++)
- {
- // Count how many times this next loop
- // becomes shorter and shorter
- for (int i = 0; i < _arr.Length - pass; i++)
- {
- if (_arr[i] > _arr[i + 1])
- {
- // Exchange elements
- temp = _arr[i];
- _arr[i] = _arr[i + 1];
- _arr[i + 1] = temp;
- }
- }
- }
- st.Stop();
- Console.WriteLine("--Improvement 1--");
- Program.printArray(_arr);//Display the contents after each iteration of the algorithm
- Console.WriteLine("improvedBubbleSort 1 time taken to sort array: {0}", st.Elapsed);
Add Comment
Please, Sign In to add comment