Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool readArgument(){
- char* command = (char*)malloc(1024);
- int value;
- scanf("%s", command);
- //puts(command);
- if(!strcmp(command,"insertNode")) {
- scanf("%d", &value);
- root = insertNode(root, value);
- return true;
- }
- else if(!strcmp(command,"find")){
- scanf("%d", &value);
- find(root, value);
- return true;
- }
- else if(!strcmp(command,"inorder")){
- printInorder(root);
- puts("");
- return true;
- }
- else if(!strcmp(command,"min")){
- findMin(root, true);
- return true;
- }
- else if(!strcmp(command,"max")){
- findMax(root);
- return true;
- }
- else if(!strcmp(command,"delete")){
- scanf("%d", &value);
- root = deleteNode(root, value);
- return true;
- }
- else if(!strcmp(command,"parent")){
- scanf("%d", &value);
- Node* parent = findParent(root, findAndReturn(root, value));
- printf("Parent of %d is %d",value, parent->data);
- }
- else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement