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 <time.h> | |
int linear_search(int ara[], int n, int key) | |
{ | |
for (int i = 0; i < n; i++) { | |
if (ara[i] == key) { | |
return i; | |
} | |
} |
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
/*************************************************************************** | |
Sort a struct array in C using qsort function | |
****************************************************************************/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct Student { | |
char name[30]; |
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
""" | |
Generate all subsets of a set using recursion | |
""" | |
def subsets1(S): | |
if S == []: | |
return [[]] | |
result = [[]] | |
n = len(S) | |
visited = [False] * n |
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
import sys | |
def left(i): | |
return i * 2 | |
def right(i): | |
return i * 2 + 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
def left(i): | |
return 2 * i | |
def test_left(): | |
pass | |
def right(i): | |
return 2 * i + 1 |