Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
101 views

The method below has been taken from the book Data Structures & Algorithms by Robert Lafore. This method is used to bubble sort a given array. nElems is the number of elements in the array. In my ...
Azer Shukurzade's user avatar
-1 votes
1 answer
81 views

I have a question about the analysis of the bubble sort algorithm. I created the bubble sort algorithm in Python without including temporary storage. That means it directly swaps the adjacent pairs. ...
mrpotter's user avatar
-1 votes
1 answer
71 views

This is my code: #include <iostream> #include <vector> using namespace std; int BubbleSort(vector<int>, int); int main(){ vector<int> lista_y2 {1, 2, 0}; cout <&...
TRzende's user avatar
  • 21
0 votes
0 answers
33 views

I am learning assembly 64 bit in windows and I made a bubble sort algorithm but it doesn't work when I put the print in a loop instead of copying and pasting the same line with increasing amounts of ...
user14415213's user avatar
-4 votes
1 answer
78 views

I seem to have a problem to sort my list (cities and temperatures) from coldest to warmest. Here is the code for the method. static void bubblesort(List<Stad> städer, int n) { n = städer....
Aron Åkesäter's user avatar
1 vote
1 answer
78 views

I am implementing a script which compares bubble sort, insertion sort and selection sort. Although all these have a time complexity of the order of N^2, selection sort is supposed to be twice as fast ...
Dana Strong's user avatar
-1 votes
1 answer
56 views

I have been doing DSA lately on python, this time tried bubble-sort algorithm on a doubly linked list. Unfortunately, the method is not giving proper result. Please correct me, tell me where I am ...
Abhrajit Saha's user avatar
1 vote
1 answer
51 views

I have written an assembly program that sorts an array using bubble sort. I am getting errors. This is the full code: org 100h section .data array db 5, 3, 7, 1, 4, 9, 2, 8, 6 array_size db 9 ...
melissa's user avatar
  • 11
1 vote
3 answers
180 views

I can't understand why do optimized version of my bubble sorting algorithm takes not less time than unoptimized version Here is my files: main.c - here I create arrays of different sizes and run both ...
EzioMercer's user avatar
  • 2,149
1 vote
1 answer
162 views

So I was building a project that created a graph representing the bubble sort algorithm, but, the way I did is very slow and like to reorganize a vector with a hundred positions take about 3 minutes. ...
Matheus Santos da Silva's user avatar
0 votes
1 answer
83 views

This function goes through the dataset and then sorts it in ascending order. What its meant to do is stop when the list has been sorted. However, the !changed control flow statement terminates it ...
That wolphin's user avatar
0 votes
1 answer
173 views

I am trying to solve the following task: Write an assembly code in MARIE to sort the following numbers (Hexadecimal) from maximum to minimum. Numbers (HEX): 5, 35, 75, 45, 85, 25, 95, 55, 15, 65 You ...
Tyler Chetty's user avatar
3 votes
5 answers
163 views

I have a problem with a C program that is supposed to sort the environmental variables by order based on their name. However, it doesn't seem to be sorting them correctly, as the strcmp is supposed to ...
Sebastian Llaurador's user avatar
1 vote
2 answers
92 views

As mentioned above, I tried to implement a bubble sort method but every time I try to run it, it returns ones and zeroes instead of the sorted numbers. So far I've tried to look at another example of ...
whos joe's user avatar
0 votes
1 answer
89 views

I'm new to programming and currently working on an app to assist with managing my home budget. All the data is stored in an XML file. To sort vectors by date, I've implemented a bubble sort algorithm. ...
Bartosz Kowalski's user avatar
0 votes
1 answer
85 views

I have a question which needs me to sort out surnames. I'm using bubblesort, but I'm having trouble splitting the first name and the surnames. I have this going on before using my bubble sort method. ...
sherrry80989's user avatar
-1 votes
1 answer
165 views

This is my code: def sort_bubble(list): comp_counter = 0 swap_counter = 0 n = len(list) for i in range(n-1): for j in range(n-i-1): comp_counter += 1 if ...
user24819857's user avatar
0 votes
1 answer
85 views

I have a small array with 7 elements which can have values from 0 to around 6 (very small numbers). The counting sort is really very efficient with such configuration, but, I have another array to ...
GH228's user avatar
  • 3
0 votes
0 answers
93 views

Beginner here. I tried to recreate the bubble sort animation on VisuAlgo using javaFX, but I can't get the code right: public class BubbleSortController implements Initializable { @FXML ...
Andrew Appah's user avatar
1 vote
1 answer
81 views

I am an absolute java beginner and have tried to write a bubble-sort. it seems to work up to 10 digits. I thought it might be because I used int. My names are in german. I hope that doesn't bother you....
ilohk lol's user avatar
0 votes
1 answer
64 views

I am writing the code for bubble sorting in assembly and my assembler is giving me "Access violation writing location" error inside the swap label. kindly help INCLUDE irvine32.inc .data arr ...
k224058 Syed Ali Ahmed's user avatar
-1 votes
2 answers
92 views

class Node { public: int data; Node* next; Node() { //default constructor data = NULL; next = NULL; } Node(int value) { this->data = value; ...
Ronil Doshi's user avatar
0 votes
1 answer
96 views

For an assignment I had to do a Bubble Sort on a 2D array of states and their state capitals. The name of the array is stateCapitals. I am supposed to sort by the state capitals. This is the 2D array: ...
CoderGirl's user avatar
-2 votes
1 answer
44 views

I wrote a program that tries to find out the most efficient sorting algorithm, starting from a very small unsorted txt file to a very large sorted txt file. I don't know why it is Insertion sort that ...
Debby Fo's user avatar
0 votes
2 answers
451 views

I'm trying to sort an array of pointers according to the values in an array, leaving the original dataset alone. However, when I output the pointer array and then the data array, they both have the ...
ThirstyBob321's user avatar
2 votes
1 answer
187 views

For a task I got a text file with integers in it. There can be a different number of integers in each line, but it can't be more than 30. All integers in the file are separated by spaces. I need to ...
kujosyyyy's user avatar
1 vote
1 answer
350 views

I want to infer 8x4 Single port BRAM in Verilog, and I have to read the values of the RAM and sort them. In the sorting process, I need to sort the RAM data from smallest to largest by writing to the ...
Kağan's user avatar
  • 11
1 vote
2 answers
71 views

Here is my code: int main(int argc, char **argv) { int numberOfStrings, remaining; printf("Input number of strings:"); scanf("%d", &numberOfStrings); // ...
mustafalinan's user avatar
0 votes
2 answers
110 views

I'm trying to write a simple bubble sort function to sort some random data. Whenever executed though it simply prints the unsorted list as it was written initially. Where did i go wrong??? Code: #...
Charlie Webster's user avatar
0 votes
1 answer
325 views

In my recent comparison of the Bubble Sort and Bogo Sort algorithms, specifically analyzing their performance in sorting an array of length 9, Bubble Sort consistently exhibited faster sorting times (...
Hr.Panahi's user avatar
  • 608
-1 votes
2 answers
322 views

I am new to math and algortithms and very confused. I am looking for the amount of times the numbers get compared in n. in my head it goes like this. if n = 3 in the worst case scenario: [3,2,1] 3 ...
Billy's user avatar
  • 1
-1 votes
1 answer
65 views

This is my code so far. I want to sort patient records loaded from a text file. I am struggling to understand how I can access the info stored within the struct in order to rearrange it. For example, ...
leialeia's user avatar
2 votes
1 answer
345 views

I am currently learning 8086 programming and this one was demonstrated in our lab on a 8086 kit. The following code sorts sequence of numbers to ascending order: mov si, 2000 mov cl, [si] dec cl loop1:...
Awe Kumar Jha's user avatar
-1 votes
1 answer
140 views

So i tried solving this with master theorem but unsure if my solution is correct: function MixedSort(A[1..n]){ if (n==1) { return A[1]; } m = n/2; B[1 ... m] = bubbleSort(A[1......
RainBat's user avatar
  • 33
0 votes
1 answer
114 views

I've written the following code for sorting a singly linked list using bubble sort. Sorting procedure should sort the nodes of the list on the basis of the data they contain. Sorting the nodes only ...
Debbie's user avatar
  • 969
-7 votes
3 answers
614 views

I have researched bubble sort speed differences between C and Assembly language, and found that code optimization is one factor. What other factors are there to consider for bubble sort speed ...
John's user avatar
  • 17
-2 votes
2 answers
152 views

I am given an assignment, where the input will be a list and my task is to bubble sort the list to ascending order. Here's a sample input and output that I want. Input: 45 22 34 79 23 Output: 22 45 ...
Viknesh TPK's user avatar
0 votes
3 answers
454 views

We are trying to create a bubble sort that can take in an int, float, or c-string array. We already wrote the swap function that allows us to do this, but now we cannot figure out how to get it to ...
thedrooster's user avatar
0 votes
1 answer
22 views

#include <stdio.h> int main() { int a; printf("Enter the number of rows: "); scanf("%d", &a); int b; printf("Enter the number of columns: ")...
Utkarsh's user avatar
-1 votes
1 answer
453 views

So, I was tasked to create a hybrid sort function in python that would utilize bubble and merge sorts. The idea is simple; as long as the value T (threshold) is exceeded, merge sort should run ...
Talaal Bajwa's user avatar
1 vote
1 answer
71 views

I'm trying to understand haskell, I can't really be convinced about what this line of code does, can someone detail the line of code for me? Why does the foldl need to loop through the xs list twice? ...
Vladimir Sánchez Martínez's user avatar
1 vote
1 answer
66 views

I'm attempting to implement the bubble sort algorithm using recursion to sort an array of integers. However, I keep encountering a segmentation error when I compile and run the code. I've tried ...
Phoenix's user avatar
  • 13
0 votes
1 answer
89 views

I have written code to do bubble sort recursive. But I am getting Time limit exceeded. Can anyone help me to figure out why? public static void bubbleSort(int[] arr, int index, int j){ if (...
Deepak kumar soni's user avatar
0 votes
0 answers
88 views

Trying to make a basic project which is going to get values from user and the values are going to be stored on an array. But the project is not succeed. I want to fix the problem and make the project ...
birisininkodarsivi's user avatar
-1 votes
1 answer
276 views

Recently I’ve learned two basic sorting algorithms bubble and heap sort. It’s fairly clear that heap sort is a “2D” version of the “1D” bubble sort. For both algorithms, you find the largest element ...
Mr. Brown's user avatar
  • 111
-2 votes
1 answer
95 views

I have 2 different codes for sorting an array: static void bubbleSort2(int[] arr){ System.out.println( "bubble starts "); int tmp =0;int cnt =0; for (int i=0; i&...
summary's user avatar
  • 123
0 votes
1 answer
36 views

I have two parallel arrays. one is type String and the other, type int. I want to sort them in ascending order while maintaining data consistency, keeping them parallel, to get the entry with the ...
Venus Mthethwa's user avatar
0 votes
1 answer
210 views

I don't know if bubble sort is optimal under the condition that only adjacent swaps are allowed? Is there a more optimal algorithm that can directly determine the parity of the minimum number of swaps ...
埃博拉酱's user avatar
1 vote
1 answer
312 views

I want to find the number of swaps (not comparisons) needed to sort an array of length N using bubble sort, when the array contains all numbers from 0 to N-1. I wondered if you could, instead of ...
Xyon4's user avatar
  • 41
0 votes
1 answer
115 views

// Practice working with structs // Practice applying sorting algorithms #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NUM_CITIES 10 ...
Harr's user avatar
  • 101

1
2 3 4 5
38