├── iOSInterView
├── iOSInterView.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── wupeng10.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ ├── xcuserdata
│ │ └── wupeng10.xcuserdatad
│ │ │ └── xcschemes
│ │ │ ├── xcschememanagement.plist
│ │ │ └── iOSInterView.xcscheme
│ └── project.pbxproj
├── iOSInterView
│ ├── HeapNode.m
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── HeapNode.h
│ ├── main.m
│ ├── GraphNode.m
│ ├── GraphNode.h
│ ├── GraphMatrix.m
│ ├── Heap.h
│ ├── GraphMatrix.h
│ ├── StringStruct.h
│ ├── Assets.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── GraphTheory.h
│ ├── NSArray+StackAndQueue.h
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ ├── NSArraySort.h
│ ├── LinkedList.h
│ ├── AppDelegate.m
│ ├── ViewController.m
│ ├── Heap.m
│ ├── StringStruct.m
│ ├── BinarySortTree.h
│ ├── LinkedList.m
│ ├── NSArray+StackAndQueue.m
│ ├── NSArraySort.m
│ ├── GraphTheory.m
│ └── BinarySortTree.m
├── iOSInterViewTests
│ ├── Info.plist
│ └── iOSInterViewTests.m
└── iOSInterViewUITests
│ ├── Info.plist
│ └── iOSInterViewUITests.m
└── README.md
/iOSInterView/iOSInterView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView.xcodeproj/project.xcworkspace/xcuserdata/wupeng10.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wupengFEX/iOSInterView/HEAD/iOSInterView/iOSInterView.xcodeproj/project.xcworkspace/xcuserdata/wupeng10.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/HeapNode.m:
--------------------------------------------------------------------------------
1 | //
2 | // HeapNode.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/9.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "HeapNode.h"
10 |
11 | @implementation HeapNode
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/HeapNode.h:
--------------------------------------------------------------------------------
1 | //
2 | // HeapNode.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/9.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HeapNode : NSObject
12 |
13 | @property (nonatomic, assign) int key;
14 | @property (nonatomic, assign) int data;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphNode.m:
--------------------------------------------------------------------------------
1 | //
2 | // GraphNode.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/2.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "GraphNode.h"
10 |
11 | @implementation GraphNode
12 |
13 | - (instancetype)init
14 | {
15 | self = [super init];
16 | if (self) {
17 | self.arcs = [[NSMutableArray alloc] init];
18 | self.vers = [[NSMutableArray alloc] init];
19 | self.isTrav = [[NSMutableArray alloc] init];
20 | }
21 | return self;
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphNode.h:
--------------------------------------------------------------------------------
1 | //
2 | // GraphNode.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/2.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GraphNode : NSObject
12 |
13 | // 保存顶点信息
14 | @property (nonatomic, strong) NSMutableArray *vers;
15 | // 保存边的权值
16 | @property (nonatomic, strong) NSMutableArray *arcs;
17 | // 是否遍历
18 | @property (nonatomic, strong) NSMutableArray *isTrav;
19 | // 顶点数目
20 | @property (nonatomic, assign) int verNum;
21 | // 边的数目
22 | @property (nonatomic, assign) int arcNum;
23 | // 图的类型,0是无向图,1是有向图
24 | @property (nonatomic, assign) int graphType;
25 | // 是否被访问过
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphMatrix.m:
--------------------------------------------------------------------------------
1 | //
2 | // GraphMatrix.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/8.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "GraphMatrix.h"
10 |
11 | @implementation GraphMatrix
12 |
13 | - (instancetype)init {
14 | self = [super init];
15 | if (self) {
16 | // self.matrix = [[NSMutableArray alloc] init];
17 | self.vers = [[NSMutableArray alloc] init];
18 | }
19 | return self;
20 | }
21 |
22 | @end
23 |
24 |
25 | @implementation GraphMatrixNode
26 |
27 | - (instancetype)init {
28 | self = [super init];
29 | if (self) {
30 |
31 | }
32 | return self;
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Heap.h:
--------------------------------------------------------------------------------
1 | //
2 | // Heap.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/9.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "BinarySortTree.h"
11 |
12 | @interface Heap : NSObject
13 | /*
14 | * desc: 建立并返回小顶堆
15 | *
16 | * params: heap 堆, len 长度
17 | *
18 | */
19 | + (NSMutableArray *)createMinHeap:(NSMutableArray *)heap length:(int)len;
20 |
21 | /*
22 | * desc: top k
23 | *
24 | * option:
25 | * 1. 通过hash table记录输入的值,key为值,value为出现的次数
26 | * 2. 建立容量为k的小顶堆
27 | * 3. 按照hash table中的值入堆,返回结果
28 | *
29 | * params: heap 堆, len 长度
30 | */
31 | + (NSMutableArray *)findTopKMaxNum:(NSMutableArray *)heap length:(int)len;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterViewTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterViewUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphMatrix.h:
--------------------------------------------------------------------------------
1 | //
2 | // GraphMatrix.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/8.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class GraphNode;
12 |
13 | @interface GraphMatrix : NSObject
14 |
15 | // 顶点集合
16 | @property (nonatomic, strong) NSMutableArray *vers;
17 | // 邻接矩阵
18 | @property (nonatomic, strong) NSMutableArray *matrix;
19 | // 顶点数
20 | @property (nonatomic, assign) int verNum;
21 | // 边数
22 | @property (nonatomic, assign) int arcNum;
23 | // 图的类型,0是无向图,1是有向图
24 | @property (nonatomic, assign) int graphType;
25 |
26 | @end
27 |
28 |
29 | @interface GraphMatrixNode : NSObject
30 |
31 | // 节点数据
32 | @property (nonatomic, assign) id data;
33 | // 下一个节点的指针
34 | @property (nonatomic, strong) GraphMatrixNode *next;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView.xcodeproj/xcuserdata/wupeng10.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | iOSInterView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 60BAEABC1DBF230700F35185
16 |
17 | primary
18 |
19 |
20 | 60BAEAD51DBF230700F35185
21 |
22 | primary
23 |
24 |
25 | 60BAEAE01DBF230700F35185
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/StringStruct.h:
--------------------------------------------------------------------------------
1 | //
2 | // StringStruct.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/10.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface StringStruct : NSObject
12 |
13 | /*
14 | * desc: 判断是否是回文
15 | *
16 | * params: str 判断的字符串
17 | *
18 | */
19 | + (BOOL)isPanlindrome:(NSString *)str;
20 |
21 | /*
22 | * desc: 根据遍历str,key的数字,结果是str的字母加上key的数字的字母,如果大于z/Z,则循环展示
23 | *
24 | * params: str 判断的字符串
25 | *
26 | */
27 | + (NSString *)convertString:(NSString *)str withKey:(NSString *)key;
28 |
29 | /*
30 | * desc: 判断一个字符串中所有字符都是唯一的
31 | *
32 | * params: str 判断的字符串
33 | *
34 | */
35 | + (BOOL)isUnique:(NSString *)str;
36 |
37 | /*
38 | * desc: 两个字符串str,mainStr,判断是否能够使用str中的字符串来组成mainStr
39 | *
40 | * params: mainStr str
41 | *
42 | */
43 | + (BOOL)isContainString:(NSString *)mainStr combineString:(NSString *)str;
44 |
45 | /*
46 | * desc: 单词置换
47 | *
48 | * params: strA strB
49 | *
50 | */
51 | + (BOOL)permutaionString:(NSString *)strA another:(NSString *)strB;
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterViewTests/iOSInterViewTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOSInterViewTests.m
3 | // iOSInterViewTests
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOSInterViewTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOSInterViewTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/iOSInterView/iOSInterViewUITests/iOSInterViewUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOSInterViewUITests.m
3 | // iOSInterViewUITests
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iOSInterViewUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation iOSInterViewUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphTheory.h:
--------------------------------------------------------------------------------
1 | //
2 | // GraphTheory.h
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/2.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "GraphNode.h"
11 | #import "GraphMatrix.h"
12 |
13 | @interface GraphTheory : NSObject
14 |
15 | /**
16 | * desc:通过邻接矩阵的形式创建图
17 | *
18 | * params: isDG 是否是有向图,1是,0否 verNum 顶点总数,arcNum 弧的总数,vexs 顶点数组,arcInfo 弧信息,包括起始点,终止点,以及权重
19 | *
20 | */
21 | + (GraphNode *)createGraphWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo;
22 |
23 | /**
24 | * desc:通过邻接矩阵的形式创建图
25 | *
26 | * params: isDG 是否是有向图,1是,0否 verNum 顶点总数,arcNum 弧的总数,vexs 顶点数组,arcInfo 弧信息,包括起始点,终止点,以及权重
27 | *
28 | */
29 | + (GraphMatrix *)createGraphMatrixWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo;
30 |
31 | /**
32 | * desc:深度优先遍历
33 | *
34 | * params: graph 图
35 | *
36 | */
37 | + (void)graphDFS:(GraphNode *)graph;
38 |
39 | /**
40 | * desc:广度优先遍历
41 | *
42 | * params: graph 图
43 | *
44 | */
45 | + (void)graphBFS:(GraphNode *)graph;
46 |
47 | /**
48 | * desc:通过邻接矩阵求入度
49 | *
50 | * params: graph 图
51 | *
52 | */
53 | + (void)inDegree:(GraphNode *)matrix;
54 |
55 | /**
56 | * desc:通过邻接矩阵求出度
57 | *
58 | * params: graph 图
59 | *
60 | */
61 | + (void)outDegree:(GraphNode *)graph;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/NSArray+StackAndQueue.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+StackAndQueue.h
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/27.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "BinarySortTree.h"
11 |
12 | @interface NSArray (StackAndQueue)
13 |
14 | /**
15 | * desc: 入栈操作
16 | *
17 | * params: val 入栈的值
18 | */
19 | - (void)push:(id)val;
20 |
21 | /**
22 | * desc: 出栈操作
23 | *
24 | */
25 | - (id)pop;
26 |
27 | /*
28 | * desc: 栈按照队列进行输出
29 | *
30 | * params: array 输入的数组
31 | *
32 | */
33 | - (void)reverToHeap;
34 |
35 | /*
36 | * desc: 如何按照升序,使用另外一个栈来排序一个栈,如按照升序来pop
37 | *
38 | * params: array 输入的数组
39 | *
40 | */
41 | - (NSMutableArray *)sortStackWidthDoubleStack;
42 |
43 | /*
44 | * desc: 给定一个二叉树,使用栈实现中序遍历
45 | *
46 | * params: array 输入的数组
47 | *
48 | */
49 | - (void)inOrderBinaryTreeWithStack:(BinarySortTree *)root;
50 |
51 | /*
52 | * desc: 给定一个字符串,他只包括'(',')','{','}','[',']',判断输入的字符串是否是一个有效的圆括号字符串
53 | *
54 | * params: array 字符串
55 | *
56 | */
57 | + (BOOL)judgeVaildString:(NSString *)string;
58 |
59 | /*
60 | * desc: 给定一个数组,将其中的0放在数组最后
61 | *
62 | */
63 | - (void)backZero;
64 |
65 | /*
66 | * desc: 从一个数组中找到一对元素,其和是一个给数字,返回这些数字的下标
67 | *
68 | * params: array 目标数组 val 要求的值
69 | *
70 | */
71 | + (id)twoSum:(NSArray *)array value:(NSInteger)val;
72 |
73 | /*
74 | * desc: 给定一个数组,其中三个数字相加为固定值,返回所有符合要求的数
75 | *
76 | */
77 | - (NSMutableArray *)threeNumPlusToNum:(int)num;
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/NSArraySort.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Sort.h
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/28.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSArraySort : NSObject
12 |
13 | /**
14 | * desc: 冒泡排序
15 | * 1. 进行两次便利,第一个for是从 0 - arr.length, 第二次是从0到 arr.length - i - 1;
16 | * 2. 每一趟之后最后一个是最大值;
17 | *
18 | * 时间复杂度: 最好情况o(n), 最差o(n^2), 平均o(n^2)
19 | *
20 | * 空间复杂度: 0(1)
21 | */
22 | + (NSMutableArray *)bubbleSort:(NSArray *)array;
23 |
24 |
25 | /**
26 | * desc: 选择排序
27 | * 1. 分为两趟,第一趟从0-arr.length-1, 第二趟从i + 1到arr.length
28 | * 2. 每趟的结果是最小值在最左边
29 | *
30 | * 时间复杂度:最好情况o(n^2), 最差o(n^2), 平均o(n^2)
31 | *
32 | * 空间复杂度:o(1)
33 | */
34 | + (NSMutableArray *)selectSort:(NSArray *)array;
35 |
36 | /**
37 | * desc: 插入排序
38 | * 1. 分为两步,第一步,默认从第1个元素开始便利,第二趟,从该元素开始,从后往前遍历插入
39 | * 2. 每趟结束之后前面的有序+1
40 | *
41 | * 时间复杂度:最好情况o(n), 最差o(n^2), 平均o(n^2)
42 | *
43 | * 空间复杂度:o(1)
44 | */
45 | + (NSMutableArray *)insertSort:(NSArray *)array;
46 |
47 | /**
48 | * desc: 归并排序
49 | * 1. 取中间值为哨兵,将数组分为两个数组,左数组都小于等于哨兵,右边都大于哨兵
50 | * 2. 进行递归合并,合并函数为:定义一个数组,比较两数组中的第一个元素,将小的插入到result中,直到一个数组length为0
51 | * 3. 检查两数组是否长度有不为0的,如果不为0,将其接在result上面
52 | *
53 | * 时间复杂度:o(nlongn)
54 | *
55 | * 空间复杂度:0(n)
56 | */
57 | + (NSMutableArray *)mergeSort:(NSArray *)array;
58 |
59 | /**
60 | * desc: 快速排序
61 | * 1. 找到中间值,将其分为两个数组,不包括中间的值,左边的小于等于中间值,右边大于中间值;
62 | * 2. 递归调用快排,返回结果为左边数组连接中间值和右边数组
63 | *
64 | * 时间复杂度:最好情况o(nlogn), 最差o(n^2), 平均o(nlogn)
65 | *
66 | * 空间复杂度:o(logn)
67 | */
68 | + (NSMutableArray *)quickSort:(NSArray *)array;
69 |
70 | /**
71 | * desc: bucket sort
72 | * 1. 找出数组中的最大值和最小值
73 | * 2. 确定桶间距 space = (max - min + 1) / num
74 | * 3. for循环进行分桶
75 | * 1. 确定桶的索引值 index = Math.floor((arr[i] - min) / space)
76 | * 2. 入桶,如果桶对应的索引值存在,则加入其中并进行排序,否则新建该索引下的桶数组
77 | * 4. 将桶中的每个数组连接起来
78 | */
79 | + (NSMutableArray *)bucketSort:(NSMutableArray *)array numbersOfBuckets:(NSInteger)num;
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/LinkedList.h:
--------------------------------------------------------------------------------
1 | //
2 | // LinkedList.h
3 | // BinaryTree
4 | //
5 | // Created by smart on 2016/10/24.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LinkedList : NSObject
12 |
13 | /*
14 | * 前向指针
15 | */
16 | @property (nonatomic, strong) LinkedList *prev;
17 | /*
18 | * 后向指针
19 | */
20 | @property (nonatomic, strong) LinkedList *next;
21 | /*
22 | * 节点值
23 | */
24 | @property (nonatomic, assign) NSInteger data;
25 |
26 | /**
27 | * desc: 打印链表的值,打印不带环的链表,调试用
28 | *
29 | */
30 | + (void)printfLinkedList:(LinkedList *)list;
31 |
32 | /**
33 | * desc: 创建首尾不相连的单向链表
34 | *
35 | * params: array 构建链表的数组(以数字数组为例)
36 | *
37 | */
38 | + (LinkedList *)createNoCircleAndSinglyLinkedList:(NSArray *)array;
39 |
40 | /**
41 | * desc: 创建首尾不相连的双向链表
42 | *
43 | * params: array 构建链表的数组(以数字数组为例)
44 | *
45 | */
46 | + (LinkedList *)createSinglyLinkedList:(NSArray *)array;
47 |
48 | /**
49 | * desc: 创建首尾相连的双向链表
50 | *
51 | * params: array 构建链表的数组(以数字数组为例)
52 | *
53 | */
54 | + (LinkedList *)createTwoWayLinkedList:(NSArray *)array;
55 |
56 | /**
57 | * desc: 给定一个链表和一个值,对链表进行排序,使得所有小于该值的元素都在左边,大于的都在右边
58 | *
59 | * params: list 链表,val 值
60 | *
61 | */
62 | + (LinkedList *)reorderList:(LinkedList *)list value:(NSInteger)val;
63 |
64 | /**
65 | * desc: 给定一个链表,返回链表的中间点。双指针法,一个以一倍速前进,一个以二倍速前进
66 | *
67 | * params: list 链表
68 | *
69 | */
70 | + (LinkedList *)getMiddleNodeInLinkedList:(LinkedList *)list;
71 |
72 | /**
73 | * desc: 找到链表中距离最后一个元素k的那个元素
74 | *
75 | * params: list 链表,k 距离
76 | *
77 | */
78 | + (LinkedList *)getKthNodeInLinkedList:(LinkedList *)list distance:(NSInteger)k;
79 |
80 | /**
81 | * desc: 给定一个可能包含环的链表,编写一个函数返回环开始的节点,如果不包含返回nil。设置两个指针,一个是单倍速,一个二倍速,如果能够相遇则说明又环,然后使得一个指针指向头节点,然后再次以单倍速前进,相遇点即为环开始的点
82 | *
83 | * params: list 链表
84 | *
85 | */
86 | + (LinkedList *)getStartOfCircleInLinkedList:(LinkedList *)list;
87 |
88 | /**
89 | * desc: 给定一个链表,向右旋转k个位置,k是非负数,如1>2>3>4>5,k=2,旋转之后为4>5>1>2>3
90 | *
91 | * params: list 链表,k 距离
92 | *
93 | */
94 | + (LinkedList *)revertLinkedListWithK:(LinkedList *)list distance:(NSInteger)k;
95 |
96 | /**
97 | * desc: 将链表逆转并返回新的链表头
98 | *
99 | * params: list 链表,k 距离
100 | *
101 | */
102 | + (LinkedList *)revertLinkedList:(LinkedList *)list;
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ViewController.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | ViewController *vc = [[ViewController alloc] init];
21 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
22 | self.window.rootViewController = nav;
23 | [self.window makeKeyAndVisible];
24 | return YES;
25 | }
26 |
27 |
28 | - (void)applicationWillResignActive:(UIApplication *)application {
29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
31 | }
32 |
33 |
34 | - (void)applicationDidEnterBackground:(UIApplication *)application {
35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
37 | }
38 |
39 |
40 | - (void)applicationWillEnterForeground:(UIApplication *)application {
41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
42 | }
43 |
44 |
45 | - (void)applicationDidBecomeActive:(UIApplication *)application {
46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
47 | }
48 |
49 |
50 | - (void)applicationWillTerminate:(UIApplication *)application {
51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/25.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "BinarySortTree.h"
11 | #import "LinkedList.h"
12 | #import "NSArray+StackAndQueue.h"
13 | #import "NSArraySort.h"
14 | #import "GraphTheory.h"
15 |
16 | @interface ViewController ()
17 |
18 | @property (nonatomic, strong) BinarySortTree *root;
19 | @property (nonatomic, strong) NSMutableArray *treeNode;
20 |
21 | @end
22 |
23 | @implementation ViewController
24 |
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 | self.view.backgroundColor = [UIColor whiteColor];
28 |
29 | // 二叉树测试
30 | // NSArray *binaryTree = @[@7,@2,@1,@4,@6,@8,@9,@34,@21,@23,@12];
31 | // BinarySortTree *root = [BinarySortTree binarySortTreeCreate:binaryTree];
32 | //
33 | // // 数组测试
34 | // NSMutableArray *stack = [[NSMutableArray alloc] init];
35 | // [stack push:@1];
36 | // [stack push:@4];
37 | // [stack push:@2];
38 | // [stack push:@5];
39 | // [stack push:@8];
40 | // [stack push:@7];
41 | // [stack push:@6];
42 | //// [stack pop];
43 | //// [stack reverToHeap];
44 | //// [stack sortStackWidthDoubleStack];
45 | // [stack inOrderBinaryTreeWithStack:root];
46 | // NSLog(@"array is %@;", stack);
47 | //
48 | // NSString *charString = @"({[]})";
49 | // [NSArray judgeVaildString:charString];
50 |
51 | // NSMutableArray *binaryTree = [[NSMutableArray alloc] initWithObjects:@7,@2,@1,@4,@6,@8,@9,@34,@21,@23,@12,nil];
52 | // NSMutableArray *array = [NSArraySort bubbleSort:binaryTree];
53 | // NSMutableArray *array = [NSArraySort selectSort:binaryTree];
54 | // NSMutableArray *array = [NSArraySort insertSort:binaryTree];
55 | // NSMutableArray *array = [NSArraySort mergeSort:binaryTree];
56 | // NSMutableArray *array = [NSArraySort quickSort:binaryTree];
57 | // NSMutableArray *array = [NSArraySort bucketSort:binaryTree numbersOfBuckets:5];
58 | // NSLog(@"%@", array);
59 |
60 | // 测试图
61 | NSArray *dict = @[
62 | @{
63 | @"start": @"A",
64 | @"end": @"D",
65 | @"weight": @"1"
66 | },
67 | @{
68 | @"start": @"A",
69 | @"end": @"B",
70 | @"weight": @"2"
71 | },
72 | @{
73 | @"start": @"B",
74 | @"end": @"C",
75 | @"weight": @"3"
76 | },
77 | @{
78 | @"start": @"C",
79 | @"end": @"E",
80 | @"weight": @"9"
81 | }
82 | ];
83 | NSArray *vexs = @[@"A", @"B", @"C", @"D", @"E"];
84 | GraphNode *node = [GraphTheory createGraphWithInfo:0 numberOfVex:5 numberOfArc:4 vexArray:vexs arcInfo:dict];
85 | // [GraphTheory graphDFS:node];
86 | [GraphTheory graphBFS:node];
87 | }
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/Heap.m:
--------------------------------------------------------------------------------
1 | //
2 | // Heap.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/9.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "Heap.h"
10 | #import "HeapNode.h"
11 |
12 | @implementation Heap
13 |
14 | + (NSMutableArray *)createMinHeap:(NSMutableArray *)heap length:(int)len {
15 | if (!([heap isKindOfClass:[NSMutableArray class]] && [heap count] > 0)) {
16 | return nil;
17 | }
18 | if (len <= 0) {
19 | return nil;
20 | }
21 |
22 | NSMutableArray *heapArray = [[NSMutableArray alloc] initWithCapacity:len];
23 | for (int i = 0; i < len; i++) {
24 | heapArray[i] = [NSNumber numberWithInteger:i];
25 | }
26 | NSMutableArray *arr = [self buildMinHeap:heapArray length:len];
27 | for (NSInteger i = [heap count] - 1; i >= 0 ; i--) {
28 | [self replaceNum:arr length:len value:[heap[i] intValue]];
29 | }
30 | return heapArray;
31 | }
32 |
33 | + (NSMutableArray *)findTopKMaxNum:(NSMutableArray *)heap length:(int)len {
34 | if (!([heap isKindOfClass:[NSMutableArray class]] && [heap count] > 0)) {
35 | return nil;
36 | }
37 | if (len <= 0) {
38 | return nil;
39 | }
40 |
41 | // QUERY统计
42 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
43 | for (int i = 0; i < [heap count]; i++) {
44 | NSNumber *key = [NSNumber numberWithInteger:[heap[i] intValue]];
45 | dict[key] = [NSNumber numberWithInteger:[dict[key] intValue] + 1];
46 | }
47 |
48 | // 建立小顶堆
49 | NSMutableArray *heapArray = [[NSMutableArray alloc] initWithCapacity:len];
50 | for (int i = 0; i < len; i++) {
51 | heapArray[i] = [NSNumber numberWithInteger:i];
52 | }
53 | NSMutableArray *arr = [self buildMinHeap:heapArray length:len];
54 |
55 | // 筛选
56 | for (id num in dict) {
57 | for (int i = 0; i < [dict[num] intValue]; i++) {
58 | [self replaceNum:arr length:len value:[num intValue]];
59 | }
60 | }
61 |
62 | return nil;
63 | }
64 |
65 | + (NSMutableArray *)buildMinHeap:(NSMutableArray *)heap length:(int)len {
66 | if (!([heap isKindOfClass:[NSMutableArray class]] && [heap count] > 0)) {
67 | return nil;
68 | }
69 | if (len <= 0) {
70 | return nil;
71 | }
72 |
73 | int middle = len / 2 - 1;
74 | for (int i = middle; i >= 0; i--) {
75 | [self heapAdjust:heap length:len index:i];
76 | }
77 |
78 | return heap;
79 | }
80 |
81 | + (void)heapAdjust:(NSMutableArray *)heap length:(int)len index:(int)index {
82 | if (!([heap isKindOfClass:[NSMutableArray class]] && [heap count] > 0)) {
83 | return;
84 | }
85 | if (len <= 0) {
86 | return;
87 | }
88 |
89 | int left = 2 * (index + 1) - 1;
90 | int right = 2 * (index + 1);
91 | int smallest = index;
92 |
93 | if (left < len && heap[left] < heap[smallest]) {
94 | smallest = left;
95 | }
96 | if (right < len && heap[right] < heap[smallest]) {
97 | smallest = right;
98 | }
99 |
100 | if (smallest != index) {
101 | id temp = heap[index];
102 | heap[index] = heap[smallest];
103 | heap[smallest] = temp;
104 | [self heapAdjust:heap length:len index:smallest];
105 | }
106 | }
107 |
108 | + (void)replaceNum:(NSMutableArray *)heap length:(int)len value:(int)val {
109 | if (!([heap isKindOfClass:[NSMutableArray class]] && [heap count] > 0)) {
110 | return;
111 | }
112 |
113 | if ([heap[0] intValue] < val) {
114 | heap[0] = heap[len - 1];
115 | heap[len - 1] = [NSNumber numberWithInteger:val];
116 | [self heapAdjust:heap length:--len index:0];
117 | }
118 | }
119 |
120 | @end
121 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView.xcodeproj/xcuserdata/wupeng10.xcuserdatad/xcschemes/iOSInterView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/StringStruct.m:
--------------------------------------------------------------------------------
1 | //
2 | // StringStruct.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/10.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "StringStruct.h"
10 |
11 | @implementation StringStruct
12 |
13 | // 判断是否是回文
14 | + (BOOL)isPanlindrome:(NSString *)str {
15 | if (!([str isKindOfClass:[NSString class]] && str.length > 0)) {
16 | return NO;
17 | }
18 |
19 | int i = 0;
20 | int j = (int)str.length - 1;
21 |
22 | while (i < j) {
23 | char c = [str characterAtIndex:i];
24 | char d = [str characterAtIndex:j];;
25 | if (![self isVaildChar:c]) {
26 | i++;
27 | continue;
28 | }
29 |
30 | if (![self isVaildChar:d]) {
31 | j--;
32 | continue;
33 | }
34 |
35 | if ([self lowerCase:c] != [self lowerCase:d]) {
36 | return NO;
37 | }
38 | i++;
39 | j--;
40 | }
41 | return YES;
42 | }
43 |
44 | + (BOOL)isVaildChar:(char)c {
45 | return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
46 | }
47 |
48 | + (char)lowerCase:(char)character {
49 | if (character >= 'A' && character <= 'Z') {
50 | character = character - 'A' + 'a';
51 | }
52 | return character;
53 | }
54 |
55 | // 根据遍历str,key的数字,结果是str的字母加上key的数字的字母,如果大于z/Z,则循环展示
56 | + (NSString *)convertString:(NSString *)str withKey:(NSString *)key {
57 | if (str.length == 0 || key.length == 0) {
58 | return nil;
59 | }
60 |
61 | NSString *newStr = @"";
62 | int j = 0;
63 |
64 | for (int i = 0; i < str.length; i++) {
65 | char character = [str characterAtIndex:i];
66 | int keyChar;
67 | char characterOne = character;
68 |
69 | if (character >= 'a' && character <= 'z') {
70 | keyChar = [[key substringWithRange:NSMakeRange(j % key.length, 1)] intValue];
71 | characterOne = (character + keyChar) > 'z' ? ('a' + (character + keyChar) % 'z' - 1) : (character + keyChar);
72 | j++;
73 | }
74 | else if (character >= 'A' && character <= 'Z') {
75 | keyChar = [[key substringWithRange:NSMakeRange(j % key.length, 1)] intValue];
76 | characterOne = (character + keyChar) > 'Z' ? ('A' + (character + keyChar) % 'Z' - 1) : (character + keyChar);
77 | j++;
78 | }
79 |
80 | newStr = [newStr stringByAppendingFormat:@"%c", characterOne];
81 | NSLog(@"%c", characterOne);
82 | }
83 | return newStr;
84 | }
85 |
86 | // 判断一个字符串中所有字符都是唯一的
87 | + (BOOL)isUnique:(NSString *)str {
88 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
89 | BOOL isUnique = YES;
90 |
91 | for (NSInteger i = 0; i < str.length; i++) {
92 | NSString *character = [str substringWithRange:NSMakeRange(i, 1)];
93 | if (character && !dict[character]) {
94 | dict[character] = @"1";
95 | }
96 | else {
97 | isUnique = NO;
98 | break;
99 | }
100 | }
101 | return isUnique;
102 | }
103 |
104 |
105 | // 两个字符串str,mainStr,判断是否能够使用str中的字符串来组成mainStr
106 | + (BOOL)isContainString:(NSString *)mainStr combineString:(NSString *)str {
107 | if (!(mainStr.length > 0 &&
108 | str.length > 0 &&
109 | str.length > mainStr.length)) {
110 | return NO;
111 | }
112 |
113 | BOOL isContain = YES;
114 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
115 | for (NSInteger i = 0; i < str.length; i++) {
116 | NSString *character = [str substringWithRange:NSMakeRange(i, 1)];
117 | dict[character] = [NSNumber numberWithInteger:([dict[character] intValue] + 1)];
118 | }
119 |
120 | for (NSInteger i = 0; i < mainStr.length; i++) {
121 | NSString *character = [str substringWithRange:NSMakeRange(i, 1)];
122 | if ([dict[character] intValue]) {
123 | dict[character] = [NSNumber numberWithInteger:[dict[character] intValue] - 1];
124 | }
125 | else {
126 | isContain = NO;
127 | break;
128 | }
129 | }
130 |
131 | return isContain;
132 | }
133 |
134 | // 判断两个字符串是否可以置换
135 | + (BOOL)permutaionString:(NSString *)strA another:(NSString *)strB {
136 | if (strA.length != strB.length) {
137 | return NO;
138 | }
139 |
140 | NSMutableDictionary *dictA = [[NSMutableDictionary alloc] init];
141 | NSMutableDictionary *dictB = [[NSMutableDictionary alloc] init];
142 | for (NSInteger i = 0; i < strA.length; i++) {
143 | NSString *charA = [strA substringWithRange:NSMakeRange(i, 1)];
144 | NSString *charB = [strB substringWithRange:NSMakeRange(i, 1)];
145 | dictA[charA] = [NSNumber numberWithInteger:[dictA[charA] intValue] + 1];
146 | dictB[charB] = [NSNumber numberWithInteger:[dictB[charA] intValue] + 1];
147 | }
148 |
149 | for (NSString *key in [dictA allKeys]) {
150 | if (dictB[key]) {
151 | dictB[key] = [NSNumber numberWithInteger:[dictB[key] intValue] - 1];
152 | }
153 | else {
154 | return NO;
155 | }
156 | }
157 |
158 | return YES;
159 | }
160 |
161 | @end
162 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/BinarySortTree.h:
--------------------------------------------------------------------------------
1 | //
2 | // BinarySortTree.h
3 | // BinaryTree
4 | //
5 | // Created by smart on 2016/10/21.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface BinarySortTree : NSObject
12 |
13 | /*
14 | * 左孩子
15 | */
16 | @property (nonatomic, strong) BinarySortTree *leftNode;
17 | /*
18 | * 右孩子
19 | */
20 | @property (nonatomic, strong) BinarySortTree *rightNode;
21 | /*
22 | * 节点值
23 | */
24 | @property (nonatomic, assign) NSInteger value;
25 |
26 | /**
27 | * desc: 二叉排序树的创建,每次都要从顶部元素开始遍历,小于其的放在左边,大于的放在右边
28 | *
29 | * params:根结点,node的值
30 | *
31 | */
32 | + (BinarySortTree *)binarySortTreeCreate:(NSArray *)tree;
33 |
34 | /**
35 | * desc: 先序遍历
36 | *
37 | * params: 根结点,压栈操作的block
38 | *
39 | */
40 | + (void)preOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
41 |
42 | /**
43 | * desc: 中序遍历
44 | *
45 | * params: 根结点,压栈操作的block
46 | *
47 | */
48 | + (void)inOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
49 |
50 | /**
51 | * desc: 后序遍历
52 | *
53 | * params: 根结点,压栈操作的block
54 | *
55 | */
56 | + (void)postOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
57 |
58 | /**
59 | * desc: 层次遍历(广度优先)
60 | *
61 | * params: 根结点,压栈操作的block
62 | *
63 | */
64 | + (void)levelTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
65 |
66 | /**
67 | * desc: 返回二叉树的深度
68 | *
69 | * params: root 跟节点
70 | *
71 | */
72 | + (NSInteger)depthOfTree:(BinarySortTree *)root;
73 |
74 | /**
75 | * desc: 返回二叉树的宽度
76 | *
77 | * params: root 跟节点
78 | *
79 | */
80 | + (NSInteger)widthOfTree:(BinarySortTree *)root;
81 |
82 | /**
83 | * desc: 返回二叉树的全部节点数
84 | *
85 | * params: root 跟节点
86 | *
87 | */
88 | + (NSInteger)numbersOfNodesInTree:(BinarySortTree *)root;
89 |
90 | /**
91 | * desc: 返回二叉树的叶子节点
92 | *
93 | * params: root 跟节点
94 | *
95 | */
96 | + (NSInteger)numbersOfLeafsInTree:(BinarySortTree *)root;
97 |
98 | /**
99 | * desc: 返回二叉树中某个节点到跟节点的路径
100 | *
101 | * params: root 跟节点,node 指定节点
102 | *
103 | */
104 | + (NSMutableArray *)pathOfNodeInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
105 |
106 | /**
107 | * desc: 二叉树中两个节点最近的公共父节点
108 | *
109 | * params: root 跟节点,nodeA/nodeB 两节点
110 | *
111 | */
112 | + (BinarySortTree *)publicNodeOfTwoNodesIntree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB;
113 |
114 | /**
115 | * desc: 二叉树两个节点之间的距离
116 | *
117 | * params: root 跟节点,nodeA/nodeB 两节点
118 | *
119 | */
120 | + (NSInteger)distanceOfTwoNodesInTree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB;
121 |
122 | /**
123 | * desc: 翻转二叉树
124 | *
125 | * params: root 跟节点
126 | *
127 | */
128 | + (BinarySortTree *)invertBinaryTree:(BinarySortTree *)root;
129 |
130 | /**
131 | * desc: 判断二叉树是否完全二叉树
132 | *
133 | * params: root 跟节点
134 | *
135 | */
136 | + (BOOL)isCompleteBinaryTree:(BinarySortTree *)root;
137 |
138 | /**
139 | * desc: 判断二叉树是否满二叉树
140 | *
141 | * params: root 跟节点
142 | *
143 | */
144 | + (BOOL)isFullBinaryTree:(BinarySortTree *)root;
145 |
146 | /**
147 | * desc: 判断二叉树是否平衡二叉树
148 | *
149 | * params: root 跟节点
150 | *
151 | */
152 | + (BOOL)isAVLBinaryTree:(BinarySortTree *)root;
153 |
154 | /**
155 | * desc: 返回二叉树第i层节点数
156 | *
157 | * params: root 跟节点,level 层级
158 | *
159 | */
160 | + (NSInteger)numbersOfLevelInTree:(BinarySortTree *)root level:(NSInteger)level;
161 |
162 | /**
163 | * desc: 二叉排序树插入节点
164 | *
165 | * params:根结点,插入的值
166 | *
167 | */
168 | + (BinarySortTree *)insertNodeToTree:(BinarySortTree *)root nodeValue:(NSInteger)value;
169 |
170 | /**
171 | * desc: 删除排序二叉树中的节点,三种情况:1.删除节点是叶子结点,2.删除节点只有左/右子树,3.删除节点左右子树都有
172 | *
173 | * params:根结点,插入的值
174 | *
175 | */
176 | + (void)deleteNodeInTree:(BinarySortTree *)root deleteNode:(NSInteger)value;
177 |
178 | /**
179 | * desc: 判断一棵树是否是二叉搜索树,二叉搜索树特点:父节点的值大于所有左子树的值,小于所有右子树的值,前提是假设所有值没有相同的
180 | *
181 | * params:根结点,插入的值
182 | *
183 | */
184 | + (BOOL)isBinarySearchTree:(BinarySortTree *)root;
185 |
186 | /**
187 | * desc: 判断一棵树是否是另一棵树的子树
188 | *
189 | * params:root 父树根节点,childNode 子树根节点
190 | *
191 | */
192 | + (BOOL)isContainTree:(BinarySortTree *)root childNode:(BinarySortTree *)childNode;
193 |
194 | /**
195 | * desc: 找出一棵二叉树中所有路径,并且其路径之和等于一个给定的值
196 | *
197 | * params: root 根节点,path 暂时存储路径的数组,vector 返回最终符合要求的数组,sum 给定值
198 | */
199 | + (void)findAllPathInTree:(BinarySortTree *)root pathArray:(NSMutableArray *)path vectore:(NSMutableArray *)vectore sum:(NSInteger)sum;
200 |
201 | /**
202 | * desc: 找出二叉树中一个节点的后继
203 | *
204 | * params: root 根节点,node 目标节点
205 | */
206 | + (BinarySortTree *)findSuccessor:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
207 |
208 | /**
209 | * desc: 找出二叉树中一个节点的前驱
210 | *
211 | * params: root 根节点,node 目标节点
212 | */
213 | + (BinarySortTree *)findPrecursor:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
214 |
215 | /**
216 | * desc: 序列化二叉树
217 | *
218 | * params: root 根节点
219 | */
220 | + (NSString *)serializeBinaryTree:(BinarySortTree *)root;
221 |
222 | /**
223 | * desc: 反序列化二叉树
224 | *
225 | * params: root 根节点
226 | */
227 | + (BinarySortTree *)deserializeBinaryTree:(NSString *)serialString;
228 |
229 | @end
230 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/LinkedList.m:
--------------------------------------------------------------------------------
1 | //
2 | // LinkedList.m
3 | // BinaryTree
4 | //
5 | // Created by smart on 2016/10/24.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "LinkedList.h"
10 |
11 | @implementation LinkedList
12 |
13 | // 打印链表的值,打印不带环的链表
14 | + (void)printfLinkedList:(LinkedList *)list {
15 |
16 | LinkedList *listCopy = list;
17 |
18 | while (listCopy) {
19 | NSLog(@"%@", [NSNumber numberWithInteger:listCopy.data]);
20 | listCopy = listCopy.next;
21 | }
22 | }
23 |
24 | // 创建首尾不相连的单向链表
25 | + (LinkedList *)createNoCircleAndSinglyLinkedList:(NSArray *)array {
26 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
27 | return nil;
28 | }
29 |
30 | LinkedList *head = [[LinkedList alloc] init];
31 | head.data = [[array objectAtIndex:0] intValue];
32 |
33 | LinkedList *parentNode = head;
34 | for (NSInteger i = 1; i < [array count]; i++) {
35 | LinkedList *node = [[LinkedList alloc] init];
36 | node.data = [[array objectAtIndex:i] intValue];
37 |
38 | parentNode.next = node;
39 | parentNode = node;
40 | }
41 |
42 | return head;
43 | }
44 |
45 | // 创建首尾不相连的双向链表
46 | + (LinkedList *)createSinglyLinkedList:(NSArray *)array {
47 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
48 | return nil;
49 | }
50 |
51 | LinkedList *head = [[LinkedList alloc] init];
52 | head.data = [[array objectAtIndex:0] intValue];
53 |
54 | LinkedList *parentNode = head;
55 | for (NSInteger i = 1; i < [array count]; i++) {
56 | LinkedList *node = [[LinkedList alloc] init];
57 | node.data = [[array objectAtIndex:i] intValue];
58 | node.prev = parentNode;
59 |
60 | parentNode.next = node;
61 | parentNode = node;
62 | }
63 |
64 | return head;
65 | }
66 |
67 | // 创建首尾相连的双向链表
68 | + (LinkedList *)createTwoWayLinkedList:(NSArray *)array {
69 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
70 | return nil;
71 | }
72 |
73 | LinkedList *head = [[LinkedList alloc] init];
74 | head.data = [[array objectAtIndex:0] intValue];
75 |
76 | LinkedList *parentNode = head;
77 | for (NSInteger i = 1; i < [array count]; i++) {
78 | LinkedList *node = [[LinkedList alloc] init];
79 | node.data = [[array objectAtIndex:i] intValue];
80 | node.prev = parentNode;
81 |
82 | parentNode.next = node;
83 | parentNode = node;
84 | }
85 |
86 | parentNode.next = head;
87 | head.prev = parentNode;
88 |
89 | return head;
90 | }
91 |
92 | // 给定一个链表和一个值,对链表进行排序,使得所有小于该值的元素都在左边,大于的都在右边
93 | + (LinkedList *)reorderList:(LinkedList *)list value:(NSInteger)val {
94 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
95 | return nil;
96 | }
97 |
98 | LinkedList *listA = [[LinkedList alloc] init];
99 | LinkedList *listACopy = listA;
100 | LinkedList *listB = [[LinkedList alloc] init];
101 | LinkedList *listBCopy = listB;
102 |
103 | while (list) {
104 | LinkedList *next = list.next;
105 | list.next = nil;
106 |
107 | if (list.data < val) {
108 | listACopy.next = list;
109 | listACopy = list;
110 | }
111 | else {
112 | listBCopy.next = list;
113 | listBCopy = list;
114 | }
115 | list = next;
116 | }
117 | listACopy.next = listB.next;
118 |
119 | return listA.next;
120 | }
121 |
122 | // 给定一个链表,返回链表的中间点
123 | + (LinkedList *)getMiddleNodeInLinkedList:(LinkedList *)list {
124 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
125 | return nil;
126 | }
127 |
128 | LinkedList *runner = list;
129 | LinkedList *header = list;
130 |
131 | while (header.next && runner.next.next) {
132 | header = header.next;
133 | runner = runner.next.next;
134 | }
135 |
136 | return header;
137 | }
138 |
139 | // 找到链表中距离最后一个元素k的那个元素
140 | + (LinkedList *)getKthNodeInLinkedList:(LinkedList *)list distance:(NSInteger)k {
141 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
142 | return nil;
143 | }
144 |
145 | LinkedList *runner = list;
146 | LinkedList *header = list;
147 |
148 | for (NSInteger i = 0; i < k; i++) {
149 | runner = runner.next;
150 | }
151 |
152 | if (nil == runner) {
153 | return nil;
154 | }
155 |
156 | while (runner.next) {
157 | runner = runner.next;
158 | header = header.next;
159 | }
160 |
161 | return header;
162 | }
163 |
164 | // 给定一个可能包含环的链表,编写一个函数返回环开始的节点,如果不包含返回nil
165 | + (LinkedList *)getStartOfCircleInLinkedList:(LinkedList *)list {
166 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
167 | return nil;
168 | }
169 |
170 | LinkedList *runner = list;
171 | LinkedList *header = list;
172 |
173 | while (nil != runner && nil != runner.next) {
174 | header = header.next;
175 | runner = runner.next.next;
176 | if (header == runner) {
177 | break;
178 | }
179 | }
180 |
181 | if (nil == runner && nil == runner.next) {
182 | return nil;
183 | }
184 |
185 | header = list;
186 | while (runner != header) {
187 | runner = runner.next;
188 | header = header.next;
189 | }
190 | return runner;
191 | }
192 |
193 | // 给定一个链表,向右旋转k个位置,k是非负数,如1>2>3>4>5,k=2,旋转之后为4>5>1>2>3
194 | + (LinkedList *)revertLinkedListWithK:(LinkedList *)list distance:(NSInteger)k {
195 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
196 | return nil;
197 | }
198 |
199 | LinkedList *runner = list;
200 | LinkedList *newHeader;
201 | NSInteger len = 1;
202 | while (runner.next) {
203 | len++;
204 | runner = runner.next;
205 | }
206 | runner.next = list;
207 | runner = runner.next;
208 |
209 | for (NSInteger i = 0; i < len - k - 1; i++) {
210 | runner = runner.next;
211 | }
212 | newHeader = runner.next;
213 | runner.next = nil;
214 | return newHeader;
215 | }
216 |
217 |
218 | // 将链表逆转并返回新的链表头
219 | + (LinkedList *)revertLinkedList:(LinkedList *)list {
220 | if (!(nil != list && [list isKindOfClass:[LinkedList class]])) {
221 | return nil;
222 | }
223 |
224 | LinkedList *nextNode;
225 | LinkedList *prevNode;
226 | while (list) {
227 | nextNode = list.next;
228 | list.next = prevNode;
229 | prevNode = list;
230 | list = nextNode;
231 | }
232 | return prevNode;
233 | }
234 |
235 | @end
236 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/NSArray+StackAndQueue.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+StackAndQueue.m
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/27.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "NSArray+StackAndQueue.h"
10 |
11 | @implementation NSArray (StackAndQueue)
12 |
13 | // 入栈操作
14 | - (void)push:(id)val {
15 | if ([self isKindOfClass:[NSMutableArray class]]) {
16 | [(NSMutableArray *)self addObject:val];
17 | }
18 | }
19 |
20 | // 出栈操作
21 | - (id)pop {
22 | id lastObject;
23 | if ([self isKindOfClass:[NSMutableArray class]]) {
24 | lastObject = [self lastObject];
25 | [(NSMutableArray *)self removeLastObject];
26 | }
27 | return lastObject;
28 | }
29 |
30 | // 栈按照队列进行输出
31 | - (void)reverToHeap {
32 | NSMutableArray *array = (NSMutableArray *)self;
33 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
34 | return;
35 | }
36 |
37 | NSMutableArray *heapArray = [[NSMutableArray alloc] initWithArray:array];
38 | [array removeAllObjects];
39 | while ([heapArray count]) {
40 | [array push:[heapArray pop]];
41 | }
42 | }
43 |
44 | // 如何按照升序,使用另外一个栈来排序一个栈,如按照升序来pop
45 | - (NSMutableArray *)sortStackWidthDoubleStack {
46 | NSMutableArray *input = (NSMutableArray *)self;
47 | if (!([input isKindOfClass:[NSMutableArray class]] && [input count])) {
48 | return nil;
49 | }
50 |
51 | NSMutableArray *output = [[NSMutableArray alloc] init];
52 | [output push:[input pop]];
53 |
54 | while ([input count]) {
55 | id val = [input pop];
56 | while ([output count] && [[output lastObject] intValue] > [val intValue]) {
57 | [input push:[output pop]];
58 | }
59 | [output push:val];
60 | }
61 | return output;
62 | }
63 |
64 | // 给定一个二叉树,使用栈实现中序遍历
65 | - (void)inOrderBinaryTreeWithStack:(BinarySortTree *)root {
66 | if (!(root && [root isKindOfClass:[BinarySortTree class]])) {
67 | return;
68 | }
69 |
70 | NSMutableArray *stack = [[NSMutableArray alloc] init];
71 | while ([stack count] || root) {
72 | if (root) {
73 | [stack push:root];
74 | root = root.leftNode;
75 | }
76 | else {
77 | root = [stack lastObject];
78 | [stack pop];
79 | NSLog(@"%d", (int)root.value);
80 | root = root.rightNode;
81 | }
82 | }
83 | }
84 |
85 | // 给定一个字符串,他只包括'(',')','{','}','[',']',判断输入的字符串是否是一个有效的圆括号字符串
86 | + (BOOL)judgeVaildString:(NSString *)string {
87 | if (string.length <= 0) {
88 | return NO;
89 | }
90 |
91 | NSMutableArray *stack = [[NSMutableArray alloc] init];
92 | for (NSInteger i = 0; i < string.length; i++) {
93 | NSString *charter = [string substringWithRange:NSMakeRange(i, 1)];
94 |
95 | if ([self isLeftMatch:charter]) {
96 | [stack push:charter];
97 | }
98 | else {
99 | if (![self matchCharter:charter charter:[stack lastObject]]) {
100 | return false;
101 | }
102 | [stack pop];
103 | }
104 | }
105 | return [stack count] == 0;
106 | }
107 |
108 | + (BOOL)isLeftMatch:(NSString *)charter {
109 | if (charter.length != 1) {
110 | return NO;
111 | }
112 |
113 | if ([charter isEqualToString:@"{"] ||
114 | [charter isEqualToString:@"["] ||
115 | [charter isEqualToString:@"("]) {
116 | return YES;
117 | }
118 |
119 | return NO;
120 | }
121 |
122 | + (BOOL)matchCharter:(NSString *)str charter:(NSString *)charter {
123 | if (charter.length != 1) {
124 | return nil;
125 | }
126 |
127 | BOOL chr = nil;
128 | if ([str isEqualToString:@"}"]) {
129 | chr = [charter isEqualToString:@"{"];
130 | }
131 | else if ([str isEqualToString:@"]"]) {
132 | chr = [charter isEqualToString:@"["];
133 | }
134 | else if ([str isEqualToString:@")"]) {
135 | chr = [charter isEqualToString:@"("];
136 | }
137 | return chr;
138 | }
139 |
140 | // move zero
141 | - (void)backZero {
142 | NSMutableArray *array = (NSMutableArray *)self;
143 | if (!([array count] > 0 && [array isKindOfClass:[NSMutableArray class]])) {
144 | return;
145 | }
146 |
147 | int count = 0;
148 | // 将大于0的放在数组前面
149 | for (int i = 0; i < [array count]; i++) {
150 | if ([array[i] intValue] != 0) {
151 | array[count++] = array[i];
152 | }
153 | }
154 | // 数组后面填0
155 | for (int i = count; i < [array count]; i++) {
156 | array[i] = @0;
157 | }
158 | }
159 |
160 | // 从一个数组中找到一对元素,其和是一个给数字,返回这些数字的下标
161 | + (id)twoSum:(NSArray *)array value:(NSInteger)val {
162 | if ([array count] < 2) {
163 | return nil;
164 | }
165 |
166 | NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
167 | for (NSInteger i = 0; i < [array count]; i++) {
168 | NSString *currentNum = [NSString stringWithFormat:@"%ld", val - [[array objectAtIndex:i] intValue]];
169 | dict[currentNum] = [NSNumber numberWithInteger:i];
170 | }
171 |
172 | for (NSInteger i = 0; i < [array count]; i++) {
173 | NSString *currentNum = [NSString stringWithFormat:@"%d", [[array objectAtIndex:i] intValue]];
174 | if (dict[currentNum]) {
175 | return @[[NSNumber numberWithInteger:i], dict[currentNum]];
176 | }
177 | }
178 |
179 | return nil;
180 | }
181 |
182 | // 三个数相加和为一个指定数字
183 | - (NSMutableArray *)threeNumPlusToNum:(int)num {
184 | NSMutableArray *array = (NSMutableArray *)self;
185 | NSMutableArray *result = [[NSMutableArray alloc] init];
186 | if (!([array count] > 0 && [array isKindOfClass:[NSMutableArray class]])) {
187 | return nil;
188 | }
189 |
190 | for (int i = 0; i < [array count] - 2; i++) {
191 | if (i > 0 && [array[i] intValue] == [array[i - 1] intValue]) {
192 | continue;
193 | }
194 |
195 | int target = num - [array[i] intValue];
196 | [self twoSumForThreeSum:array start:i + 1 target:target result:result];
197 | }
198 |
199 | return result;
200 | }
201 |
202 | - (void)twoSumForThreeSum:(NSMutableArray *)array start:(int)start target:(int)target result:(NSMutableArray *)result {
203 | int head = start;
204 | int tail = (int)[array count] - 1;
205 |
206 | while (head < tail) {
207 | int temp = [array[head] intValue] + [array[tail] intValue];
208 | if (temp < target) {
209 | head++;
210 | }
211 | else if (temp > target) {
212 | tail--;
213 | }
214 | else {
215 | NSMutableArray *dict = [[NSMutableArray alloc] init];
216 | [dict push:array[start - 1]];
217 | [dict push:array[head]];
218 | [dict push:array[tail]];
219 | [result push:dict];
220 |
221 | //为了防止出现重复的二元组,使结果等于target
222 | int k = head+1;
223 | while(k < tail && array[k] == array[head]) k++;
224 | head = k;
225 | k = tail-1;
226 | while(k > head && array[k] == array[tail]) k--;
227 | tail = k;
228 | }
229 | }
230 | }
231 |
232 | @end
233 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/NSArraySort.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+Sort.m
3 | // iOSInterView
4 | //
5 | // Created by smart on 2016/10/28.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "NSArraySort.h"
10 |
11 | @implementation NSArraySort
12 |
13 | // 冒泡排序
14 | // 最佳情况 o(n)
15 | // 最差情况 o(n2)
16 | // 平均情况 o(n2)
17 | // 空间复杂度 o(1)
18 | + (NSMutableArray *)bubbleSort:(NSArray *)array {
19 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
20 | return nil;
21 | }
22 |
23 | NSMutableArray *finalArray = [[NSMutableArray alloc] initWithArray:array];
24 | for (NSInteger i = 0; i < [finalArray count]; i++) {
25 | for (NSInteger j = 0; j < [finalArray count] - i - 1; j++) {
26 | if (array[j] > array[j + 1]) {
27 | id temp = finalArray[j + 1];
28 | finalArray[j + 1] = finalArray[j];
29 | finalArray[j] = temp;
30 | }
31 | }
32 | }
33 | return finalArray;
34 | }
35 |
36 | // 选择排序
37 | // 最佳情况 o(n2)
38 | // 最差情况 o(n2)
39 | // 平均情况 o(n2)
40 | // 空间复杂度 o(1)
41 | + (NSMutableArray *)selectSort:(NSArray *)array {
42 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
43 | return nil;
44 | }
45 |
46 | NSMutableArray *finalArray = [[NSMutableArray alloc] initWithArray:array];
47 | NSInteger maxIndex = 0;
48 | for (NSInteger i = 0; i < [finalArray count] - 1; i++) {
49 | maxIndex = i;
50 | for (NSInteger j = i + 1; j < [finalArray count]; j++) {
51 | if (finalArray[j] < finalArray[maxIndex]) {
52 | maxIndex = j;
53 | }
54 | }
55 | id temp = finalArray[i];
56 | finalArray[i] = finalArray[maxIndex];
57 | finalArray[maxIndex] = temp;
58 | }
59 |
60 | return finalArray;
61 | }
62 |
63 | // 插入排序
64 | // 最佳情况 o(n)
65 | // 最差情况 o(n2)
66 | // 平均情况 o(n2)
67 | // 空间复杂度 o(1)
68 | + (NSMutableArray *)insertSort:(NSArray *)array {
69 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
70 | return nil;
71 | }
72 |
73 | NSMutableArray *finalArray = [[NSMutableArray alloc] initWithArray:array];
74 | for (NSInteger i = 1; i < [finalArray count]; i++) {
75 | NSInteger j = i - 1;
76 | id guard = finalArray[i];
77 | while (j >= 0 && finalArray[j] > guard) {
78 | finalArray[j + 1] = finalArray[j];
79 | j--;
80 | }
81 | finalArray[j + 1] = guard;
82 | }
83 |
84 | return finalArray;
85 | }
86 |
87 | // 归并排序,时间复杂度计算可抽象为二叉树,每层n个节点,每层计算量为o(n),深度为logn
88 | // 最佳情况 o(nlogn)
89 | // 最差情况 o(nlogn)
90 | // 平均情况 o(nlogn)
91 | // 空间复杂度 o(n)
92 | + (NSMutableArray *)mergeSort:(NSMutableArray *)array {
93 | if (!([array isKindOfClass:[NSMutableArray class]] && [array count] > 0)) {
94 | return nil;
95 | }
96 |
97 | if ([array count] < 2) {
98 | return array;
99 | }
100 |
101 | NSMutableArray *finalArray = array;
102 | NSInteger middle = ceilf([array count] / 2.0f);
103 | NSMutableArray *left = [[NSMutableArray alloc] initWithArray:[finalArray subarrayWithRange:NSMakeRange(0, middle)]];
104 | NSMutableArray *right = [[NSMutableArray alloc] initWithArray:[finalArray subarrayWithRange:NSMakeRange(middle, [array count] - middle)]];
105 |
106 | return [self merge:[self mergeSort:left] rightArray:[self mergeSort:right]];
107 | }
108 |
109 | + (NSMutableArray *)merge:(NSMutableArray *)left rightArray:(NSMutableArray *)right {
110 | if (!([left isKindOfClass:[NSArray class]] && [right isKindOfClass:[NSArray class]] &&
111 | [left count] > 0 && [right count] > 0)) {
112 | return nil;
113 | }
114 |
115 | NSMutableArray *result = [[NSMutableArray alloc] init];
116 | while ([left count] > 0 && [right count] > 0) {
117 | if (left[0] > right[0]) {
118 | [result addObject:right[0]];
119 | [right removeObjectAtIndex:0];
120 |
121 | }
122 | else {
123 | [result addObject:left[0]];
124 | [left removeObjectAtIndex:0];
125 | }
126 | }
127 |
128 | while ([left count]) {
129 | [result addObject:left[0]];
130 | [left removeObjectAtIndex:0];
131 | }
132 |
133 | while ([right count]) {
134 | [result addObject:right[0]];
135 | [right removeObjectAtIndex:0];
136 | }
137 |
138 | return result;
139 | }
140 |
141 | // 快速排序
142 | // 最佳情况 o(nlogn)
143 | // 最差情况 o(n2)
144 | // 平均情况 o(nlogn)
145 | // 空间复杂度 o(logn)
146 | + (NSMutableArray *)quickSort:(NSMutableArray *)array {
147 | if (!([array isKindOfClass:[NSMutableArray class]] && [array count] > 0)) {
148 | return [[NSMutableArray alloc] init];
149 | }
150 |
151 | if ([array count] < 2) {
152 | return array;
153 | }
154 |
155 | NSMutableArray *left = [[NSMutableArray alloc] init];
156 | NSMutableArray *right = [[NSMutableArray alloc] init];
157 | NSInteger middle = ceilf([array count] / 2.0f);
158 | id middleVal = array[middle];
159 | [array removeObjectAtIndex:middle];
160 | for (NSInteger i = 0; i < [array count]; i++) {
161 | if (middleVal > array[i]) {
162 | [left addObject:array[i]];
163 | }
164 | else {
165 | [right addObject:array[i]];
166 | }
167 | }
168 | left = [self quickSort:left];
169 | right = [self quickSort:right];
170 |
171 | NSMutableArray *leftArr = [[NSMutableArray alloc] initWithArray:[left arrayByAddingObject:middleVal]];
172 | NSMutableArray *rightArr = [[NSMutableArray alloc] initWithArray:[leftArr arrayByAddingObjectsFromArray:right]];
173 |
174 | return rightArr;
175 | }
176 |
177 | // 桶排序
178 | // 最佳情况 o(n + k)
179 | // 最差情况 o(n2)
180 | // 平均情况 o(n + k)
181 | // 空间复杂度 o(n + k)
182 | + (NSMutableArray *)bucketSort:(NSMutableArray *)array numbersOfBuckets:(NSInteger)num {
183 | if (!([array isKindOfClass:[NSArray class]] && [array count] > 0)) {
184 | return nil;
185 | }
186 |
187 | NSInteger max = 0;
188 | NSInteger min = 0;
189 | NSInteger space = 0;
190 | NSInteger n = 0;
191 | NSMutableDictionary *bucket = [[NSMutableDictionary alloc] init];
192 | NSMutableArray *result = [[NSMutableArray alloc] init];
193 |
194 | for (NSInteger i = 0; i < [array count]; i++) {
195 | max = max > [array[i] intValue] ? max : [array[i] intValue];
196 | min = min < [array[i] intValue] ? min : [array[i] intValue];
197 | }
198 | space = (max - min + 1) / num;
199 |
200 | for (NSInteger i = 0; i < [array count]; i++) {
201 | NSNumber *index = [NSNumber numberWithInteger:ceil(([array[i] intValue] - min) / space)];
202 | if (bucket[index]) {
203 | NSInteger k = [bucket[index] count] - 1;
204 | while (k >= 0 && bucket[index][k] > array[i]) {
205 | bucket[index][k + 1] = bucket[index][k];
206 | k--;
207 | }
208 | bucket[index][k + 1] = array[i];
209 | }
210 | else {
211 | bucket[index] = [[NSMutableArray alloc] init];
212 | [bucket[index] addObject:array[i]];
213 | }
214 | }
215 |
216 | while (n < num) {
217 | result = [[NSMutableArray alloc] initWithArray:[result arrayByAddingObjectsFromArray:bucket[[NSNumber numberWithInteger:n]]]];
218 | n++;
219 | }
220 |
221 | return result;
222 | }
223 |
224 | @end
225 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/GraphTheory.m:
--------------------------------------------------------------------------------
1 | //
2 | // GraphTheory.m
3 | // iOSInterView
4 | //
5 | // Created by wupeng10 on 2016/11/2.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "GraphTheory.h"
10 |
11 | static NSMutableArray *queue;
12 |
13 | @implementation GraphTheory
14 |
15 | + (GraphNode *)createGraphWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo {
16 |
17 | if (!([vexs isKindOfClass:[NSArray class]] && [vexs count])) {
18 | return nil;
19 | }
20 | if (!([arcInfo isKindOfClass:[NSArray class]] && [arcInfo count])) {
21 | return nil;
22 | }
23 |
24 | GraphNode *graph = [[GraphNode alloc] init];
25 | // 是否是有向图
26 | if (isDG) {
27 | graph.graphType = 1;
28 | }
29 | else {
30 | graph.graphType = 0;
31 | }
32 | // 顶点数目
33 | graph.verNum = verNum;
34 | // 弧的数目
35 | graph.arcNum = arcNum;
36 | // 顶点数组
37 | graph.vers = [[NSMutableArray alloc] initWithArray:vexs];
38 | // 初始化矩阵
39 | for (int i = 0; i < verNum; i++) {
40 | graph.arcs[i] = [[NSMutableArray alloc] initWithCapacity:arcNum];
41 | for (int j = 0; j < verNum; j++) {
42 | graph.arcs[i][j] = [NSNumber numberWithInteger:0];
43 | }
44 | }
45 | // 弧的数组
46 | for (int i = 0; i < arcNum; i++) {
47 | int start = [self getIndexOfVexs:graph nodeName:[arcInfo[i] valueForKey:@"start"]];
48 | int end = [self getIndexOfVexs:graph nodeName:[arcInfo[i] valueForKey:@"end"]];
49 | id weight = [arcInfo[i] valueForKey:@"weight"];
50 |
51 | if (graph.graphType == 0) {
52 | graph.arcs[start][end] = graph.arcs[end][start] = weight;
53 | }
54 | else {
55 | graph.arcs[start][end] = weight;
56 | }
57 | }
58 | return graph;
59 | }
60 |
61 | + (GraphMatrix *)createGraphMatrixWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo {
62 | if (verNum <= 0 || arcNum <= 0) {
63 | return nil;
64 | }
65 | if (!([vexs isKindOfClass:[NSArray class]] &&
66 | [arcInfo isKindOfClass:[NSArray class]] &&
67 | [vexs count] > 0 && [arcInfo count] > 0)) {
68 | return nil;
69 | }
70 | GraphMatrix *matrix = [[GraphMatrix alloc] init];
71 | matrix.verNum = verNum;
72 | matrix.arcNum = arcNum;
73 | matrix.vers = [[NSMutableArray alloc] initWithArray:vexs];
74 | matrix.matrix = [[NSMutableArray alloc] initWithCapacity:verNum];
75 | // 是否是有向图
76 | if (isDG) {
77 | matrix.graphType = 1;
78 | }
79 | else {
80 | matrix.graphType = 0;
81 | }
82 |
83 | for (int i = 0; i < verNum; i++) {
84 | matrix.matrix[i] = [[GraphMatrixNode alloc] init];
85 | GraphMatrixNode *node = matrix.matrix[i];
86 | node.data = vexs[i];
87 | }
88 |
89 | for (int i = 0; i < arcNum; i++) {
90 | int start = [self getIndexOfMatrixVexs:matrix nodeName:[arcInfo[i] valueForKey:@"start"]];
91 | int end = [self getIndexOfMatrixVexs:matrix nodeName:[arcInfo[i] valueForKey:@"end"]];
92 |
93 | if (matrix.graphType == 0) {
94 | GraphMatrixNode *startDGNode = matrix.matrix[end];
95 | GraphMatrixNode *endDGNode = [[GraphMatrixNode alloc] init];
96 | endDGNode.data = vexs[start];
97 | endDGNode.next = startDGNode.next;
98 | startDGNode.next = endDGNode;
99 | }
100 | GraphMatrixNode *startNode = matrix.matrix[start];
101 | GraphMatrixNode *endNode = [[GraphMatrixNode alloc] init];
102 | endNode.data = vexs[end];
103 | endNode.next = startNode.next;
104 | startNode.next = endNode;
105 | }
106 |
107 | return matrix;
108 | }
109 |
110 | + (int)getIndexOfVexs:(GraphNode *)graph nodeName:(NSString *)name {
111 | if (!(graph && [graph isKindOfClass:[GraphNode class]])) {
112 | return 0;
113 | }
114 |
115 | for (int i = 0; i < graph.verNum; i++) {
116 | if ([graph.vers[i] isEqualToString:name]) {
117 | return i;
118 | }
119 | }
120 |
121 | return 0;
122 | }
123 |
124 | + (int)getIndexOfMatrixVexs:(GraphMatrix *)graph nodeName:(NSString *)name {
125 | if (!(graph && [graph isKindOfClass:[GraphMatrix class]])) {
126 | return 0;
127 | }
128 |
129 | for (int i = 0; i < graph.verNum; i++) {
130 | if ([graph.vers[i] isEqualToString:name]) {
131 | return i;
132 | }
133 | }
134 |
135 | return 0;
136 | }
137 |
138 | // 深度优先遍历
139 | + (void)graphDFS:(GraphNode *)graph {
140 | if (!(graph && [graph isKindOfClass:[GraphNode class]])) {
141 | return;
142 | }
143 |
144 | for (int i = 0; i < graph.verNum; i++) {
145 | graph.isTrav[i] = [NSNumber numberWithInteger:0];
146 | }
147 |
148 | for (int i = 0; i < graph.verNum; i++) {
149 | if (![graph.isTrav[i] boolValue]) {
150 | [self DFS:graph nodeIndex:i];
151 | }
152 | }
153 | }
154 |
155 | + (void)DFS:(GraphNode *)graph nodeIndex:(int)index {
156 | if (!(graph && [graph isKindOfClass:[GraphNode class]])) {
157 | return;
158 | }
159 |
160 | NSLog(@"访问过的节点是:%@", graph.vers[index]);
161 | graph.isTrav[index] = [NSNumber numberWithInteger:1];
162 | for (int j = 0; j < graph.verNum; j++) {
163 | if ([graph.isTrav[j] intValue] == 0 && [graph.arcs[index][j] intValue] > 0) {
164 | [self DFS:graph nodeIndex:j];
165 | }
166 | }
167 | }
168 |
169 | + (void)graphBFS:(GraphNode *)graph {
170 | if (!(graph && [graph isKindOfClass:[GraphNode class]])) {
171 | return;
172 | }
173 | if (nil == queue) {
174 | queue = [[NSMutableArray alloc] init];
175 | }
176 |
177 | for (int i = 0; i < graph.verNum; i++) {
178 | graph.isTrav[i] = [NSNumber numberWithInteger:0];
179 | }
180 |
181 | for (int i = 0; i < graph.verNum; i++) {
182 | if (![graph.isTrav[i] boolValue]) {
183 | [self BFS:graph nodeIndex:i];
184 | }
185 | }
186 | }
187 |
188 | + (void)BFS:(GraphNode *)graph nodeIndex:(int)index {
189 | if (!(graph && [graph isKindOfClass:[GraphNode class]])) {
190 | return;
191 | }
192 |
193 | graph.isTrav[index] = [NSNumber numberWithInteger:1];
194 | [queue addObject:[NSNumber numberWithInteger:index]];
195 | NSLog(@"广度优先遍历的节点是:%@", graph.vers[index]);
196 |
197 | while ([queue count] > 0) {
198 | int k = [[queue objectAtIndex:0] intValue];
199 | [queue removeObjectAtIndex:0];
200 |
201 | for (int i = 0; i < graph.verNum; i++) {
202 | if ([graph.arcs[k][i] intValue] && [graph.isTrav[i] intValue] == 0) {
203 | NSLog(@"广度优先遍历的节点是:%@", graph.vers[i]);
204 | graph.isTrav[i] = [NSNumber numberWithInteger:1];
205 | [queue addObject:[NSNumber numberWithBool:i]];
206 | }
207 | }
208 | }
209 |
210 | }
211 |
212 | + (void)inDegree:(GraphNode *)graph {
213 | if (![graph isKindOfClass:[GraphNode class]]) {
214 | return;
215 | }
216 |
217 | if ([graph.arcs count] <= 0) {
218 | return;
219 | }
220 |
221 | int k = 0;
222 | for (int i = 0; i < graph.verNum; i++) {
223 | for (int j = 0; j < graph.verNum; j++) {
224 | if ([graph.arcs[i][j] intValue] != 0) {
225 | k++;
226 | }
227 | }
228 | NSLog(@"节点%@的入度是:%d", graph.vers[i], k);
229 | k = 0;
230 | }
231 | }
232 |
233 | + (void)outDegree:(GraphNode *)graph {
234 | if (![graph isKindOfClass:[GraphNode class]]) {
235 | return;
236 | }
237 |
238 | int k = 0;
239 | for (int i = 0; i < graph.verNum; i++) {
240 | for (int j = 0; j < graph.verNum; j++) {
241 | if ([graph.arcs[j][i] intValue] != 0) {
242 | k++;
243 | }
244 | }
245 | NSLog(@"节点%@的入度是:%d", graph.vers[i], k);
246 | k = 0;
247 | }
248 | }
249 |
250 | @end
251 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOSInterView
2 |
3 | 工程中会包含一些iOS面试中的算法和数据结构相关题目,通过objective c来实现,目前包含链表、二叉树、栈、队列、排序等的部分,持续更新中...
4 |
5 | ### 二叉树
6 |
7 | ```/**
8 | * desc: 二叉排序树的创建,每次都要从顶部元素开始遍历,小于其的放在左边,大于的放在右边
9 | *
10 | * params:根结点,node的值
11 | *
12 | */
13 | + (BinarySortTree *)binarySortTreeCreate:(NSArray *)tree;
14 |
15 | /**
16 | * desc: 先序遍历
17 | *
18 | * params: 根结点,压栈操作的block
19 | *
20 | */
21 | + (void)preOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
22 |
23 | /**
24 | * desc: 中序遍历
25 | *
26 | * params: 根结点,压栈操作的block
27 | *
28 | */
29 | + (void)inOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
30 |
31 | /**
32 | * desc: 后序遍历
33 | *
34 | * params: 根结点,压栈操作的block
35 | *
36 | */
37 | + (void)postOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
38 |
39 | /**
40 | * desc: 层次遍历(广度优先)
41 | *
42 | * params: 根结点,压栈操作的block
43 | *
44 | */
45 | + (void)levelTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler;
46 |
47 | /**
48 | * desc: 返回二叉树的深度
49 | *
50 | * params: root 跟节点
51 | *
52 | */
53 | + (NSInteger)depthOfTree:(BinarySortTree *)root;
54 |
55 | /**
56 | * desc: 返回二叉树的宽度
57 | *
58 | * params: root 跟节点
59 | *
60 | */
61 | + (NSInteger)widthOfTree:(BinarySortTree *)root;
62 |
63 | /**
64 | * desc: 返回二叉树的全部节点数
65 | *
66 | * params: root 跟节点
67 | *
68 | */
69 | + (NSInteger)numbersOfNodesInTree:(BinarySortTree *)root;
70 |
71 | /**
72 | * desc: 返回二叉树的叶子节点
73 | *
74 | * params: root 跟节点
75 | *
76 | */
77 | + (NSInteger)numbersOfLeafsInTree:(BinarySortTree *)root;
78 |
79 | /**
80 | * desc: 返回二叉树中某个节点到跟节点的路径
81 | *
82 | * params: root 跟节点,node 指定节点
83 | *
84 | */
85 | + (NSMutableArray *)pathOfNodeInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
86 |
87 | /**
88 | * desc: 二叉树中两个节点最近的公共父节点
89 | *
90 | * params: root 跟节点,nodeA/nodeB 两节点
91 | *
92 | */
93 | + (BinarySortTree *)publicNodeOfTwoNodesIntree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB;
94 |
95 | /**
96 | * desc: 二叉树两个节点之间的距离
97 | *
98 | * params: root 跟节点,nodeA/nodeB 两节点
99 | *
100 | */
101 | + (NSInteger)distanceOfTwoNodesInTree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB;
102 |
103 | /**
104 | * desc: 翻转二叉树
105 | *
106 | * params: root 跟节点
107 | *
108 | */
109 | + (BinarySortTree *)invertBinaryTree:(BinarySortTree *)root;
110 |
111 | /**
112 | * desc: 判断二叉树是否完全二叉树
113 | *
114 | * params: root 跟节点
115 | *
116 | */
117 | + (BOOL)isCompleteBinaryTree:(BinarySortTree *)root;
118 |
119 | /**
120 | * desc: 判断二叉树是否满二叉树
121 | *
122 | * params: root 跟节点
123 | *
124 | */
125 | + (BOOL)isFullBinaryTree:(BinarySortTree *)root;
126 |
127 | /**
128 | * desc: 判断二叉树是否平衡二叉树
129 | *
130 | * params: root 跟节点
131 | *
132 | */
133 | + (BOOL)isAVLBinaryTree:(BinarySortTree *)root;
134 |
135 | /**
136 | * desc: 返回二叉树第i层节点数
137 | *
138 | * params: root 跟节点,level 层级
139 | *
140 | */
141 | + (NSInteger)numbersOfLevelInTree:(BinarySortTree *)root level:(NSInteger)level;
142 |
143 | /**
144 | * desc: 二叉排序树插入节点
145 | *
146 | * params:根结点,插入的值
147 | *
148 | */
149 | + (BinarySortTree *)insertNodeToTree:(BinarySortTree *)root nodeValue:(NSInteger)value;
150 |
151 | /**
152 | * desc: 删除排序二叉树中的节点,三种情况:1.删除节点是叶子结点,2.删除节点只有左/右子树,3.删除节点左右子树都有
153 | *
154 | * params:根结点,插入的值
155 | *
156 | */
157 | + (void)deleteNodeInTree:(BinarySortTree *)root deleteNode:(NSInteger)value;
158 |
159 | /**
160 | * desc: 判断一棵树是否是二叉搜索树,二叉搜索树特点:父节点的值大于所有左子树的值,小于所有右子树的值,前提是假设所有值没有相同的
161 | *
162 | * params:根结点,插入的值
163 | *
164 | */
165 | + (BOOL)isBinarySearchTree:(BinarySortTree *)root;
166 |
167 | /**
168 | * desc: 判断一棵树是否是另一棵树的子树
169 | *
170 | * params:root 父树根节点,childNode 子树根节点
171 | *
172 | */
173 | + (BOOL)isContainTree:(BinarySortTree *)root childNode:(BinarySortTree *)childNode;
174 |
175 | /**
176 | * desc: 找出一棵二叉树中所有路径,并且其路径之和等于一个给定的值
177 | *
178 | * params: root 根节点,path 暂时存储路径的数组,vector 返回最终符合要求的数组,sum 给定值
179 | */
180 | + (void)findAllPathInTree:(BinarySortTree *)root pathArray:(NSMutableArray *)path vectore:(NSMutableArray *)vectore sum:(NSInteger)sum;
181 |
182 | /**
183 | * desc: 找出二叉树中一个节点的后继
184 | *
185 | * params: root 根节点,node 目标节点
186 | */
187 | + (BinarySortTree *)findSuccessor:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
188 |
189 | /**
190 | * desc: 找出二叉树中一个节点的前驱
191 | *
192 | * params: root 根节点,node 目标节点
193 | */
194 | + (BinarySortTree *)findPrecursor:(BinarySortTree *)root searchNode:(BinarySortTree *)node;
195 |
196 | /**
197 | * desc: 序列化二叉树
198 | *
199 | * params: root 根节点
200 | */
201 | + (NSString *)serializeBinaryTree:(BinarySortTree *)root;
202 |
203 | /**
204 | * desc: 反序列化二叉树
205 | *
206 | * params: root 根节点
207 | */
208 | + (BinarySortTree *)deserializeBinaryTree:(NSString *)serialString;
209 | ```
210 |
211 | ### 链表
212 | ```
213 | /**
214 | * desc: 打印链表的值,打印不带环的链表,调试用
215 | *
216 | */
217 | + (void)printfLinkedList:(LinkedList *)list;
218 |
219 | /**
220 | * desc: 创建首尾不相连的单向链表
221 | *
222 | * params: array 构建链表的数组(以数字数组为例)
223 | *
224 | */
225 | + (LinkedList *)createNoCircleAndSinglyLinkedList:(NSArray *)array;
226 |
227 | /**
228 | * desc: 创建首尾不相连的双向链表
229 | *
230 | * params: array 构建链表的数组(以数字数组为例)
231 | *
232 | */
233 | + (LinkedList *)createSinglyLinkedList:(NSArray *)array;
234 |
235 | /**
236 | * desc: 创建首尾相连的双向链表
237 | *
238 | * params: array 构建链表的数组(以数字数组为例)
239 | *
240 | */
241 | + (LinkedList *)createTwoWayLinkedList:(NSArray *)array;
242 |
243 | /**
244 | * desc: 给定一个链表和一个值,对链表进行排序,使得所有小于该值的元素都在左边,大于的都在右边
245 | *
246 | * params: list 链表,val 值
247 | *
248 | */
249 | + (LinkedList *)reorderList:(LinkedList *)list value:(NSInteger)val;
250 |
251 | /**
252 | * desc: 给定一个链表,返回链表的中间点。双指针法,一个以一倍速前进,一个以二倍速前进
253 | *
254 | * params: list 链表
255 | *
256 | */
257 | + (LinkedList *)getMiddleNodeInLinkedList:(LinkedList *)list;
258 |
259 | /**
260 | * desc: 找到链表中距离最后一个元素k的那个元素
261 | *
262 | * params: list 链表,k 距离
263 | *
264 | */
265 | + (LinkedList *)getKthNodeInLinkedList:(LinkedList *)list distance:(NSInteger)k;
266 |
267 | /**
268 | * desc: 给定一个可能包含环的链表,编写一个函数返回环开始的节点,如果不包含返回nil。设置两个指针,一个是单倍速,一个二倍速,如果能够相遇则说明又环,然后使得一个指针指向头节点,然后再次以单倍速前进,相遇点即为环开始的点
269 | *
270 | * params: list 链表
271 | *
272 | */
273 | + (LinkedList *)getStartOfCircleInLinkedList:(LinkedList *)list;
274 |
275 | /**
276 | * desc: 给定一个链表,向右旋转k个位置,k是非负数,如1>2>3>4>5,k=2,旋转之后为4>5>1>2>3
277 | *
278 | * params: list 链表,k 距离
279 | *
280 | */
281 | + (LinkedList *)revertLinkedListWithK:(LinkedList *)list distance:(NSInteger)k;
282 |
283 | /**
284 | * desc: 将链表逆转并返回新的链表头
285 | *
286 | * params: list 链表,k 距离
287 | *
288 | */
289 | + (LinkedList *)revertLinkedList:(LinkedList *)list;
290 | ```
291 |
292 | ###栈和队列
293 | ```
294 | /**
295 | * desc: 入栈操作
296 | *
297 | * params: val 入栈的值
298 | */
299 | - (void)push:(id)val;
300 |
301 | /**
302 | * desc: 出栈操作
303 | *
304 | */
305 | - (id)pop;
306 |
307 | /*
308 | * desc: 栈按照队列进行输出
309 | *
310 | * params: array 输入的数组
311 | *
312 | */
313 | - (void)reverToHeap;
314 |
315 | /*
316 | * desc: 如何按照升序,使用另外一个栈来排序一个栈,如按照升序来pop
317 | *
318 | * params: array 输入的数组
319 | *
320 | */
321 | - (NSMutableArray *)sortStackWidthDoubleStack;
322 |
323 | /*
324 | * desc: 给定一个二叉树,使用栈实现中序遍历
325 | *
326 | * params: array 输入的数组
327 | *
328 | */
329 | - (void)inOrderBinaryTreeWithStack:(BinarySortTree *)root;
330 |
331 | /*
332 | * desc: 给定一个字符串,他只包括'(',')','{','}','[',']',判断输入的字符串是否是一个有效的圆括号字符串
333 | *
334 | * params: array 字符串
335 | *
336 | */
337 | + (BOOL)judgeVaildString:(NSString *)string;
338 |
339 | /*
340 | * desc: 给定一个数组,将其中的0放在数组最后
341 | *
342 | */
343 | - (void)backZero;
344 |
345 | /*
346 | * desc: 从一个数组中找到一对元素,其和是一个给数字,返回这些数字的下标
347 | *
348 | * params: array 目标数组 val 要求的值
349 | *
350 | */
351 | + (id)twoSum:(NSArray *)array value:(NSInteger)val;
352 |
353 | /*
354 | * desc: 给定一个数组,其中三个数字相加为固定值,返回所有符合要求的数
355 | *
356 | */
357 | - (NSMutableArray *)threeNumPlusToNum:(int)num;
358 | ```
359 |
360 | ### 排序
361 | ```
362 | /**
363 | * desc: 冒泡排序
364 | * 1. 进行两次便利,第一个for是从 0 - arr.length, 第二次是从0到 arr.length - i - 1;
365 | * 2. 每一趟之后最后一个是最大值;
366 | *
367 | * 时间复杂度: 最好情况o(n), 最差o(n^2), 平均o(n^2)
368 | *
369 | * 空间复杂度: 0(1)
370 | */
371 | + (NSMutableArray *)bubbleSort:(NSArray *)array;
372 |
373 |
374 | /**
375 | * desc: 选择排序
376 | * 1. 分为两趟,第一趟从0-arr.length-1, 第二趟从i + 1到arr.length
377 | * 2. 每趟的结果是最小值在最左边
378 | *
379 | * 时间复杂度:最好情况o(n^2), 最差o(n^2), 平均o(n^2)
380 | *
381 | * 空间复杂度:o(1)
382 | */
383 | + (NSMutableArray *)selectSort:(NSArray *)array;
384 |
385 | /**
386 | * desc: 插入排序
387 | * 1. 分为两步,第一步,默认从第1个元素开始便利,第二趟,从该元素开始,从后往前遍历插入
388 | * 2. 每趟结束之后前面的有序+1
389 | *
390 | * 时间复杂度:最好情况o(n), 最差o(n^2), 平均o(n^2)
391 | *
392 | * 空间复杂度:o(1)
393 | */
394 | + (NSMutableArray *)insertSort:(NSArray *)array;
395 |
396 | /**
397 | * desc: 归并排序
398 | * 1. 取中间值为哨兵,将数组分为两个数组,左数组都小于等于哨兵,右边都大于哨兵
399 | * 2. 进行递归合并,合并函数为:定义一个数组,比较两数组中的第一个元素,将小的插入到result中,直到一个数组length为0
400 | * 3. 检查两数组是否长度有不为0的,如果不为0,将其接在result上面
401 | *
402 | * 时间复杂度:o(nlongn)
403 | *
404 | * 空间复杂度:0(n)
405 | */
406 | + (NSMutableArray *)mergeSort:(NSArray *)array;
407 |
408 | /**
409 | * desc: 快速排序
410 | * 1. 找到中间值,将其分为两个数组,不包括中间的值,左边的小于等于中间值,右边大于中间值;
411 | * 2. 递归调用快排,返回结果为左边数组连接中间值和右边数组
412 | *
413 | * 时间复杂度:最好情况o(nlogn), 最差o(n^2), 平均o(nlogn)
414 | *
415 | * 空间复杂度:o(logn)
416 | */
417 | + (NSMutableArray *)quickSort:(NSArray *)array;
418 |
419 | /**
420 | * desc: bucket sort
421 | * 1. 找出数组中的最大值和最小值
422 | * 2. 确定桶间距 space = (max - min + 1) / num
423 | * 3. for循环进行分桶
424 | * 1. 确定桶的索引值 index = Math.floor((arr[i] - min) / space)
425 | * 2. 入桶,如果桶对应的索引值存在,则加入其中并进行排序,否则新建该索引下的桶数组
426 | * 4. 将桶中的每个数组连接起来
427 | */
428 | + (NSMutableArray *)bucketSort:(NSMutableArray *)array numbersOfBuckets:(NSInteger)num;
429 | ```
430 | ### 图
431 | ```
432 | /**
433 | * desc:通过邻接矩阵的形式创建图
434 | *
435 | * params: isDG 是否是有向图,1是,0否 verNum 顶点总数,arcNum 弧的总数,vexs 顶点数组,arcInfo 弧信息,包括起始点,终止点,以及权重
436 | *
437 | */
438 | + (GraphNode *)createGraphWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo;
439 |
440 | /**
441 | * desc:通过邻接矩阵的形式创建图
442 | *
443 | * params: isDG 是否是有向图,1是,0否 verNum 顶点总数,arcNum 弧的总数,vexs 顶点数组,arcInfo 弧信息,包括起始点,终止点,以及权重
444 | *
445 | */
446 | + (GraphMatrix *)createGraphMatrixWithInfo:(BOOL)isDG numberOfVex:(int)verNum numberOfArc:(int)arcNum vexArray:(NSArray *)vexs arcInfo:(NSArray *)arcInfo;
447 |
448 | /**
449 | * desc:深度优先遍历
450 | *
451 | * params: graph 图
452 | *
453 | */
454 | + (void)graphDFS:(GraphNode *)graph;
455 |
456 | /**
457 | * desc:广度优先遍历
458 | *
459 | * params: graph 图
460 | *
461 | */
462 | + (void)graphBFS:(GraphNode *)graph;
463 |
464 | /**
465 | * desc:通过邻接矩阵求入度
466 | *
467 | * params: graph 图
468 | *
469 | */
470 | + (void)inDegree:(GraphNode *)matrix;
471 |
472 | /**
473 | * desc:通过邻接矩阵求出度
474 | *
475 | * params: graph 图
476 | *
477 | */
478 | + (void)outDegree:(GraphNode *)graph;
479 | ```
480 | ### 堆
481 | ```
482 | /*
483 | * desc: 建立并返回小顶堆
484 | *
485 | * params: heap 堆, len 长度
486 | *
487 | */
488 | + (NSMutableArray *)createMinHeap:(NSMutableArray *)heap length:(int)len;
489 |
490 | /*
491 | * desc: top k
492 | *
493 | * option:
494 | * 1. 通过hash table记录输入的值,key为值,value为出现的次数
495 | * 2. 建立容量为k的小顶堆
496 | * 3. 按照hash table中的值入堆,返回结果
497 | *
498 | * params: heap 堆, len 长度
499 | */
500 | + (NSMutableArray *)findTopKMaxNum:(NSMutableArray *)heap length:(int)len;
501 | ```
502 | ### 字符串
503 | ```
504 | /*
505 | * desc: 判断是否是回文
506 | *
507 | * params: str 字符串
508 | */
509 | + (BOOL)isPanlindrome:(NSString *)str;
510 |
511 | /*
512 | * desc: 提供一个字母字符串和数字字符串,从key中取一位出来(key向后移动以为),从str的第一个字母开始,根据取出的数值将str中的字母向后移动key位,如果到z/Z了从头循环
513 | *
514 | * params: str 字符串
515 | */
516 | + (NSString *)convertString:(NSString *)str withKey:(NSString *)key;
517 |
518 | /*
519 | * desc: 判断一个字符串中所有字符都是唯一的
520 | *
521 | * params: str 判断的字符串
522 | *
523 | */
524 | + (BOOL)isUnique:(NSString *)str;
525 |
526 | /*
527 | * desc: 两个字符串str,mainStr,判断是否能够使用str中的字符串来组成mainStr
528 | *
529 | * params: mainStr str
530 | *
531 | */
532 | + (BOOL)isContainString:(NSString *)mainStr combineString:(NSString *)str;
533 |
534 | /*
535 | * desc: 单词置换
536 | *
537 | * params: strA strB
538 | *
539 | */
540 | + (BOOL)permutaionString:(NSString *)strA another:(NSString *)strB;
541 |
542 | ```
543 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView/BinarySortTree.m:
--------------------------------------------------------------------------------
1 | //
2 | // BinarySortTree.m
3 | // BinaryTree
4 | //
5 | // Created by smart on 2016/10/21.
6 | // Copyright © 2016年 smartfutureplayer@gmail.com. All rights reserved.
7 | //
8 |
9 | #import "BinarySortTree.h"
10 |
11 | static NSMutableArray *serialString;
12 | static int serialCount;
13 |
14 | @interface BinarySortTree ()
15 |
16 | @property (nonatomic, assign) NSInteger nodeIndex;
17 |
18 | @end
19 |
20 | @implementation BinarySortTree
21 |
22 | // 二叉排序树的创建
23 | + (BinarySortTree *)binarySortTreeCreate:(NSArray *)tree {
24 | if (!([tree isKindOfClass:[NSArray class]] && [tree count] > 0)) {
25 | return nil;
26 | }
27 |
28 | BinarySortTree *root = nil;
29 | for (NSInteger i = 0; i < [tree count]; i++) {
30 | root = [self insertNodeToTree:root nodeValue:[[tree objectAtIndex:i] intValue]];
31 | }
32 |
33 | return root;
34 | }
35 |
36 | // 二叉排序树的创建
37 | + (BinarySortTree *)insertNodeToTree:(BinarySortTree *)root nodeValue:(NSInteger)value {
38 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
39 | root = [[BinarySortTree alloc] init];
40 | root.value = value;
41 | }
42 | else if (root.value == value) {
43 | NSException *exception = [NSException
44 | exceptionWithName: @"不能构建二叉排序树"
45 | reason: @"由于有相同元素,从而不能构建二叉排序树"
46 | userInfo: nil];
47 | @throw exception;
48 | }
49 | else if (root.value > value) {
50 | root.leftNode = [self insertNodeToTree:root.leftNode nodeValue:value];
51 | }
52 | else if (root.value < value) {
53 | root.rightNode = [self insertNodeToTree:root.rightNode nodeValue:value];
54 | }
55 |
56 | return root;
57 | }
58 |
59 | // 先序遍历
60 | + (void)preOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler {
61 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
62 | return;
63 | }
64 |
65 | if (handler) {
66 | handler(root);
67 | }
68 | [self preOrderTraverseTree:root.leftNode handler:handler];
69 | [self preOrderTraverseTree:root.rightNode handler:handler];
70 | }
71 |
72 | // 中序遍历
73 | + (void)inOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler {
74 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
75 | return;
76 | }
77 |
78 | [self inOrderTraverseTree:root.leftNode handler:handler];
79 | if (handler) {
80 | handler(root);
81 | }
82 | [self inOrderTraverseTree:root.rightNode handler:handler];
83 | }
84 |
85 | // 后序遍历
86 | + (void)postOrderTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler {
87 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
88 | return;
89 | }
90 |
91 | [self postOrderTraverseTree:root.leftNode handler:handler];
92 | [self postOrderTraverseTree:root.rightNode handler:handler];
93 | if (handler) {
94 | handler(root);
95 | }
96 | }
97 |
98 | // 层次遍历(广度优先)
99 | + (void)levelTraverseTree:(BinarySortTree *)root handler:(void(^)(BinarySortTree *node))handler {
100 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
101 | return;
102 | }
103 |
104 | NSMutableArray *treeNode = [[NSMutableArray alloc] init];
105 | [treeNode addObject:root];
106 |
107 | while ([treeNode count] > 0) {
108 | BinarySortTree *currentNode = [treeNode firstObject];
109 | if (handler) {
110 | handler(currentNode);
111 | }
112 | [treeNode removeObjectAtIndex:0];
113 | if (currentNode.leftNode) {
114 | [treeNode addObject:currentNode.leftNode];
115 | }
116 | if (currentNode.rightNode) {
117 | [treeNode addObject:currentNode.rightNode];
118 | }
119 | }
120 | }
121 |
122 | // 返回二叉树的深度
123 | + (NSInteger)depthOfTree:(BinarySortTree *)root {
124 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
125 | return 0;
126 | }
127 |
128 | if (nil == root.leftNode && nil == root.rightNode) {
129 | return 1;
130 | }
131 |
132 | NSInteger leftTreeDepth = [self depthOfTree:root.leftNode];
133 | NSInteger rightTreeDepth = [self depthOfTree:root.rightNode];
134 | return MAX(leftTreeDepth, rightTreeDepth) + 1;
135 | }
136 |
137 | // 返回二叉树的宽度
138 | + (NSInteger)widthOfTree:(BinarySortTree *)root {
139 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
140 | return 0;
141 | }
142 |
143 | NSInteger currentWidth = 0;
144 | NSInteger maxWidth = 1;
145 | NSMutableArray *treeNode = [[NSMutableArray alloc] init];
146 | [treeNode addObject:root];
147 |
148 | while ([treeNode count] > 0) {
149 | currentWidth = [treeNode count];
150 | for (NSInteger i = 0; i < currentWidth; i++) {
151 | BinarySortTree *currentNode = [treeNode firstObject];
152 | if ([currentNode isKindOfClass:[BinarySortTree class]]) {
153 | if (currentNode.leftNode) {
154 | [treeNode addObject:currentNode.leftNode];
155 | }
156 | if (currentNode.rightNode) {
157 | [treeNode addObject:currentNode.rightNode];
158 | }
159 | }
160 | [treeNode removeObjectAtIndex:0];
161 | }
162 | maxWidth = MAX(currentWidth, maxWidth);
163 | }
164 | return maxWidth;
165 | }
166 |
167 | // 返回二叉树的全部节点数
168 | + (NSInteger)numbersOfNodesInTree:(BinarySortTree *)root {
169 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
170 | return 0;
171 | }
172 |
173 | return [self numbersOfNodesInTree:root.leftNode] + [self numbersOfNodesInTree:root.rightNode] + 1;
174 | }
175 |
176 | // 返回二叉树的叶子节点
177 | + (NSInteger)numbersOfLeafsInTree:(BinarySortTree *)root {
178 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
179 | return 0;
180 | }
181 |
182 | if (nil == root.leftNode && nil == root.rightNode) {
183 | return 1;
184 | }
185 |
186 | return [self numbersOfLeafsInTree:root.leftNode] + [self numbersOfLeafsInTree:root.rightNode];
187 | }
188 |
189 | // 返回二叉树第i层节点数
190 | + (NSInteger)numbersOfLevelInTree:(BinarySortTree *)root level:(NSInteger)level {
191 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]]) || level < 1) {
192 | return 0;
193 | }
194 |
195 | if (level == 1) {
196 | return 1;
197 | }
198 |
199 | return [self numbersOfLevelInTree:root.leftNode level:(level - 1)] + [self numbersOfLevelInTree:root.rightNode level:(level - 1)];
200 | }
201 |
202 | // 返回二叉树中某个节点到跟节点的路径
203 | + (NSMutableArray *)pathOfNodeInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node {
204 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
205 | return nil;
206 | }
207 | if (!(nil != node && [node isKindOfClass:[BinarySortTree class]])) {
208 | return nil;
209 | }
210 | NSMutableArray *pathArray = [[NSMutableArray alloc] init];
211 | [self findNodeInTree:root searchNode:node pathArray:pathArray];
212 |
213 | return pathArray;
214 | }
215 |
216 | + (BOOL)findNodeInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node pathArray:(NSMutableArray *)pathArray {
217 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
218 | return NO;
219 | }
220 | if (!(nil != node && [node isKindOfClass:[BinarySortTree class]])) {
221 | return NO;
222 | }
223 | if (root == node) {
224 | [pathArray addObject:root];
225 | return YES;
226 | }
227 |
228 | [pathArray addObject:root];
229 |
230 | BOOL hasFind = [self findNodeInTree:root.leftNode searchNode:node pathArray:pathArray];
231 | if (!hasFind) {
232 | hasFind = [self findNodeInTree:root.rightNode searchNode:node pathArray:pathArray];
233 | }
234 | if (!hasFind) {
235 | [pathArray removeLastObject];
236 | }
237 |
238 | return hasFind;
239 | }
240 |
241 | // 返回二叉树中某个节点到跟节点的路径的值
242 | + (NSMutableArray *)pathOfNodeValueInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node {
243 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
244 | return nil;
245 | }
246 | if (!(nil != node && [node isKindOfClass:[BinarySortTree class]])) {
247 | return nil;
248 | }
249 | NSMutableArray *pathArray = [[NSMutableArray alloc] init];
250 | [self findNodeValueInTree:root searchNode:node pathArray:pathArray];
251 |
252 | return pathArray;
253 | }
254 |
255 | + (BOOL)findNodeValueInTree:(BinarySortTree *)root searchNode:(BinarySortTree *)node pathArray:(NSMutableArray *)pathArray {
256 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
257 | return NO;
258 | }
259 | if (!(nil != node && [node isKindOfClass:[BinarySortTree class]])) {
260 | return NO;
261 | }
262 | if (root == node) {
263 | [pathArray addObject:[NSNumber numberWithInteger:root.value]];
264 | return YES;
265 | }
266 |
267 | [pathArray addObject:[NSNumber numberWithInteger:root.value]];
268 |
269 | BOOL hasFind = [self findNodeValueInTree:root.leftNode searchNode:node pathArray:pathArray];
270 | if (!hasFind) {
271 | hasFind = [self findNodeValueInTree:root.rightNode searchNode:node pathArray:pathArray];
272 | }
273 | if (!hasFind) {
274 | [pathArray removeLastObject];
275 | }
276 |
277 | return hasFind;
278 | }
279 |
280 | // 二叉树中两个节点最近的公共父节点
281 | + (BinarySortTree *)publicNodeOfTwoNodesIntree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB {
282 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]]) ||
283 | !(nil != nodeA && [nodeA isKindOfClass:[BinarySortTree class]]) ||
284 | !(nil != nodeB && [nodeB isKindOfClass:[BinarySortTree class]])) {
285 | return nil;
286 | }
287 | if (!(nil != nodeB && [nodeB isKindOfClass:[BinarySortTree class]])) {
288 | return nil;
289 | }
290 |
291 | if (nodeA == nodeB) {
292 | return nodeA;
293 | }
294 |
295 | NSArray *pathA = [self pathOfNodeInTree:root searchNode:nodeA];
296 | NSArray *pathB = [self pathOfNodeInTree:root searchNode:nodeB];
297 |
298 | // 找公共节点,这里的比较可以优化
299 | for (NSInteger i = [pathA count] - 1; i >= 0; i--) {
300 | for (NSInteger j = [pathB count] - 1; j >= 0 ; j--) {
301 | if ([pathA objectAtIndex:i] == [pathB objectAtIndex:j]) {
302 | return (BinarySortTree *)[pathA objectAtIndex:i];
303 | }
304 | }
305 | }
306 |
307 | return nil;
308 | }
309 |
310 | // 二叉树两个节点之间的距离
311 | + (NSInteger)distanceOfTwoNodesInTree:(BinarySortTree *)root nodeA:(BinarySortTree *)nodeA nodeB:(BinarySortTree *)nodeB {
312 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]]) ||
313 | !(nil != nodeA && [nodeA isKindOfClass:[BinarySortTree class]]) ||
314 | !(nil != nodeB && [nodeB isKindOfClass:[BinarySortTree class]])) {
315 | return -1;
316 | }
317 | if (!(nil != nodeB && [nodeB isKindOfClass:[BinarySortTree class]])) {
318 | return -1;
319 | }
320 |
321 | NSMutableArray *pathArray = [[NSMutableArray alloc] init];
322 | if (nodeA == nodeB) {
323 | [pathArray addObject:nodeB];
324 | return 0;
325 | }
326 |
327 | NSArray *pathA = [self pathOfNodeValueInTree:root searchNode:nodeA];
328 | NSArray *pathB = [self pathOfNodeValueInTree:root searchNode:nodeB];
329 | // 这里的比较可以优化
330 | for (NSInteger i = [pathA count] - 1; i >= 0; i--) {
331 | for (NSInteger j = [pathB count] - 1; j >= 0 ; j--) {
332 | if ([pathA objectAtIndex:i] == [pathB objectAtIndex:j]) {
333 | return [pathA count] - i + [pathB count] - j - 2;
334 | }
335 | }
336 | }
337 |
338 | return -1;
339 | }
340 |
341 | // 翻转二叉树
342 | + (BinarySortTree *)invertBinaryTree:(BinarySortTree *)root {
343 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
344 | return nil;
345 | }
346 |
347 | if (nil == root.leftNode && nil == root.rightNode) {
348 | return root;
349 | }
350 |
351 | [self invertBinaryTree:root.leftNode];
352 | [self invertBinaryTree:root.rightNode];
353 |
354 | BinarySortTree *tempNode = root.leftNode;
355 | root.leftNode = root.rightNode;
356 | root.rightNode = tempNode;
357 | return root;
358 | }
359 |
360 | // 判断二叉树是否完全二叉树
361 | + (BOOL)isCompleteBinaryTree:(BinarySortTree *)root {
362 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
363 | return NO;
364 | }
365 |
366 | if (nil == root.leftNode && root.rightNode) {
367 | return NO;
368 | }
369 |
370 | if (nil == root.leftNode &&
371 | nil == root.rightNode) {
372 | return YES;
373 | }
374 |
375 | NSMutableArray *nodeArray = [[NSMutableArray alloc] init];
376 | [nodeArray addObject:root];
377 |
378 | BOOL isComplete = NO;
379 | while ([nodeArray count]) {
380 | BinarySortTree *currentNode = [nodeArray firstObject];
381 | [nodeArray removeObjectAtIndex:0];
382 | if (!currentNode.leftNode && currentNode.rightNode) {
383 | return NO;
384 | }
385 |
386 | if (isComplete && (currentNode.leftNode || currentNode.rightNode)) {
387 | return NO;
388 | }
389 |
390 | if (nil == currentNode.rightNode) {
391 | isComplete = YES;
392 | }
393 | if (currentNode.leftNode) {
394 | [nodeArray addObject:currentNode.leftNode];
395 | }
396 | if (currentNode.rightNode) {
397 | [nodeArray addObject:currentNode.rightNode];
398 | }
399 | }
400 | return isComplete;
401 | }
402 |
403 |
404 | // 判断二叉树是否满二叉树
405 | + (BOOL)isFullBinaryTree:(BinarySortTree *)root {
406 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
407 | return NO;
408 | }
409 |
410 | NSInteger leafs = [self numbersOfLeafsInTree:root];
411 | NSInteger depth = [self depthOfTree:root];
412 | return leafs == pow(2, depth - 1);
413 | }
414 |
415 | // 判断二叉树是否平衡二叉树
416 | + (BOOL)isAVLBinaryTree:(BinarySortTree *)root {
417 | static NSInteger height;
418 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
419 | height = 0;
420 | return YES;
421 | }
422 |
423 | if (nil == root.leftNode && nil == root.rightNode) {
424 | height = 1;
425 | return YES;
426 | }
427 |
428 | [self isAVLBinaryTree:root.leftNode];
429 | NSInteger heightOfLeft = height;
430 | [self isAVLBinaryTree:root.rightNode];
431 | NSInteger heightOfRight = height;
432 | height = MAX(heightOfLeft, heightOfRight) + 1;
433 |
434 | if (heightOfLeft && heightOfRight && ABS(heightOfRight - heightOfLeft) <= 1) {
435 | return YES;
436 | }
437 |
438 | return NO;
439 | }
440 |
441 | // 删除排序二叉树中的节点
442 | + (void)deleteNodeInTree:(BinarySortTree *)root deleteNode:(NSInteger)value {
443 | if (!(nil != root && [root isKindOfClass:[BinarySortTree class]])) {
444 | return;
445 | }
446 |
447 | BinarySortTree *currentNode = root;
448 | BinarySortTree *parentNode = root;
449 | BOOL isLeft = YES;
450 | while (currentNode.value != value) {
451 | parentNode = currentNode;
452 |
453 | if (currentNode.value > value) {
454 | isLeft = YES;
455 | currentNode = currentNode.leftNode;
456 | }
457 | else {
458 | isLeft = NO;
459 | currentNode = currentNode.rightNode;
460 | }
461 |
462 | if (nil == currentNode) {
463 | return;
464 | }
465 | }
466 |
467 | if (nil == currentNode.leftNode && nil == currentNode.rightNode) {
468 | if (currentNode == root) {
469 | root = nil;
470 | }
471 | else if (isLeft) {
472 | parentNode.leftNode = nil;
473 | }
474 | else {
475 | parentNode.rightNode = nil;
476 | }
477 | }
478 | else if (nil == currentNode.leftNode) {
479 | if (currentNode == root) {
480 | root = currentNode.rightNode;
481 | }
482 | else if (isLeft) {
483 | parentNode.leftNode = currentNode.rightNode;
484 | }
485 | else {
486 | parentNode.rightNode = currentNode.rightNode;
487 | }
488 | }
489 | else if (nil == currentNode.rightNode) {
490 | if (currentNode == root) {
491 | root = currentNode.leftNode;
492 | }
493 | else if (isLeft) {
494 | parentNode.leftNode = currentNode.leftNode;
495 | }
496 | else {
497 | parentNode.rightNode = currentNode.leftNode;
498 | }
499 | }
500 | else {
501 | BinarySortTree *middle = [self getMiddleSortNode:currentNode];
502 | if (currentNode == root) {
503 | root = middle;
504 | }
505 | else if (isLeft) {
506 | parentNode.leftNode = middle;
507 | }
508 | else {
509 | parentNode.rightNode = middle;
510 | }
511 | middle.leftNode = currentNode.leftNode;
512 | NSLog(@"123");
513 | }
514 | }
515 |
516 | + (BinarySortTree *)getMiddleSortNode:(BinarySortTree *)node {
517 | if (!(nil != node && [node isKindOfClass:[BinarySortTree class]])) {
518 | return nil;
519 | }
520 |
521 | BinarySortTree *middleNode = node;
522 | BinarySortTree *parentNode = node;
523 | BinarySortTree *currentNode = node.rightNode;
524 |
525 | while (nil != currentNode) {
526 | parentNode = middleNode;
527 | middleNode = currentNode;
528 | currentNode = currentNode.leftNode;
529 | }
530 |
531 | if (middleNode != node.rightNode) {
532 | parentNode.leftNode = middleNode.rightNode;
533 | middleNode.rightNode = node.rightNode;
534 | }
535 |
536 | return middleNode;
537 | }
538 |
539 | // 判断二叉树是否是二叉搜索树
540 | + (BOOL)isBinarySearchTree:(BinarySortTree *)root {
541 |
542 | if (nil == root) {
543 | return YES;
544 | }
545 |
546 | if ((root.leftNode && root.value < root.leftNode.value) || (root.rightNode && root.value > root.rightNode.value)) {
547 | return NO;
548 | }
549 | [self isBinarySearchTree:root.leftNode];
550 | [self isBinarySearchTree:root.rightNode];
551 |
552 | return YES;
553 | }
554 |
555 | // 判断一棵树是否是另一棵树的子树
556 | + (BOOL)isContainTree:(BinarySortTree *)root childNode:(BinarySortTree *)childNode {
557 | if (nil == childNode) {
558 | return YES;
559 | }
560 |
561 | if (nil == root) {
562 | return NO;
563 | }
564 |
565 | if (root.value == childNode.value) {
566 | if ([self isMatch:root childNode:childNode]) {
567 | return YES;
568 | }
569 | }
570 |
571 | return [self isContainTree:root.leftNode childNode:childNode] || [self isContainTree:root.rightNode childNode:childNode];
572 | }
573 |
574 | + (BOOL)isMatch:(BinarySortTree *)root childNode:(BinarySortTree *)childNode {
575 | if (nil == root && nil == childNode) {
576 | return YES;
577 | }
578 | if (nil == root || nil == childNode) {
579 | return NO;
580 | }
581 | if (root.value != childNode.value) {
582 | return NO;
583 | }
584 | return [self isMatch:root.leftNode childNode:childNode.leftNode] && [self isMatch:root.rightNode childNode:childNode.rightNode];
585 | }
586 |
587 | // 找出一棵二叉树中所有路径,并且其路径之和等于一个给定的值
588 | + (void)findAllPathInTree:(BinarySortTree *)root pathArray:(NSMutableArray *)path vectore:(NSMutableArray *)vectore sum:(NSInteger)sum {
589 | if (nil == root) {
590 | return;
591 | }
592 | if (nil != root && nil == root.leftNode && nil == root.rightNode && sum - root.value > 0) {
593 | [path removeLastObject];
594 | }
595 |
596 | [path addObject:[NSNumber numberWithInteger:root.value]];
597 | if (sum == root.value) {
598 | [vectore addObject:[[NSMutableArray alloc] initWithArray:path]];
599 | }
600 |
601 | [self findAllPathInTree:root.leftNode pathArray:path vectore:vectore sum:(sum - root.value)];
602 | [self findAllPathInTree:root.rightNode pathArray:path vectore:vectore sum:(sum - root.value)];
603 | }
604 |
605 | // 中序遍历不带父链接的二叉树,找到给定节点的下一个节点,后继为比当前节点大的所有节点中值最小的那个
606 | + (BinarySortTree *)findSuccessor:(BinarySortTree *)root searchNode:(BinarySortTree *)node {
607 | if (nil == root) {
608 | return nil;
609 | }
610 |
611 | if (nil != node.rightNode) {
612 | BinarySortTree *left = node.rightNode;
613 | while (left.leftNode) {
614 | left = left.leftNode;
615 | }
616 | return left;
617 | }
618 |
619 | BinarySortTree *parentNode = nil;
620 | while (root) {
621 | if (root.value > node.value) {
622 | parentNode = root;
623 | root = root.leftNode;
624 | }
625 | else {
626 | root = root.rightNode;
627 | }
628 | }
629 |
630 | return parentNode;
631 | }
632 |
633 | // 中序遍历不带父链接的二叉树,找到给定节点的上一个节点,后继为比当前节点小的所有节点中值最大的那个
634 | + (BinarySortTree *)findPrecursor:(BinarySortTree *)root searchNode:(BinarySortTree *)node {
635 | if (nil == root) {
636 | return nil;
637 | }
638 |
639 | if (node.leftNode) {
640 | BinarySortTree *right = node.leftNode;
641 | while (right.rightNode) {
642 | right = right.rightNode;
643 | }
644 | return right;
645 | }
646 |
647 | BinarySortTree *parentNode = nil;
648 | while (root) {
649 | if (root.value >= node.value) {
650 | root = root.leftNode;
651 | }
652 | else {
653 | parentNode = root;
654 | root = root.rightNode;
655 | }
656 | }
657 | return parentNode;
658 | }
659 |
660 | + (NSString *)serializeBinaryTree:(BinarySortTree *)root {
661 | if (nil == serialString) {
662 | serialString = [[NSMutableArray alloc] init];
663 | }
664 |
665 | if (!(root && [root isKindOfClass:[BinarySortTree class]])) {
666 | [serialString addObject:@"#"];
667 | return nil;
668 | }
669 |
670 | [serialString addObject:[NSString stringWithFormat:@"%d", (int)root.value]];
671 | [self serializeBinaryTree:root.leftNode];
672 | [self serializeBinaryTree:root.rightNode];
673 |
674 | return [serialString componentsJoinedByString:@","];
675 | }
676 |
677 | + (BinarySortTree *)deserializeBinaryTree:(NSString *)serialString {
678 | if (nil == serialString) {
679 | return nil;
680 | }
681 |
682 | BinarySortTree *node;
683 | NSArray *array = [serialString componentsSeparatedByString:@","];
684 | if (![array[serialCount] isEqualToString:@"#"]) {
685 | node = [[BinarySortTree alloc] init];
686 | node.value = [array[serialCount] intValue];
687 | serialCount++;
688 | node.leftNode = [self deserializeBinaryTree:serialString];
689 | node.rightNode = [self deserializeBinaryTree:serialString];
690 | }
691 | return node;
692 | }
693 |
694 | @end
695 |
--------------------------------------------------------------------------------
/iOSInterView/iOSInterView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 602502751DC1C93C0051BE52 /* NSArray+StackAndQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 602502741DC1C93C0051BE52 /* NSArray+StackAndQueue.m */; };
11 | 606354811DD1B9F400E4CAC8 /* GraphMatrix.m in Sources */ = {isa = PBXBuildFile; fileRef = 606354801DD1B9F400E4CAC8 /* GraphMatrix.m */; };
12 | 606354841DD2CA6E00E4CAC8 /* Heap.m in Sources */ = {isa = PBXBuildFile; fileRef = 606354831DD2CA6E00E4CAC8 /* Heap.m */; };
13 | 6063548A1DD2CFBC00E4CAC8 /* HeapNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 606354891DD2CFBC00E4CAC8 /* HeapNode.m */; };
14 | 607AAAC41DD4C05A004AD10F /* StringStruct.m in Sources */ = {isa = PBXBuildFile; fileRef = 607AAAC31DD4C05A004AD10F /* StringStruct.m */; };
15 | 607AE7401DC9DDDD0022030F /* GraphTheory.m in Sources */ = {isa = PBXBuildFile; fileRef = 607AE73F1DC9DDDD0022030F /* GraphTheory.m */; };
16 | 607AE7431DC9E8EC0022030F /* GraphNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 607AE7421DC9E8EC0022030F /* GraphNode.m */; };
17 | 60BAEAC21DBF230700F35185 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAC11DBF230700F35185 /* main.m */; };
18 | 60BAEAC51DBF230700F35185 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAC41DBF230700F35185 /* AppDelegate.m */; };
19 | 60BAEAC81DBF230700F35185 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAC71DBF230700F35185 /* ViewController.m */; };
20 | 60BAEACB1DBF230700F35185 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 60BAEAC91DBF230700F35185 /* Main.storyboard */; };
21 | 60BAEACD1DBF230700F35185 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 60BAEACC1DBF230700F35185 /* Assets.xcassets */; };
22 | 60BAEAD01DBF230700F35185 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 60BAEACE1DBF230700F35185 /* LaunchScreen.storyboard */; };
23 | 60BAEADB1DBF230700F35185 /* iOSInterViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEADA1DBF230700F35185 /* iOSInterViewTests.m */; };
24 | 60BAEAE61DBF230700F35185 /* iOSInterViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAE51DBF230700F35185 /* iOSInterViewUITests.m */; };
25 | 60BAEAF51DBF239A00F35185 /* BinarySortTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAF41DBF239A00F35185 /* BinarySortTree.m */; };
26 | 60BAEAF81DBF23E100F35185 /* LinkedList.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BAEAF71DBF23E100F35185 /* LinkedList.m */; };
27 | 60C0ED8D1DC33634000D4B3A /* NSArraySort.m in Sources */ = {isa = PBXBuildFile; fileRef = 60C0ED8C1DC33634000D4B3A /* NSArraySort.m */; };
28 | /* End PBXBuildFile section */
29 |
30 | /* Begin PBXContainerItemProxy section */
31 | 60BAEAD71DBF230700F35185 /* PBXContainerItemProxy */ = {
32 | isa = PBXContainerItemProxy;
33 | containerPortal = 60BAEAB51DBF230700F35185 /* Project object */;
34 | proxyType = 1;
35 | remoteGlobalIDString = 60BAEABC1DBF230700F35185;
36 | remoteInfo = iOSInterView;
37 | };
38 | 60BAEAE21DBF230700F35185 /* PBXContainerItemProxy */ = {
39 | isa = PBXContainerItemProxy;
40 | containerPortal = 60BAEAB51DBF230700F35185 /* Project object */;
41 | proxyType = 1;
42 | remoteGlobalIDString = 60BAEABC1DBF230700F35185;
43 | remoteInfo = iOSInterView;
44 | };
45 | /* End PBXContainerItemProxy section */
46 |
47 | /* Begin PBXFileReference section */
48 | 602502731DC1C93C0051BE52 /* NSArray+StackAndQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+StackAndQueue.h"; sourceTree = ""; };
49 | 602502741DC1C93C0051BE52 /* NSArray+StackAndQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+StackAndQueue.m"; sourceTree = ""; };
50 | 6063547F1DD1B9F400E4CAC8 /* GraphMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphMatrix.h; sourceTree = ""; };
51 | 606354801DD1B9F400E4CAC8 /* GraphMatrix.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GraphMatrix.m; sourceTree = ""; };
52 | 606354821DD2CA6E00E4CAC8 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heap.h; sourceTree = ""; };
53 | 606354831DD2CA6E00E4CAC8 /* Heap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Heap.m; sourceTree = ""; };
54 | 606354881DD2CFBC00E4CAC8 /* HeapNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapNode.h; sourceTree = ""; };
55 | 606354891DD2CFBC00E4CAC8 /* HeapNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HeapNode.m; sourceTree = ""; };
56 | 607AAAC21DD4C05A004AD10F /* StringStruct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringStruct.h; sourceTree = ""; };
57 | 607AAAC31DD4C05A004AD10F /* StringStruct.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StringStruct.m; sourceTree = ""; };
58 | 607AE73E1DC9DDDD0022030F /* GraphTheory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphTheory.h; sourceTree = ""; };
59 | 607AE73F1DC9DDDD0022030F /* GraphTheory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GraphTheory.m; sourceTree = ""; };
60 | 607AE7411DC9E8EC0022030F /* GraphNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphNode.h; sourceTree = ""; };
61 | 607AE7421DC9E8EC0022030F /* GraphNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GraphNode.m; sourceTree = ""; };
62 | 60BAEABD1DBF230700F35185 /* iOSInterView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSInterView.app; sourceTree = BUILT_PRODUCTS_DIR; };
63 | 60BAEAC11DBF230700F35185 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
64 | 60BAEAC31DBF230700F35185 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
65 | 60BAEAC41DBF230700F35185 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
66 | 60BAEAC61DBF230700F35185 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
67 | 60BAEAC71DBF230700F35185 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
68 | 60BAEACA1DBF230700F35185 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
69 | 60BAEACC1DBF230700F35185 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
70 | 60BAEACF1DBF230700F35185 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
71 | 60BAEAD11DBF230700F35185 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
72 | 60BAEAD61DBF230700F35185 /* iOSInterViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSInterViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
73 | 60BAEADA1DBF230700F35185 /* iOSInterViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOSInterViewTests.m; sourceTree = ""; };
74 | 60BAEADC1DBF230700F35185 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
75 | 60BAEAE11DBF230700F35185 /* iOSInterViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = iOSInterViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
76 | 60BAEAE51DBF230700F35185 /* iOSInterViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iOSInterViewUITests.m; sourceTree = ""; };
77 | 60BAEAE71DBF230700F35185 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
78 | 60BAEAF31DBF239A00F35185 /* BinarySortTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySortTree.h; sourceTree = ""; };
79 | 60BAEAF41DBF239A00F35185 /* BinarySortTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BinarySortTree.m; sourceTree = ""; };
80 | 60BAEAF61DBF23E100F35185 /* LinkedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkedList.h; sourceTree = ""; };
81 | 60BAEAF71DBF23E100F35185 /* LinkedList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinkedList.m; sourceTree = ""; };
82 | 60C0ED8B1DC33634000D4B3A /* NSArraySort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSArraySort.h; sourceTree = ""; };
83 | 60C0ED8C1DC33634000D4B3A /* NSArraySort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSArraySort.m; sourceTree = ""; };
84 | /* End PBXFileReference section */
85 |
86 | /* Begin PBXFrameworksBuildPhase section */
87 | 60BAEABA1DBF230700F35185 /* Frameworks */ = {
88 | isa = PBXFrameworksBuildPhase;
89 | buildActionMask = 2147483647;
90 | files = (
91 | );
92 | runOnlyForDeploymentPostprocessing = 0;
93 | };
94 | 60BAEAD31DBF230700F35185 /* Frameworks */ = {
95 | isa = PBXFrameworksBuildPhase;
96 | buildActionMask = 2147483647;
97 | files = (
98 | );
99 | runOnlyForDeploymentPostprocessing = 0;
100 | };
101 | 60BAEADE1DBF230700F35185 /* Frameworks */ = {
102 | isa = PBXFrameworksBuildPhase;
103 | buildActionMask = 2147483647;
104 | files = (
105 | );
106 | runOnlyForDeploymentPostprocessing = 0;
107 | };
108 | /* End PBXFrameworksBuildPhase section */
109 |
110 | /* Begin PBXGroup section */
111 | 60BAEAB41DBF230700F35185 = {
112 | isa = PBXGroup;
113 | children = (
114 | 60BAEABF1DBF230700F35185 /* iOSInterView */,
115 | 60BAEAD91DBF230700F35185 /* iOSInterViewTests */,
116 | 60BAEAE41DBF230700F35185 /* iOSInterViewUITests */,
117 | 60BAEABE1DBF230700F35185 /* Products */,
118 | );
119 | sourceTree = "";
120 | };
121 | 60BAEABE1DBF230700F35185 /* Products */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 60BAEABD1DBF230700F35185 /* iOSInterView.app */,
125 | 60BAEAD61DBF230700F35185 /* iOSInterViewTests.xctest */,
126 | 60BAEAE11DBF230700F35185 /* iOSInterViewUITests.xctest */,
127 | );
128 | name = Products;
129 | sourceTree = "";
130 | };
131 | 60BAEABF1DBF230700F35185 /* iOSInterView */ = {
132 | isa = PBXGroup;
133 | children = (
134 | 60BAEAF61DBF23E100F35185 /* LinkedList.h */,
135 | 60BAEAF71DBF23E100F35185 /* LinkedList.m */,
136 | 60BAEAF31DBF239A00F35185 /* BinarySortTree.h */,
137 | 60BAEAF41DBF239A00F35185 /* BinarySortTree.m */,
138 | 60BAEAC31DBF230700F35185 /* AppDelegate.h */,
139 | 60BAEAC41DBF230700F35185 /* AppDelegate.m */,
140 | 60BAEAC61DBF230700F35185 /* ViewController.h */,
141 | 60BAEAC71DBF230700F35185 /* ViewController.m */,
142 | 60BAEAC91DBF230700F35185 /* Main.storyboard */,
143 | 60BAEACC1DBF230700F35185 /* Assets.xcassets */,
144 | 60BAEACE1DBF230700F35185 /* LaunchScreen.storyboard */,
145 | 60BAEAD11DBF230700F35185 /* Info.plist */,
146 | 60BAEAC01DBF230700F35185 /* Supporting Files */,
147 | 602502731DC1C93C0051BE52 /* NSArray+StackAndQueue.h */,
148 | 602502741DC1C93C0051BE52 /* NSArray+StackAndQueue.m */,
149 | 60C0ED8B1DC33634000D4B3A /* NSArraySort.h */,
150 | 60C0ED8C1DC33634000D4B3A /* NSArraySort.m */,
151 | 607AE73E1DC9DDDD0022030F /* GraphTheory.h */,
152 | 607AE73F1DC9DDDD0022030F /* GraphTheory.m */,
153 | 607AE7411DC9E8EC0022030F /* GraphNode.h */,
154 | 607AE7421DC9E8EC0022030F /* GraphNode.m */,
155 | 6063547F1DD1B9F400E4CAC8 /* GraphMatrix.h */,
156 | 606354801DD1B9F400E4CAC8 /* GraphMatrix.m */,
157 | 606354821DD2CA6E00E4CAC8 /* Heap.h */,
158 | 606354831DD2CA6E00E4CAC8 /* Heap.m */,
159 | 606354881DD2CFBC00E4CAC8 /* HeapNode.h */,
160 | 606354891DD2CFBC00E4CAC8 /* HeapNode.m */,
161 | 607AAAC21DD4C05A004AD10F /* StringStruct.h */,
162 | 607AAAC31DD4C05A004AD10F /* StringStruct.m */,
163 | );
164 | path = iOSInterView;
165 | sourceTree = "";
166 | };
167 | 60BAEAC01DBF230700F35185 /* Supporting Files */ = {
168 | isa = PBXGroup;
169 | children = (
170 | 60BAEAC11DBF230700F35185 /* main.m */,
171 | );
172 | name = "Supporting Files";
173 | sourceTree = "";
174 | };
175 | 60BAEAD91DBF230700F35185 /* iOSInterViewTests */ = {
176 | isa = PBXGroup;
177 | children = (
178 | 60BAEADA1DBF230700F35185 /* iOSInterViewTests.m */,
179 | 60BAEADC1DBF230700F35185 /* Info.plist */,
180 | );
181 | path = iOSInterViewTests;
182 | sourceTree = "";
183 | };
184 | 60BAEAE41DBF230700F35185 /* iOSInterViewUITests */ = {
185 | isa = PBXGroup;
186 | children = (
187 | 60BAEAE51DBF230700F35185 /* iOSInterViewUITests.m */,
188 | 60BAEAE71DBF230700F35185 /* Info.plist */,
189 | );
190 | path = iOSInterViewUITests;
191 | sourceTree = "";
192 | };
193 | /* End PBXGroup section */
194 |
195 | /* Begin PBXNativeTarget section */
196 | 60BAEABC1DBF230700F35185 /* iOSInterView */ = {
197 | isa = PBXNativeTarget;
198 | buildConfigurationList = 60BAEAEA1DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterView" */;
199 | buildPhases = (
200 | 60BAEAB91DBF230700F35185 /* Sources */,
201 | 60BAEABA1DBF230700F35185 /* Frameworks */,
202 | 60BAEABB1DBF230700F35185 /* Resources */,
203 | );
204 | buildRules = (
205 | );
206 | dependencies = (
207 | );
208 | name = iOSInterView;
209 | productName = iOSInterView;
210 | productReference = 60BAEABD1DBF230700F35185 /* iOSInterView.app */;
211 | productType = "com.apple.product-type.application";
212 | };
213 | 60BAEAD51DBF230700F35185 /* iOSInterViewTests */ = {
214 | isa = PBXNativeTarget;
215 | buildConfigurationList = 60BAEAED1DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterViewTests" */;
216 | buildPhases = (
217 | 60BAEAD21DBF230700F35185 /* Sources */,
218 | 60BAEAD31DBF230700F35185 /* Frameworks */,
219 | 60BAEAD41DBF230700F35185 /* Resources */,
220 | );
221 | buildRules = (
222 | );
223 | dependencies = (
224 | 60BAEAD81DBF230700F35185 /* PBXTargetDependency */,
225 | );
226 | name = iOSInterViewTests;
227 | productName = iOSInterViewTests;
228 | productReference = 60BAEAD61DBF230700F35185 /* iOSInterViewTests.xctest */;
229 | productType = "com.apple.product-type.bundle.unit-test";
230 | };
231 | 60BAEAE01DBF230700F35185 /* iOSInterViewUITests */ = {
232 | isa = PBXNativeTarget;
233 | buildConfigurationList = 60BAEAF01DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterViewUITests" */;
234 | buildPhases = (
235 | 60BAEADD1DBF230700F35185 /* Sources */,
236 | 60BAEADE1DBF230700F35185 /* Frameworks */,
237 | 60BAEADF1DBF230700F35185 /* Resources */,
238 | );
239 | buildRules = (
240 | );
241 | dependencies = (
242 | 60BAEAE31DBF230700F35185 /* PBXTargetDependency */,
243 | );
244 | name = iOSInterViewUITests;
245 | productName = iOSInterViewUITests;
246 | productReference = 60BAEAE11DBF230700F35185 /* iOSInterViewUITests.xctest */;
247 | productType = "com.apple.product-type.bundle.ui-testing";
248 | };
249 | /* End PBXNativeTarget section */
250 |
251 | /* Begin PBXProject section */
252 | 60BAEAB51DBF230700F35185 /* Project object */ = {
253 | isa = PBXProject;
254 | attributes = {
255 | LastUpgradeCheck = 0800;
256 | ORGANIZATIONNAME = "smartfutureplayer@gmail.com";
257 | TargetAttributes = {
258 | 60BAEABC1DBF230700F35185 = {
259 | CreatedOnToolsVersion = 8.0;
260 | ProvisioningStyle = Automatic;
261 | };
262 | 60BAEAD51DBF230700F35185 = {
263 | CreatedOnToolsVersion = 8.0;
264 | ProvisioningStyle = Automatic;
265 | TestTargetID = 60BAEABC1DBF230700F35185;
266 | };
267 | 60BAEAE01DBF230700F35185 = {
268 | CreatedOnToolsVersion = 8.0;
269 | ProvisioningStyle = Automatic;
270 | TestTargetID = 60BAEABC1DBF230700F35185;
271 | };
272 | };
273 | };
274 | buildConfigurationList = 60BAEAB81DBF230700F35185 /* Build configuration list for PBXProject "iOSInterView" */;
275 | compatibilityVersion = "Xcode 3.2";
276 | developmentRegion = English;
277 | hasScannedForEncodings = 0;
278 | knownRegions = (
279 | en,
280 | Base,
281 | );
282 | mainGroup = 60BAEAB41DBF230700F35185;
283 | productRefGroup = 60BAEABE1DBF230700F35185 /* Products */;
284 | projectDirPath = "";
285 | projectRoot = "";
286 | targets = (
287 | 60BAEABC1DBF230700F35185 /* iOSInterView */,
288 | 60BAEAD51DBF230700F35185 /* iOSInterViewTests */,
289 | 60BAEAE01DBF230700F35185 /* iOSInterViewUITests */,
290 | );
291 | };
292 | /* End PBXProject section */
293 |
294 | /* Begin PBXResourcesBuildPhase section */
295 | 60BAEABB1DBF230700F35185 /* Resources */ = {
296 | isa = PBXResourcesBuildPhase;
297 | buildActionMask = 2147483647;
298 | files = (
299 | 60BAEAD01DBF230700F35185 /* LaunchScreen.storyboard in Resources */,
300 | 60BAEACD1DBF230700F35185 /* Assets.xcassets in Resources */,
301 | 60BAEACB1DBF230700F35185 /* Main.storyboard in Resources */,
302 | );
303 | runOnlyForDeploymentPostprocessing = 0;
304 | };
305 | 60BAEAD41DBF230700F35185 /* Resources */ = {
306 | isa = PBXResourcesBuildPhase;
307 | buildActionMask = 2147483647;
308 | files = (
309 | );
310 | runOnlyForDeploymentPostprocessing = 0;
311 | };
312 | 60BAEADF1DBF230700F35185 /* Resources */ = {
313 | isa = PBXResourcesBuildPhase;
314 | buildActionMask = 2147483647;
315 | files = (
316 | );
317 | runOnlyForDeploymentPostprocessing = 0;
318 | };
319 | /* End PBXResourcesBuildPhase section */
320 |
321 | /* Begin PBXSourcesBuildPhase section */
322 | 60BAEAB91DBF230700F35185 /* Sources */ = {
323 | isa = PBXSourcesBuildPhase;
324 | buildActionMask = 2147483647;
325 | files = (
326 | 602502751DC1C93C0051BE52 /* NSArray+StackAndQueue.m in Sources */,
327 | 606354811DD1B9F400E4CAC8 /* GraphMatrix.m in Sources */,
328 | 60BAEAF51DBF239A00F35185 /* BinarySortTree.m in Sources */,
329 | 60BAEAC81DBF230700F35185 /* ViewController.m in Sources */,
330 | 607AE7431DC9E8EC0022030F /* GraphNode.m in Sources */,
331 | 6063548A1DD2CFBC00E4CAC8 /* HeapNode.m in Sources */,
332 | 60C0ED8D1DC33634000D4B3A /* NSArraySort.m in Sources */,
333 | 60BAEAC51DBF230700F35185 /* AppDelegate.m in Sources */,
334 | 607AAAC41DD4C05A004AD10F /* StringStruct.m in Sources */,
335 | 607AE7401DC9DDDD0022030F /* GraphTheory.m in Sources */,
336 | 606354841DD2CA6E00E4CAC8 /* Heap.m in Sources */,
337 | 60BAEAF81DBF23E100F35185 /* LinkedList.m in Sources */,
338 | 60BAEAC21DBF230700F35185 /* main.m in Sources */,
339 | );
340 | runOnlyForDeploymentPostprocessing = 0;
341 | };
342 | 60BAEAD21DBF230700F35185 /* Sources */ = {
343 | isa = PBXSourcesBuildPhase;
344 | buildActionMask = 2147483647;
345 | files = (
346 | 60BAEADB1DBF230700F35185 /* iOSInterViewTests.m in Sources */,
347 | );
348 | runOnlyForDeploymentPostprocessing = 0;
349 | };
350 | 60BAEADD1DBF230700F35185 /* Sources */ = {
351 | isa = PBXSourcesBuildPhase;
352 | buildActionMask = 2147483647;
353 | files = (
354 | 60BAEAE61DBF230700F35185 /* iOSInterViewUITests.m in Sources */,
355 | );
356 | runOnlyForDeploymentPostprocessing = 0;
357 | };
358 | /* End PBXSourcesBuildPhase section */
359 |
360 | /* Begin PBXTargetDependency section */
361 | 60BAEAD81DBF230700F35185 /* PBXTargetDependency */ = {
362 | isa = PBXTargetDependency;
363 | target = 60BAEABC1DBF230700F35185 /* iOSInterView */;
364 | targetProxy = 60BAEAD71DBF230700F35185 /* PBXContainerItemProxy */;
365 | };
366 | 60BAEAE31DBF230700F35185 /* PBXTargetDependency */ = {
367 | isa = PBXTargetDependency;
368 | target = 60BAEABC1DBF230700F35185 /* iOSInterView */;
369 | targetProxy = 60BAEAE21DBF230700F35185 /* PBXContainerItemProxy */;
370 | };
371 | /* End PBXTargetDependency section */
372 |
373 | /* Begin PBXVariantGroup section */
374 | 60BAEAC91DBF230700F35185 /* Main.storyboard */ = {
375 | isa = PBXVariantGroup;
376 | children = (
377 | 60BAEACA1DBF230700F35185 /* Base */,
378 | );
379 | name = Main.storyboard;
380 | sourceTree = "";
381 | };
382 | 60BAEACE1DBF230700F35185 /* LaunchScreen.storyboard */ = {
383 | isa = PBXVariantGroup;
384 | children = (
385 | 60BAEACF1DBF230700F35185 /* Base */,
386 | );
387 | name = LaunchScreen.storyboard;
388 | sourceTree = "";
389 | };
390 | /* End PBXVariantGroup section */
391 |
392 | /* Begin XCBuildConfiguration section */
393 | 60BAEAE81DBF230700F35185 /* Debug */ = {
394 | isa = XCBuildConfiguration;
395 | buildSettings = {
396 | ALWAYS_SEARCH_USER_PATHS = NO;
397 | CLANG_ANALYZER_NONNULL = YES;
398 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
399 | CLANG_CXX_LIBRARY = "libc++";
400 | CLANG_ENABLE_MODULES = YES;
401 | CLANG_ENABLE_OBJC_ARC = YES;
402 | CLANG_WARN_BOOL_CONVERSION = YES;
403 | CLANG_WARN_CONSTANT_CONVERSION = YES;
404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
405 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
406 | CLANG_WARN_EMPTY_BODY = YES;
407 | CLANG_WARN_ENUM_CONVERSION = YES;
408 | CLANG_WARN_INFINITE_RECURSION = YES;
409 | CLANG_WARN_INT_CONVERSION = YES;
410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
411 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
412 | CLANG_WARN_UNREACHABLE_CODE = YES;
413 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
414 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
415 | COPY_PHASE_STRIP = NO;
416 | DEBUG_INFORMATION_FORMAT = dwarf;
417 | ENABLE_STRICT_OBJC_MSGSEND = YES;
418 | ENABLE_TESTABILITY = YES;
419 | GCC_C_LANGUAGE_STANDARD = gnu99;
420 | GCC_DYNAMIC_NO_PIC = NO;
421 | GCC_NO_COMMON_BLOCKS = YES;
422 | GCC_OPTIMIZATION_LEVEL = 0;
423 | GCC_PREPROCESSOR_DEFINITIONS = (
424 | "DEBUG=1",
425 | "$(inherited)",
426 | );
427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
429 | GCC_WARN_UNDECLARED_SELECTOR = YES;
430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
431 | GCC_WARN_UNUSED_FUNCTION = YES;
432 | GCC_WARN_UNUSED_VARIABLE = YES;
433 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
434 | MTL_ENABLE_DEBUG_INFO = YES;
435 | ONLY_ACTIVE_ARCH = YES;
436 | SDKROOT = iphoneos;
437 | TARGETED_DEVICE_FAMILY = "1,2";
438 | };
439 | name = Debug;
440 | };
441 | 60BAEAE91DBF230700F35185 /* Release */ = {
442 | isa = XCBuildConfiguration;
443 | buildSettings = {
444 | ALWAYS_SEARCH_USER_PATHS = NO;
445 | CLANG_ANALYZER_NONNULL = YES;
446 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
447 | CLANG_CXX_LIBRARY = "libc++";
448 | CLANG_ENABLE_MODULES = YES;
449 | CLANG_ENABLE_OBJC_ARC = YES;
450 | CLANG_WARN_BOOL_CONVERSION = YES;
451 | CLANG_WARN_CONSTANT_CONVERSION = YES;
452 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
453 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
454 | CLANG_WARN_EMPTY_BODY = YES;
455 | CLANG_WARN_ENUM_CONVERSION = YES;
456 | CLANG_WARN_INFINITE_RECURSION = YES;
457 | CLANG_WARN_INT_CONVERSION = YES;
458 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
459 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
460 | CLANG_WARN_UNREACHABLE_CODE = YES;
461 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
462 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
463 | COPY_PHASE_STRIP = NO;
464 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
465 | ENABLE_NS_ASSERTIONS = NO;
466 | ENABLE_STRICT_OBJC_MSGSEND = YES;
467 | GCC_C_LANGUAGE_STANDARD = gnu99;
468 | GCC_NO_COMMON_BLOCKS = YES;
469 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
470 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
471 | GCC_WARN_UNDECLARED_SELECTOR = YES;
472 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
473 | GCC_WARN_UNUSED_FUNCTION = YES;
474 | GCC_WARN_UNUSED_VARIABLE = YES;
475 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
476 | MTL_ENABLE_DEBUG_INFO = NO;
477 | SDKROOT = iphoneos;
478 | TARGETED_DEVICE_FAMILY = "1,2";
479 | VALIDATE_PRODUCT = YES;
480 | };
481 | name = Release;
482 | };
483 | 60BAEAEB1DBF230700F35185 /* Debug */ = {
484 | isa = XCBuildConfiguration;
485 | buildSettings = {
486 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
487 | INFOPLIST_FILE = iOSInterView/Info.plist;
488 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
489 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterView;
490 | PRODUCT_NAME = "$(TARGET_NAME)";
491 | };
492 | name = Debug;
493 | };
494 | 60BAEAEC1DBF230700F35185 /* Release */ = {
495 | isa = XCBuildConfiguration;
496 | buildSettings = {
497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
498 | INFOPLIST_FILE = iOSInterView/Info.plist;
499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
500 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterView;
501 | PRODUCT_NAME = "$(TARGET_NAME)";
502 | };
503 | name = Release;
504 | };
505 | 60BAEAEE1DBF230700F35185 /* Debug */ = {
506 | isa = XCBuildConfiguration;
507 | buildSettings = {
508 | BUNDLE_LOADER = "$(TEST_HOST)";
509 | INFOPLIST_FILE = iOSInterViewTests/Info.plist;
510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
511 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterViewTests;
512 | PRODUCT_NAME = "$(TARGET_NAME)";
513 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSInterView.app/iOSInterView";
514 | };
515 | name = Debug;
516 | };
517 | 60BAEAEF1DBF230700F35185 /* Release */ = {
518 | isa = XCBuildConfiguration;
519 | buildSettings = {
520 | BUNDLE_LOADER = "$(TEST_HOST)";
521 | INFOPLIST_FILE = iOSInterViewTests/Info.plist;
522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
523 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterViewTests;
524 | PRODUCT_NAME = "$(TARGET_NAME)";
525 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSInterView.app/iOSInterView";
526 | };
527 | name = Release;
528 | };
529 | 60BAEAF11DBF230700F35185 /* Debug */ = {
530 | isa = XCBuildConfiguration;
531 | buildSettings = {
532 | INFOPLIST_FILE = iOSInterViewUITests/Info.plist;
533 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
534 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterViewUITests;
535 | PRODUCT_NAME = "$(TARGET_NAME)";
536 | TEST_TARGET_NAME = iOSInterView;
537 | };
538 | name = Debug;
539 | };
540 | 60BAEAF21DBF230700F35185 /* Release */ = {
541 | isa = XCBuildConfiguration;
542 | buildSettings = {
543 | INFOPLIST_FILE = iOSInterViewUITests/Info.plist;
544 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
545 | PRODUCT_BUNDLE_IDENTIFIER = itoss.iOSInterViewUITests;
546 | PRODUCT_NAME = "$(TARGET_NAME)";
547 | TEST_TARGET_NAME = iOSInterView;
548 | };
549 | name = Release;
550 | };
551 | /* End XCBuildConfiguration section */
552 |
553 | /* Begin XCConfigurationList section */
554 | 60BAEAB81DBF230700F35185 /* Build configuration list for PBXProject "iOSInterView" */ = {
555 | isa = XCConfigurationList;
556 | buildConfigurations = (
557 | 60BAEAE81DBF230700F35185 /* Debug */,
558 | 60BAEAE91DBF230700F35185 /* Release */,
559 | );
560 | defaultConfigurationIsVisible = 0;
561 | defaultConfigurationName = Release;
562 | };
563 | 60BAEAEA1DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterView" */ = {
564 | isa = XCConfigurationList;
565 | buildConfigurations = (
566 | 60BAEAEB1DBF230700F35185 /* Debug */,
567 | 60BAEAEC1DBF230700F35185 /* Release */,
568 | );
569 | defaultConfigurationIsVisible = 0;
570 | defaultConfigurationName = Release;
571 | };
572 | 60BAEAED1DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterViewTests" */ = {
573 | isa = XCConfigurationList;
574 | buildConfigurations = (
575 | 60BAEAEE1DBF230700F35185 /* Debug */,
576 | 60BAEAEF1DBF230700F35185 /* Release */,
577 | );
578 | defaultConfigurationIsVisible = 0;
579 | defaultConfigurationName = Release;
580 | };
581 | 60BAEAF01DBF230700F35185 /* Build configuration list for PBXNativeTarget "iOSInterViewUITests" */ = {
582 | isa = XCConfigurationList;
583 | buildConfigurations = (
584 | 60BAEAF11DBF230700F35185 /* Debug */,
585 | 60BAEAF21DBF230700F35185 /* Release */,
586 | );
587 | defaultConfigurationIsVisible = 0;
588 | defaultConfigurationName = Release;
589 | };
590 | /* End XCConfigurationList section */
591 | };
592 | rootObject = 60BAEAB51DBF230700F35185 /* Project object */;
593 | }
594 |
--------------------------------------------------------------------------------