This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(data) { | |
| this.data = data; | |
| this.next = null; | |
| } | |
| } | |
| class LinkedList { | |
| constructor () { | |
| this.head = null; | |
| this.size = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(data) { | |
| this.left; | |
| this.right; | |
| this.data = data; | |
| } | |
| insert(value) { | |
| if(value < this.data) { | |
| if(this.left == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(data, left = null, right = null) { | |
| this.left = left; | |
| this.right = right; | |
| this.data = data; | |
| } | |
| } | |
| class BST { | |
| constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <cs50.h> | |
| #include <math.h> | |
| int main(void) { | |
| long card_no; | |
| do{ | |
| card_no = get_long("Card Number: "); | |
| }while(card_no < 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cs50.h> | |
| #include <stdio.h> | |
| int main(void) | |
| { | |
| int n; | |
| do { | |
| n = get_int("height: "); | |
| }while(n < 1 || n > 8); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <cs50.h> | |
| #include <ctype.h> | |
| #include <string.h> | |
| #include <math.h> | |
| int main(void) | |
| { | |
| string text = get_string("Text:"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <ctype.h> | |
| #include <cs50.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| bool isNumber(char number[]); | |
| int main(int argc, string argv[]) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <ctype.h> | |
| #include <cs50.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| bool isAlpha(string key); | |
| bool hasDuplicates(string key); | |
| int main(int argc, string argv[]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cs50.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| // Max number of candidates | |
| #define MAX 9 | |
| // Candidates have name and vote count | |
| typedef struct | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cs50.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| // Max voters and candidates | |
| #define MAX_VOTERS 100 | |
| #define MAX_CANDIDATES 9 | |
| // preferences[i][j] is jth preference for voter i | |
| int preferences[MAX_VOTERS][MAX_CANDIDATES]; |