This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:bkenne11:portfolio:bogosort [2011/12/15 22:15] – [Objectives] bkenne11 | user:bkenne11:portfolio:bogosort [2011/12/15 22:23] (current) – [References] bkenne11 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for Data Structures by Brandon Kennedy during the Fall 2011 Semester. | ||
+ | |||
+ | This project was begun on 12-15-2011 and is anticipated to take 2 hours. | ||
+ | =====Objectives===== | ||
+ | The purpose of this project is to straight up have some fun. I am going to implement a bogosort program that will sort integers from lowest to highest value and output them. | ||
+ | |||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * wikipedia on bogosorts. | ||
+ | |||
+ | =====Background===== | ||
+ | The background to this project is to have some fun on my last project. I need another sort so i am implementing a bogo sort program. | ||
+ | |||
+ | =====Attributes===== | ||
+ | State and justify the attributes you'd like to receive upon successful approval and completion of this project. | ||
+ | |||
+ | * attribute1: sorts -> this is a bogo sorting implementation. | ||
+ | |||
+ | =====Code===== | ||
+ | <code c 1> | ||
+ | //bogo.c, a bogosort implementation for Data Structures | ||
+ | //By Brandon Kennedy | ||
+ | //compile: gcc -o bogo bogo.c | ||
+ | //run ./bogo | ||
+ | # | ||
+ | # | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | int size=10; | ||
+ | int tmp=0, | ||
+ | int value[size]; | ||
+ | char sort = ' | ||
+ | for(i=0; | ||
+ | { | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | } | ||
+ | while(sort == ' | ||
+ | { | ||
+ | sort = ' | ||
+ | one = (rand() % size); | ||
+ | two = (rand() % size); | ||
+ | tmp = value[one]; | ||
+ | value[one] = value[two]; | ||
+ | value[two] = tmp; | ||
+ | for(i=0; | ||
+ | { | ||
+ | if(value[i] > value[i+1]) | ||
+ | sort = ' | ||
+ | } | ||
+ | } | ||
+ | for(i=0; | ||
+ | printf(" | ||
+ | return 0; | ||
+ | } | ||
+ | </ | ||
+ | =====Execution===== | ||
+ | Again, if there is associated code with the project, and you haven' | ||
+ | |||
+ | <cli> | ||
+ | . 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 90 lab46: | ||
+ | enter a value for slot 0: 1 | ||
+ | enter a value for slot 1: 3 | ||
+ | enter a value for slot 2: 2 | ||
+ | enter a value for slot 3: 5 | ||
+ | enter a value for slot 4: 4 | ||
+ | enter a value for slot 5: 7 | ||
+ | enter a value for slot 6: 6 | ||
+ | enter a value for slot 7: 9 | ||
+ | enter a value for slot 8: 8 | ||
+ | enter a value for slot 9: 0 | ||
+ | . 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 lab46: | ||
+ | enter a value for slot 0: 1 | ||
+ | enter a value for slot 1: 2 | ||
+ | enter a value for slot 2: 4 | ||
+ | enter a value for slot 3: 3 | ||
+ | enter a value for slot 4: 7 | ||
+ | enter a value for slot 5: 5 | ||
+ | enter a value for slot 6: 8 | ||
+ | enter a value for slot 7: 9 | ||
+ | enter a value for slot 8: 6 | ||
+ | enter a value for slot 9: 10 | ||
+ | . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10 lab46: | ||
+ | enter a value for slot 0: 12 | ||
+ | enter a value for slot 1: 345 | ||
+ | enter a value for slot 2: 67 | ||
+ | enter a value for slot 3: 945 | ||
+ | enter a value for slot 4: 35 | ||
+ | enter a value for slot 5: 65 | ||
+ | enter a value for slot 6: 4 | ||
+ | enter a value for slot 7: 32 | ||
+ | enter a value for slot 8: 76 | ||
+ | enter a value for slot 9: 54 | ||
+ | . 4 . 12 . 32 . 35 . 54 . 65 . 67 . 76 . 345 . 945 lab46: | ||
+ | lab46: | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | =====Reflection===== | ||
+ | Bogosorts are crap, they really are... it could take who knows how long to sort a bag of numbers by shaking it and dumping it on the floor... I have deffinitely seen the light on how 0(n) calculations are important. | ||
+ | =====References===== | ||
+ | In performing this project, the following resources were referenced: | ||
+ | |||
+ | * wiki on bogosorts to get the flow of things :p |