12 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for Anil2447

Here is the code for [B][COLOR="Red"]Insertion Sort, Bubble Sort and Selection Sort[/COLOR][/B] [B]Insertion Sort[/B] [CODE] #include <stdio.h> main() { int i,j,key; int a[5]={5,2,3,4,1}; for(i=1;i<5;i++) { key=a[i]; while(i>0 && a[i-1]>key) { j=a[i]; a[i]=a[i-1]; a[i-1]=j; --i; } } int k; for(k=0;k<5;k++) {printf("%d ", a[k]);} printf("\n"); } [/CODE] [B]Bubble Sort[/B] [CODE] #include <stdio.h> …

Member Avatar for Talha_5
0
9K
Member Avatar for chubbyy.putto

I am creating 30 random from last function and the last function have pass the information to this one. I am using the bubble sort because i want to make a mode. But mode is not idea here. Anyway, it run but it show some crazy output. Here is the …

Member Avatar for chubbyy.putto
0
257
Member Avatar for Waseemaburakia

I'm trying to modify a Bibblesort code I'm writing that will count the number of instances and print out a seperate line for each instance and how many occurances it had. def BubbleSortList(MyList): ComparisonCounter = 0 for j in range ( len(MyList)): for i in range ( len(MyList)-1-j ): if …

Member Avatar for Waseemaburakia
0
289
Member Avatar for aVar++

Hi guys, I got this from my teacher and im really confused. could anyone point me in the right direction? Thanks > What does it do? > > This time I'm looking for an overall summary, in one sentence, with the word "by" in the middle: > "This function ..........., …

Member Avatar for Lucaci Andrew
0
209
Member Avatar for flopoe

Hello everyone; I am new to Python. How can we explain this code step by step. I couldn't understand some parts. myList=[43,21,12,80,3,2,35] end=len(myList)-1 while (end!=-1): swapped=-1 for i in range(0,end): if myList[i]>myList[i+1]: temp=myList[i] myList[i]=myList[i+1] myList[i+1]=temp swapped=i end=swapped print(myList)

Member Avatar for vegaseat
1
981
Member Avatar for edwarddaniel.baldeviano

Hi, everyone! This is my first post ever here in Daniweb. I experienced a problem in printing the sorted array of 5 numbers, as the following code only prints the first iteration of the loop, and it does not print the array input. Here's the code: section .data i db …

0
591
Member Avatar for kiail

I'm trying to make a bubble sort to sort numbers like 3.2, 5.8, etc(double / float numbers). I have this code so far, but I'm still trying to learn and don't know why my code isn't working the way I think it should. Any help is appreciated. [CODE]using System; using …

Member Avatar for Momerath
0
269
Member Avatar for jaymayne

Need help making a module that sorts 4 arrays this how it started out void dataSort (float sLengthArray[],float rSlopeArray[],float speedArray[], float size) { void swap (int *x,int *y); int pass,j; for (pass=0;pass < size-1; pass++) { for (a = 0;j< size-1; j++) { if (slengthArray[j] > slengthArray[j + 1]) { …

Member Avatar for zeroliken
0
255
Member Avatar for manongjulius

so. . . i guess you could say i'm kinda new here but. . . this site really helps me alot this past few days and i decided to join... i was surfing all over the internet and i can't find what's the problem with my program. this always says …

Member Avatar for manongjulius
0
281
Member Avatar for guru_iyer

I have been told to sort an array of structure(student) depending on one of its members(per) using bubble sort. I need to sort the 'student' structure in descending order of 'per'. Please help. I'm stuck!! [CODE] #include<stdio.h> #include<conio.h> struct student { char sname[20],dept[25]; int rollno; float per; }s[30]; void accept(int …

Member Avatar for guru_iyer
0
932
Member Avatar for addxztion

So uhm...I want to do the bubble sort and i found a code but actually i don't really know what's missing...ok...sorry but i am just a newbie and not so average of logic(lol. :p). My goal here is to complete this code, 'cause i tried to run it but it …

Member Avatar for addxztion
0
166
Member Avatar for pinknblu

It provides the average grade of an student. Assignment: How many students are in the class ? 3 Enter five test scores for student number 1 80 90 70 90 80 The average for student number 1 is 85 Enter five test scores for student number 2 100 60 60 …

Member Avatar for pinknblu
0
183

The End.