Objective-C Implementation of semi-search, selection of sorting, Bubble sorting and quick sorting, and bubble objective-c

Source: Internet
Author: User

Objective-C Implementation of semi-search, selection of sorting, Bubble sorting and quick sorting, and bubble objective-c
Objective-C Implementation of semi-search, selection of sorting, Bubble sorting, and quick sorting

-(IBAction) zheBanChaZhao :( id) sender {NSMutableArray * allObj = [[NSMutableArray alloc] init]; int base = 0; int findY = arc4random () % 1000; for (int I = 1; I <100; I ++) {int tmpX = arc4random () % 10; base + = tmpX; [allObj addObject: [NSNumber numberWithInt: base];} NSMutableString * mulStr = [[NSMutableString alloc] init]; NSInteger count = [allObj count]; for (NSInteger I = 0; I
 
  
TmpInt) {low = mid + 1;} else {index = mid; break;} if (index! =-1) {NSLog (@ "% ld digit found", index);} else {NSLog (@ "\ n not found ");}} -(IBAction) xuanZhePaiXu :( id) sender {NSMutableArray * allObj = [[NSMutableArray alloc] init]; for (int I = 1; I <30; I ++) {int tmpX = arc4random () % 100; [allObj addObject: [NSNumber numberWithInt: tmpX];} NSMutableString * mulStr = [[NSMutableString alloc] init]; NSInteger count = [allObj count]; for (NSInteger I = 0; I
  
   
[JNum integerValue]) {[allObj exchangeObjectAtIndex: j withObjectAtIndex: I] ;}} mulStr = [[NSMutableString alloc] init]; for (NSInteger I = 0; I
   
    
= RightIndex) {// return if the array length is 0 or 1;} NSInteger I = leftIndex; NSInteger j = rightIndex; // record benchmark number NSInteger key = [array [I] integerValue]; while (I <j) {/***** first, start from j on the Right To Find A value smaller than the base number. ***/while (I <j & [array [j] integerValue]> = key) {// if it is larger than the benchmark number, continue to search for j --;} // if it is smaller than the benchmark number, swap the small value to the position I, array [I] = array [j]; /***** when a value smaller than the benchmark value is found on the right side, start from I and find the value larger than the reference number ***/while (I <j & [array [I] integerValue] <= key) {// if it is smaller than the benchmark number, continue to search for I ++;} // if it is larger than the benchmark number, place the searched cursor to the j position array [j] = array [I];} // place the baseline number in the correct position array [I] = @ (key ); // [self kuaiSu: array withLeftIndex: leftIndex andRightIndex: I-1] on the left of the benchmark number; // [self kuaiSu: array withLeftIndex: I + 1 andRightIndex: rightIndex];}
   
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.